Skip to main content

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