Trait metaheuristics::Metaheuristics [−][src]
pub trait Metaheuristics<T> { fn clone_candidate(&mut self, candidate: &T) -> T; fn generate_candidate(&mut self) -> T; fn rank_candidate(&mut self, candidate: &T) -> f64; fn tweak_candidate(&mut self, candidate: &T) -> T; }
Implement this simple trait to apply metaheuristics to your optimisation problems
Required Methods
fn clone_candidate(&mut self, candidate: &T) -> T
Clone the supplied candidate solution
let new_candidate = problem.clone_candidate(&old_candidate);
fn generate_candidate(&mut self) -> T
Randomly generate a new candidate solution
let candidate = problem.generate_candidate();
fn rank_candidate(&mut self, candidate: &T) -> f64
Rank a candidate solution so that it can be compared with another (higher is better)
if problem.rank_candidate(&new_candidate) > problem.rank_candidate(&old_candidate) { ... }
fn tweak_candidate(&mut self, candidate: &T) -> T
Clone the supplied candidate solution, then make a small (but random) modification
let new_candidate = problem.tweak_candidate(&old_candidate);