Trait metaheuristics_nature::Algorithm [−][src]
The methods of the metaheuristic algorithms.
This trait is extendable.
Create a structure and store a AlgorithmBase
member to implement it.
use metaheuristics_nature::{AlgorithmBase, Algorithm, ObjFunc, Setting}; struct MyAlgorithm<F: ObjFunc> { tmp: Vec<f64>, base: AlgorithmBase<F>, } impl<F: ObjFunc> MyAlgorithm<F> { fn new(func: F, settings: Setting) -> Self { let base = AlgorithmBase::new(func, settings); Self { tmp: vec![], base, } } } impl<F: ObjFunc> Algorithm<F> for MyAlgorithm<F> { fn base(&self) -> &AlgorithmBase<F> { &self.base } fn base_mut(&mut self) -> &mut AlgorithmBase<F> { &mut self.base } fn generation(&mut self) { unimplemented!() } }
Your algorithm will be implemented Solver automatically.
Required methods
fn base(&self) -> &AlgorithmBase<F>
[src]
Return a base handle.
fn base_mut(&mut self) -> &mut AlgorithmBase<F>
[src]
Return a mutable base handle.
fn generation(&mut self)
[src]
Processing implementation of each generation.
Provided methods
fn init(&mut self)
[src]
Initialization implementation.
fn lb(&self, i: usize) -> f64
[src]
Get lower bound with index.
fn ub(&self, i: usize) -> f64
[src]
Get upper bound with index.
fn assign_from(&mut self, i: usize, f: f64, v: Vec<f64>)
[src]
Assign from source.
fn set_best(&mut self, i: usize)
[src]
Set the index to best.
fn find_best(&mut self)
[src]
Find the best, and set it globally.
fn init_pop(&mut self)
[src]
Initialize population.
fn check(&self, s: usize, v: f64) -> f64
[src]
Check the bounds.