Struct metaheuristics_nature::utility::Context
source · [−]#[non_exhaustive]pub struct Context<F: ObjFunc> {
pub rng: Rng,
pub best: Array1<f64>,
pub best_f: F::Fitness,
pub pool: Array2<f64>,
pub fitness: Vec<F::Fitness>,
pub adaptive: f64,
pub gen: u64,
pub func: F,
}
Expand description
The base class of algorithms.
This type provides a shared dataset if you want to implement a new method.
Please see Algorithm
for the implementation.
Fields (Non-exhaustive)
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.rng: Rng
Random number generator.
best: Array1<f64>
The best variables.
best_f: F::Fitness
Best fitness.
pool: Array2<f64>
Current variables of all individuals.
fitness: Vec<F::Fitness>
Current fitness of all individuals.
adaptive: f64
Adaptive factor.
gen: u64
Generation.
func: F
The objective function.
Implementations
sourceimpl<F: ObjFunc> Context<F>
impl<F: ObjFunc> Context<F>
sourcepub fn set_best_from<'a, A>(&mut self, f: F::Fitness, v: A) where
A: AsArray<'a, f64>,
pub fn set_best_from<'a, A>(&mut self, f: F::Fitness, v: A) where
A: AsArray<'a, f64>,
Set the fitness and variables to best.
sourcepub fn assign_from_best(&mut self, i: usize)
pub fn assign_from_best(&mut self, i: usize)
Assign the index from best.
Auto Trait Implementations
impl<F> RefUnwindSafe for Context<F> where
F: RefUnwindSafe,
<F as ObjFunc>::Fitness: RefUnwindSafe,
impl<F> Send for Context<F>
impl<F> Sync for Context<F>
impl<F> Unpin for Context<F> where
F: Unpin,
<F as ObjFunc>::Fitness: Unpin,
impl<F> UnwindSafe for Context<F> where
F: UnwindSafe,
<F as ObjFunc>::Fitness: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more