solverforge_solver/phase/localsearch/acceptor/
mod.rs

1//! Acceptors for local search move acceptance.
2//!
3//! Acceptors determine whether a move should be accepted based on
4//! comparing the resulting score with the previous score.
5
6mod diversified_late_acceptance;
7mod entity_tabu;
8mod great_deluge;
9mod hill_climbing;
10mod late_acceptance;
11mod move_tabu;
12mod simulated_annealing;
13mod step_counting;
14mod tabu_search;
15mod value_tabu;
16
17use std::fmt::Debug;
18
19use solverforge_core::domain::PlanningSolution;
20
21pub use diversified_late_acceptance::DiversifiedLateAcceptanceAcceptor;
22pub use entity_tabu::EntityTabuAcceptor;
23pub use great_deluge::GreatDelugeAcceptor;
24pub use hill_climbing::HillClimbingAcceptor;
25pub use late_acceptance::LateAcceptanceAcceptor;
26pub use move_tabu::MoveTabuAcceptor;
27pub use simulated_annealing::SimulatedAnnealingAcceptor;
28pub use step_counting::StepCountingHillClimbingAcceptor;
29pub use tabu_search::TabuSearchAcceptor;
30pub use value_tabu::ValueTabuAcceptor;
31
32/// Trait for accepting or rejecting moves in local search.
33///
34/// Acceptors implement different strategies for escaping local optima,
35/// such as hill climbing, simulated annealing, or tabu search.
36pub trait Acceptor<S: PlanningSolution>: Send + Debug {
37    /// Returns true if a move resulting in `move_score` should be accepted,
38    /// given the previous step's score.
39    fn is_accepted(&self, last_step_score: &S::Score, move_score: &S::Score) -> bool;
40
41    /// Called when a phase starts.
42    fn phase_started(&mut self, _initial_score: &S::Score) {}
43
44    /// Called when a phase ends.
45    fn phase_ended(&mut self) {}
46
47    /// Called when a step starts.
48    fn step_started(&mut self) {}
49
50    /// Called when a step ends with an accepted move.
51    fn step_ended(&mut self, _step_score: &S::Score) {}
52}
53
54#[cfg(test)]
55mod tests;