pub struct NeatStrategy<B: Backend> { /* private fields */ }Expand description
Custom NEAT harness. Does not implement
Strategy — see the module docs.
Implementations§
Source§impl<B: Backend> NeatStrategy<B>
impl<B: Backend> NeatStrategy<B>
Sourcepub fn init(
&self,
params: &NeatParams,
rng: &mut dyn Rng,
device: &<B as BackendTypes>::Device,
) -> NeatState
pub fn init( &self, params: &NeatParams, rng: &mut dyn Rng, device: &<B as BackendTypes>::Device, ) -> NeatState
Build the initial state: a per-run registry plus pop_size minimal
genomes (aligned ids, per-individual random weights from one
SeedPurpose::Init substream).
device is part of the harness signature for symmetry with the tensor
strategies; NEAT genomes are host-side, so it is unused here.
§Panics
Panics if weight_init_std is non-finite (+∞ or NaN).
Sourcepub fn ask(
&self,
params: &NeatParams,
state: &NeatState,
rng: &mut dyn Rng,
) -> (Vec<TopologyGenome>, NeatState)
pub fn ask( &self, params: &NeatParams, state: &NeatState, rng: &mut dyn Rng, ) -> (Vec<TopologyGenome>, NeatState)
Propose the next population.
Before the first tell (resident fitness still empty), the
unchanged resident population is returned for evaluation. Afterwards the
already-speciated residents drive reproduction: stagnant species are
removed (top-K protected), offspring are apportioned by size-adjusted
fitness (largest-remainder, summing exactly to pop_size), and each
species contributes its champion unchanged (if large enough) plus
offspring from intra-species crossover (rare interspecies mating) or
mutation-only, all followed by the four mutation operators. Four StdRng
substreams (selection, crossover, mutation, misc) keep operator RNG
independent.
Sourcepub fn tell(
&self,
params: &NeatParams,
population: Vec<TopologyGenome>,
fitness: Vec<f32>,
state: NeatState,
rng: &mut dyn Rng,
) -> NeatState
pub fn tell( &self, params: &NeatParams, population: Vec<TopologyGenome>, fitness: Vec<f32>, state: NeatState, rng: &mut dyn Rng, ) -> NeatState
Install the evaluated population and its (maximization) fitness, speciate, update per-species best/stagnation and the global best-so-far, and bump the generation.
Speciation lives here — not in ask — because this is the only point
where the new population, its fitness, and the prior species’ cloned
representatives all coexist consistently (so member indices stay valid and
each species’ next representative is cloned from a live member).
§Fitness hygiene
This is NEAT’s driver chokepoint (ADR 0034): NEAT is its own driver
and does not run through
EvolutionaryHarness, so there is
no harness above it to sanitize fitness. tell therefore applies
sanitize_fitness to the incoming
fitness (NaN → −∞, +∞ → f32::MAX, −∞ and finite pass through)
before it is stored or handed to species::speciate, so a
non-finite fitness can never poison speciation, offspring apportionment,
or best-so-far tracking.
§Panics
Panics if population.len() differs from fitness.len().
Trait Implementations§
Source§impl<B: Clone + Backend> Clone for NeatStrategy<B>
impl<B: Clone + Backend> Clone for NeatStrategy<B>
Source§fn clone(&self) -> NeatStrategy<B>
fn clone(&self) -> NeatStrategy<B>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<B: Copy + Backend> Copy for NeatStrategy<B>
Auto Trait Implementations§
impl<B> Freeze for NeatStrategy<B>
impl<B> RefUnwindSafe for NeatStrategy<B>
impl<B> Send for NeatStrategy<B>
impl<B> Sync for NeatStrategy<B>
impl<B> Unpin for NeatStrategy<B>
impl<B> UnsafeUnpin for NeatStrategy<B>
impl<B> UnwindSafe for NeatStrategy<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
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>
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