solverforge_solver/phase/localsearch/
mod.rs

1//! Local search phase
2//!
3//! Improves an existing solution by iteratively applying moves
4//! that are accepted according to an acceptance criterion.
5
6mod acceptor;
7mod forager;
8mod phase;
9
10pub use acceptor::{
11    Acceptor, DiversifiedLateAcceptanceAcceptor, EntityTabuAcceptor, GreatDelugeAcceptor,
12    HillClimbingAcceptor, LateAcceptanceAcceptor, MoveTabuAcceptor, SimulatedAnnealingAcceptor,
13    StepCountingHillClimbingAcceptor, TabuSearchAcceptor, ValueTabuAcceptor,
14};
15pub use forager::{AcceptedCountForager, FirstAcceptedForager, LocalSearchForager};
16pub use phase::LocalSearchPhase;
17
18/// Local search phase configuration.
19#[derive(Debug, Clone)]
20pub struct LocalSearchConfig {
21    /// The acceptor type to use.
22    pub acceptor_type: AcceptorType,
23    /// Maximum number of steps (None = unlimited).
24    pub step_limit: Option<u64>,
25    /// Number of accepted moves to collect before quitting early.
26    pub accepted_count_limit: Option<usize>,
27}
28
29impl Default for LocalSearchConfig {
30    fn default() -> Self {
31        Self {
32            acceptor_type: AcceptorType::HillClimbing,
33            step_limit: Some(1000),
34            accepted_count_limit: Some(1),
35        }
36    }
37}
38
39/// Type of acceptor to use in local search.
40#[derive(Debug, Clone, Copy, PartialEq, Eq)]
41pub enum AcceptorType {
42    /// Accept only improving moves.
43    HillClimbing,
44    /// Accept moves with probability based on temperature.
45    SimulatedAnnealing,
46}