solverforge_solver/phase/mod.rs
1//! Solver phases for different solving strategies
2//!
3//! Phases are the main building blocks of solving:
4//! - ConstructionHeuristicPhase: Builds an initial solution
5//! - LocalSearchPhase: Improves an existing solution
6//! - ExhaustiveSearchPhase: Explores entire solution space
7//! - PartitionedSearchPhase: Parallel solving via partitioning
8//! - VndPhase: Variable Neighborhood Descent
9
10pub mod construction;
11pub mod exhaustive;
12pub mod localsearch;
13pub mod partitioned;
14mod tuple_impl;
15pub mod vnd;
16
17use std::fmt::Debug;
18
19use solverforge_core::domain::PlanningSolution;
20use solverforge_scoring::ScoreDirector;
21
22use crate::scope::SolverScope;
23
24/// A phase of the solving process.
25///
26/// Phases are executed in sequence by the solver. Each phase has its own
27/// strategy for exploring or constructing solutions.
28///
29/// # Type Parameters
30/// * `S` - The planning solution type
31/// * `D` - The score director type
32pub trait Phase<S: PlanningSolution, D: ScoreDirector<S>>: Send + Debug {
33 /// Executes this phase.
34 ///
35 /// The phase should modify the working solution in the solver scope
36 /// and update the best solution when improvements are found.
37 fn solve(&mut self, solver_scope: &mut SolverScope<'_, S, D>);
38
39 /// Returns the name of this phase type.
40 fn phase_type_name(&self) -> &'static str;
41}
42
43/// Unit type implements Phase as a no-op (empty phase list).
44impl<S: PlanningSolution, D: ScoreDirector<S>> Phase<S, D> for () {
45 fn solve(&mut self, _solver_scope: &mut SolverScope<'_, S, D>) {
46 // No-op: empty phase list does nothing
47 }
48
49 fn phase_type_name(&self) -> &'static str {
50 "NoOp"
51 }
52}