pub enum LocalSearchType {
HillClimbing,
TabuSearch {
tabu_size: usize,
},
SimulatedAnnealing {
starting_temp: f64,
decay_rate: f64,
},
LateAcceptance {
size: usize,
},
ValueTabuSearch {
value_tabu_size: usize,
},
MoveTabuSearch {
move_tabu_size: usize,
aspiration_enabled: bool,
},
}Expand description
Type of local search algorithm to use.
Different local search algorithms have different characteristics:
HillClimbing: Simple, fast, but can get stuck in local optimaTabuSearch: Avoids revisiting recent statesSimulatedAnnealing: Probabilistic acceptance of worse movesLateAcceptance: Compares against historical scores
§Examples
use solverforge_solver::manager::LocalSearchType;
// Hill climbing - simplest approach
let hill = LocalSearchType::HillClimbing;
assert_eq!(hill, LocalSearchType::default());
// Tabu search with memory of 10 recent moves
let tabu = LocalSearchType::TabuSearch { tabu_size: 10 };
// Simulated annealing with temperature decay
let sa = LocalSearchType::SimulatedAnnealing {
starting_temp: 1.0,
decay_rate: 0.995,
};
// Late acceptance comparing to 100 steps ago
let late = LocalSearchType::LateAcceptance { size: 100 };Variants§
HillClimbing
Hill climbing: only accept improving moves.
This is the simplest local search strategy. It only accepts moves that improve the score. Fast but can easily get stuck in local optima.
§Example
use solverforge_solver::manager::LocalSearchType;
let acceptor = LocalSearchType::HillClimbing;TabuSearch
Tabu search: avoid recently visited states.
Maintains a list of recently made moves and forbids reversing them. This helps escape local optima by forcing exploration.
§Example
use solverforge_solver::manager::LocalSearchType;
// Keep last 7 moves in tabu list
let tabu = LocalSearchType::TabuSearch { tabu_size: 7 };SimulatedAnnealing
Simulated annealing: accept worse moves with decreasing probability.
Initially accepts worse moves with high probability, but as the “temperature” decreases, it becomes more selective. Good for escaping local optima early in the search.
§Example
use solverforge_solver::manager::LocalSearchType;
// Start with temperature 1.0, decay by 0.1% per step
let sa = LocalSearchType::SimulatedAnnealing {
starting_temp: 1.0,
decay_rate: 0.999,
};LateAcceptance
Late acceptance: compare against score from N steps ago.
Accepts a move if the new score is better than the score from N steps ago. Provides a balance between exploration and exploitation.
§Example
use solverforge_solver::manager::LocalSearchType;
// Compare against score from 400 steps ago
let late = LocalSearchType::LateAcceptance { size: 400 };ValueTabuSearch
Value tabu search: forbid recently assigned values.
Remembers recently assigned values and forbids reassigning them. Different from entity tabu in that it tracks the values themselves, not the entity-variable combinations.
§Example
use solverforge_solver::manager::LocalSearchType;
// Forbid last 5 assigned values
let value_tabu = LocalSearchType::ValueTabuSearch { value_tabu_size: 5 };MoveTabuSearch
Move tabu search: forbid recently made moves.
Remembers recently made moves (by hash) and forbids making the same move again. Supports aspiration criterion: tabu moves can be accepted if they lead to a new best solution.
§Example
use solverforge_solver::manager::LocalSearchType;
// Forbid last 10 moves, with aspiration enabled
let move_tabu = LocalSearchType::MoveTabuSearch {
move_tabu_size: 10,
aspiration_enabled: true,
};Trait Implementations§
Source§impl Clone for LocalSearchType
impl Clone for LocalSearchType
Source§fn clone(&self) -> LocalSearchType
fn clone(&self) -> LocalSearchType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LocalSearchType
impl Debug for LocalSearchType
Source§impl Default for LocalSearchType
impl Default for LocalSearchType
Source§fn default() -> Self
fn default() -> Self
Returns HillClimbing as the default.
§Example
use solverforge_solver::manager::LocalSearchType;
let default = LocalSearchType::default();
assert_eq!(default, LocalSearchType::HillClimbing);