Skip to main content

solverforge_solver/termination/
traits.rs

1// Termination trait definition.
2
3use std::fmt::Debug;
4
5use solverforge_core::domain::PlanningSolution;
6use solverforge_scoring::Director;
7
8use crate::scope::BestSolutionCallback;
9use crate::scope::SolverScope;
10
11/// Trait for determining when to stop solving.
12///
13/// # Type Parameters
14/// * `S` - The planning solution type
15/// * `D` - The score director type
16/// * `BestCb` - The best-solution callback type (default `()`)
17pub trait Termination<S: PlanningSolution, D: Director<S>, BestCb: BestSolutionCallback<S> = ()>:
18    Send + Debug
19{
20    // Returns true if solving should terminate.
21    fn is_terminated(&self, solver_scope: &SolverScope<S, D, BestCb>) -> bool;
22
23    /* Installs this termination's limit as an in-phase limit on the solver scope.
24
25    This allows the termination to fire inside the phase step loop (T1 fix).
26    The default implementation is a no-op.
27    */
28    fn install_inphase_limits(&self, _solver_scope: &mut SolverScope<S, D, BestCb>) {}
29}