Struct metaheuristics_nature::Fx
source · pub struct Fx<'b, 'f, Y: Fitness, const DIM: usize> { /* private fields */ }
Expand description
A quick interface help to create objective function from a callable object.
See also ObjFunc
for implementing the full definitions.
use metaheuristics_nature::{Fx, Rga, Solver};
let bound = [[-50., 50.]; 4];
let f = Fx::new(&bound, |&[a, b, c, d]| a * a + 8. * b * b + c * c + d * d);
let s = Solver::build(Rga::default(), f)
.seed(0)
.task(|ctx| ctx.gen == 20)
.solve();
Implementations§
Trait Implementations§
source§impl<Y: Fitness, const DIM: usize> Bounded for Fx<'_, '_, Y, DIM>
impl<Y: Fitness, const DIM: usize> Bounded for Fx<'_, '_, Y, DIM>
source§fn bound(&self) -> &[[f64; 2]]
fn bound(&self) -> &[[f64; 2]]
The upper bound and lower bound in
[[lower, upper]; number_of_vars]
form. Read moresource§fn bound_width(&self, s: usize) -> f64
fn bound_width(&self, s: usize) -> f64
Get the width of the upper bound and the lower bound.
source§fn bound_range(&self, s: usize) -> RangeInclusive<f64>
fn bound_range(&self, s: usize) -> RangeInclusive<f64>
Get the upper bound and the lower bound as a range. Read more
Auto Trait Implementations§
impl<'b, 'f, Y, const DIM: usize> Freeze for Fx<'b, 'f, Y, DIM>
impl<'b, 'f, Y, const DIM: usize> !RefUnwindSafe for Fx<'b, 'f, Y, DIM>
impl<'b, 'f, Y, const DIM: usize> Send for Fx<'b, 'f, Y, DIM>
impl<'b, 'f, Y, const DIM: usize> Sync for Fx<'b, 'f, Y, DIM>
impl<'b, 'f, Y, const DIM: usize> Unpin for Fx<'b, 'f, Y, DIM>
impl<'b, 'f, Y, const DIM: usize> !UnwindSafe for Fx<'b, 'f, Y, DIM>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more