pub struct FromLandscape<L> { /* private fields */ }Expand description
Adapter from Landscape to BatchFitnessFn<B, Tensor<B, 2>>.
Use this when the landscape carries its own evaluate(&[f64]) -> f64
(Sphere, Ackley, Rastrigin) so the example does not need a separate
FitnessEvaluable shim. Each row is pulled to host as f32, widened
to f64, evaluated, and re-uploaded as a Tensor<B, 1> — same
precision caveats as FromFitnessEvaluable apply.
§Panics
evaluate_batch panics if the supplied population tensor is not rank
2, or if its data cannot be read as f32 (e.g. an integer backend).
Implementations§
Source§impl<L: Landscape> FromLandscape<L>
impl<L: Landscape> FromLandscape<L>
Sourcepub fn new(landscape: L) -> Self
pub fn new(landscape: L) -> Self
Builds the adapter from a self-evaluating landscape, taking the
objective sense from the landscape’s Landscape::sense (which
defaults to ObjectiveSense::Minimize).
Sourcepub fn with_sense(landscape: L, sense: ObjectiveSense) -> Self
pub fn with_sense(landscape: L, sense: ObjectiveSense) -> Self
Builds the adapter with an explicit ObjectiveSense, overriding the
landscape’s declared sense. Examples and showcases spell out
ObjectiveSense::Minimize here so intent is visible at the call site.
Trait Implementations§
Source§impl<L, B> BatchFitnessFn<B, Tensor<B, 2>> for FromLandscape<L>
impl<L, B> BatchFitnessFn<B, Tensor<B, 2>> for FromLandscape<L>
Source§fn evaluate_batch(
&mut self,
population: &Tensor<B, 2>,
device: &<B as BackendTypes>::Device,
) -> Tensor<B, 1>
fn evaluate_batch( &mut self, population: &Tensor<B, 2>, device: &<B as BackendTypes>::Device, ) -> Tensor<B, 1>
population and returns a fitness tensor in
the objective’s natural value space (no hand-negation). Read moreSource§fn sense(&self) -> ObjectiveSense
fn sense(&self) -> ObjectiveSense
Auto Trait Implementations§
impl<L> Freeze for FromLandscape<L>where
L: Freeze,
impl<L> RefUnwindSafe for FromLandscape<L>where
L: RefUnwindSafe,
impl<L> Send for FromLandscape<L>where
L: Send,
impl<L> Sync for FromLandscape<L>where
L: Sync,
impl<L> Unpin for FromLandscape<L>where
L: Unpin,
impl<L> UnsafeUnpin for FromLandscape<L>where
L: UnsafeUnpin,
impl<L> UnwindSafe for FromLandscape<L>where
L: UnwindSafe,
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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