solverforge_scoring/lib.rs
1//! Incremental constraint scoring for SolverForge.
2//!
3//! Applications use it through the `solverforge` facade. It provides:
4//! - the constraint stream API (`stream`): `for_each`, joins, filters,
5//! grouping and the `penalize`/`reward` terminals that build constraints;
6//! - incremental constraints such as [`IncrementalUniConstraint`], which
7//! update their score from the entities a move changed instead of
8//! rescoring the whole solution;
9//! - [`ScoreDirector`], which owns the working solution and its constraint
10//! set and keeps the score current as moves are applied and undone;
11//! - [`ConstraintSet`], a tuple of constraints evaluated without dynamic
12//! dispatch.
13//!
14//! Every constraint is monomorphized: closures are generic parameters, and
15//! there is no `Box<dyn Trait>` on the scoring path.
16
17// Zero-erasure architecture intentionally uses complex generic types
18
19// Core modules
20pub mod api;
21pub mod constraint;
22pub mod director;
23pub mod stream;
24
25/* ============================================================================
26Zero-Erasure Incremental Constraints
27============================================================================
28*/
29
30pub use constraint::{IncrementalUniConstraint, ListPrecedenceMakespanConstraint};
31
32/* ============================================================================
33Constraint Set (Tuple-Based, Zero-Erasure)
34============================================================================
35*/
36
37pub use api::constraint_set::{
38 ConstraintMetadata, ConstraintResult, ConstraintSet, ConstraintSetSource,
39 IncrementalConstraint, OrderedConstraintSetChain, SingleConstraint,
40};
41pub use api::node_sharing::{SharedNodeDiagnostics, SharedNodeId, SharedNodeOperation};
42
43/* ============================================================================
44Score Directors
45============================================================================
46*/
47
48pub use director::score_director::{
49 requires_weighted_mode, DirectorDescriptor, ScoreDirector, UnweightedMode, WeightMode,
50 WeightedMode,
51};
52pub use director::{Director, DirectorScoreState, SolvableSolution};
53
54/* ============================================================================
55Analysis (for score explanation)
56============================================================================
57*/
58
59pub use api::analysis::{
60 ConstraintAnalysis, ConstraintJustification, DetailedConstraintMatch, EntityRef,
61};
62
63/* ============================================================================
64Fluent Constraint Stream API
65============================================================================
66*/
67
68pub use stream::{
69 fixed_weight, hard_weight, BiConstraintBuilder, BiConstraintStream, ConstraintFactory,
70 ConstraintWeight, FixedWeight, GroupedConstraintBuilder, GroupedConstraintStream, HardWeight,
71 Projection, ProjectionSink, UniConstraintBuilder, UniConstraintStream,
72};