pub struct GepState<B: Backend> { /* private fields */ }Expand description
Generation state for GepStrategy.
Fields are private so the host-side fitness cache cannot fall out of sync
with the population from outside this module; build one with
try_new and read it through the accessors.
Implementations§
Source§impl<B: Backend> GepState<B>
impl<B: Backend> GepState<B>
Sourcepub fn try_new(
population: Tensor<B, 2, Int>,
fitnesses: Vec<f32>,
best_genome: Option<Tensor<B, 2, Int>>,
best_fitness: f32,
generation: usize,
) -> Result<Self, ConfigError>
pub fn try_new( population: Tensor<B, 2, Int>, fitnesses: Vec<f32>, best_genome: Option<Tensor<B, 2, Int>>, best_fitness: f32, generation: usize, ) -> Result<Self, ConfigError>
Assembles a GEP state, checking the fitness cache matches the population.
§Errors
Returns a ConfigError if population has zero rows or if
fitnesses is non-empty with a length other than pop_size. The
bootstrap state (empty fitnesses) is accepted.
Sourcepub fn population(&self) -> &Tensor<B, 2, Int>
pub fn population(&self) -> &Tensor<B, 2, Int>
Current population, shape (pop_size, genome_len).
Sourcepub fn fitnesses(&self) -> &[f32]
pub fn fitnesses(&self) -> &[f32]
Host-side fitness cache (empty at bootstrap, else pop_size long).
Sourcepub fn best_genome(&self) -> Option<&Tensor<B, 2, Int>>
pub fn best_genome(&self) -> Option<&Tensor<B, 2, Int>>
Best-so-far genome (shape (1, genome_len)), or None before the
first tell.
Sourcepub fn best_fitness(&self) -> f32
pub fn best_fitness(&self) -> f32
Best-so-far (canonical, maximise) fitness.
Sourcepub fn generation(&self) -> usize
pub fn generation(&self) -> usize
Generation counter.
Trait Implementations§
Auto Trait Implementations§
impl<B> Freeze for GepState<B>
impl<B> RefUnwindSafe for GepState<B>
impl<B> Send for GepState<B>
impl<B> Sync for GepState<B>
impl<B> Unpin for GepState<B>
impl<B> UnsafeUnpin for GepState<B>
impl<B> UnwindSafe for GepState<B>
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<C> CloneExpand for Cwhere
C: Clone,
impl<C> CloneExpand for Cwhere
C: Clone,
fn __expand_clone_method(&self, _scope: &mut Scope) -> C
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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