Skip to main content

solverforge_solver/phase/localsearch/acceptor/
traits.rs

1//! Acceptor trait definition.
2
3use std::fmt::Debug;
4
5use solverforge_core::domain::PlanningSolution;
6
7/// Trait for accepting or rejecting moves in local search.
8///
9/// Acceptors implement different strategies for escaping local optima,
10/// such as hill climbing, simulated annealing, or tabu search.
11pub trait Acceptor<S: PlanningSolution>: Send + Debug {
12    /// Returns true if a move resulting in `move_score` should be accepted,
13    /// given the previous step's score.
14    fn is_accepted(&mut self, last_step_score: &S::Score, move_score: &S::Score) -> bool;
15
16    /// Called when a phase starts.
17    fn phase_started(&mut self, _initial_score: &S::Score) {}
18
19    /// Called when a phase ends.
20    fn phase_ended(&mut self) {}
21
22    /// Called when a step starts.
23    fn step_started(&mut self) {}
24
25    /// Called when a step ends with an accepted move.
26    fn step_ended(&mut self, _step_score: &S::Score) {}
27}