Constraint Streams
Declarative constraint definition using the stream API.
Constraints are the business rules that define what makes a good solution. SolverForge uses a constraint streams API — a declarative, composable way to express rules that reads like a pipeline of filters and transformations.
for_each.named()let factory = ConstraintFactory::<Schedule, HardSoftScore>::new();
factory.for_each(|s: &Schedule| s.shifts.as_slice()) // Select all shifts
.filter(|s| s.employee_idx.is_none()) // Keep unassigned ones
.penalize(HardSoftScore::ONE_HARD) // Penalize each
.named("Unassigned shift") // Finalize
Constraints are returned as a tuple implementing ConstraintSet<S, Sc>, which the solver evaluates incrementally as it explores moves.
group_byDeclarative constraint definition using the stream API.
Control which tuples are created when joining constraint streams.
Aggregation functions for group_by operations in constraint streams.
Choose the right score type for your optimization problem.
Understand why a solution received its score with ScoreAnalysis.
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.