pub struct BatchGraphFitness<B: Backend, E> { /* private fields */ }Expand description
A GraphFitnessFn that scores the whole population in one device-resident
pass via a BatchPhenotypeEvaluator, instead of the per-genome interpreted
loop.
It is a drop-in alternative to an interpreted GraphFitnessFn in the same
manual init → ask → evaluate → tell loop: the builder argument is ignored
(the batched evaluator owns evaluation), so the harness stays
evaluation-agnostic and NeatStrategy’s determinism is untouched.
The reducer maps one genome’s batch × action_dim output slab (row-major,
as produced by BatchPhenotypeEvaluator::evaluate_population) to a single
maximization fitness — the batched analogue of the per-genome scoring an
interpreted GraphFitnessFn does on phenotype.forward(...).
Implementations§
Source§impl<B: Backend, E> BatchGraphFitness<B, E>
impl<B: Backend, E> BatchGraphFitness<B, E>
Trait Implementations§
Source§impl<B: Backend, E> Debug for BatchGraphFitness<B, E>
impl<B: Backend, E> Debug for BatchGraphFitness<B, E>
Source§impl<B: Backend, E: BatchPhenotypeEvaluator<B>> GraphFitnessFn<B> for BatchGraphFitness<B, E>
impl<B: Backend, E: BatchPhenotypeEvaluator<B>> GraphFitnessFn<B> for BatchGraphFitness<B, E>
Source§fn evaluate(
&self,
population: &[TopologyGenome],
_builder: &dyn PhenotypeBuilder<B>,
device: &<B as BackendTypes>::Device,
) -> Vec<f32>
fn evaluate( &self, population: &[TopologyGenome], _builder: &dyn PhenotypeBuilder<B>, device: &<B as BackendTypes>::Device, ) -> Vec<f32>
Score every genome in
population, returning one maximization
fitness per genome (higher is better, matching the crate-wide canonical
convention). Fitness sharing assumes the values are non-negative. The
returned Vec has one entry per input genome, in order. Build each
genome’s network with builder on device.Auto Trait Implementations§
impl<B, E> !RefUnwindSafe for BatchGraphFitness<B, E>
impl<B, E> !UnwindSafe for BatchGraphFitness<B, E>
impl<B, E> Freeze for BatchGraphFitness<B, E>where
E: Freeze,
<B as BackendTypes>::FloatTensorPrimitive: Freeze,
<B as BackendTypes>::QuantizedTensorPrimitive: Freeze,
impl<B, E> Send for BatchGraphFitness<B, E>where
E: Send,
impl<B, E> Sync for BatchGraphFitness<B, E>where
E: Sync,
impl<B, E> Unpin for BatchGraphFitness<B, E>where
E: Unpin,
<B as BackendTypes>::FloatTensorPrimitive: Unpin,
<B as BackendTypes>::QuantizedTensorPrimitive: Unpin,
impl<B, E> UnsafeUnpin for BatchGraphFitness<B, E>where
E: UnsafeUnpin,
<B as BackendTypes>::FloatTensorPrimitive: UnsafeUnpin,
<B as BackendTypes>::QuantizedTensorPrimitive: UnsafeUnpin,
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> 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