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#![allow(clippy::type_complexity)]
19#![warn(unreachable_pub)]
20#![warn(missing_docs)]
21
22// Core modules
23pub mod api;
24pub mod constraint;
25pub mod director;
26pub mod stream;
27
28/* ============================================================================
29Zero-Erasure Incremental Constraints
30============================================================================
31*/
32
33pub use constraint::{IncrementalUniConstraint, ListPrecedenceMakespanConstraint};
34
35/* ============================================================================
36Constraint Set (Tuple-Based, Zero-Erasure)
37============================================================================
38*/
39
40pub use api::constraint_set::{
41 ConstraintMetadata, ConstraintResult, ConstraintSet, ConstraintSetSource,
42 IncrementalConstraint, OrderedConstraintSetChain, SingleConstraint,
43};
44pub use api::node_sharing::{SharedNodeDiagnostics, SharedNodeId, SharedNodeOperation};
45
46/* ============================================================================
47Score Directors
48============================================================================
49*/
50
51pub use director::score_director::{
52 requires_weighted_mode, DirectorDescriptor, ReplicaDescriptor, ScoreDirector, UnweightedMode,
53 WeightMode, WeightedMode,
54};
55pub use director::{Director, DirectorScoreState, SolvableSolution};
56
57/* ============================================================================
58Analysis (for score explanation)
59============================================================================
60*/
61
62pub use api::analysis::{
63 ConstraintAnalysis, ConstraintJustification, DetailedConstraintMatch, EntityRef,
64};
65
66/* ============================================================================
67Fluent Constraint Stream API
68============================================================================
69*/
70
71pub use stream::{
72 fixed_weight, hard_weight, BiConstraintBuilder, BiConstraintStream, ConstraintFactory,
73 FixedWeight, GroupedConstraintBuilder, GroupedConstraintStream, HardWeight, Projection,
74 ProjectionSink, UniConstraintBuilder, UniConstraintStream,
75};