pub struct HallOfFame<B: Backend> { /* private fields */ }Expand description
Per-population archive of past champions, capped at a fixed capacity.
Each update appends the current generation’s best
individual (highest fitness, canonical maximise convention) to each
population’s archive. When an archive would exceed capacity the single
worst-fitness (lowest) member is dropped, so the archive always retains the
capacity best champions seen across the whole run.
The capacity is computed by capacity_for as
max(10, pop_size / 5) (Rosin & Belew sizing).
§Invariants
- All archives share a single
genome_dim; v1 co-evolution is bi-population over equal-width genomes. Asymmetric genome widths are out of scope. archives()[p].dims()[0] <= capacityafter everyupdate.
Implementations§
Source§impl<B: Backend> HallOfFame<B>
impl<B: Backend> HallOfFame<B>
Sourcepub fn new(
num_populations: usize,
capacity: usize,
genome_dim: usize,
device: &<B as BackendTypes>::Device,
) -> Self
pub fn new( num_populations: usize, capacity: usize, genome_dim: usize, device: &<B as BackendTypes>::Device, ) -> Self
Build an empty hall of fame for num_populations populations.
Each archive starts as a (0, genome_dim) tensor and grows by one row
per update until capacity is reached.
Sourcepub fn capacity_for(pop_size: usize) -> usize
pub fn capacity_for(pop_size: usize) -> usize
Recommended capacity for a population of pop_size: max(10, pop_size / 5).
Sourcepub fn update(
&mut self,
populations: &[Tensor<B, 2>],
fitnesses: &[Tensor<B, 1>],
)
pub fn update( &mut self, populations: &[Tensor<B, 2>], fitnesses: &[Tensor<B, 1>], )
Insert the best individual of each population into its archive.
For population p, the highest-fitness row of populations[p] is
appended to archives[p] (canonical maximise: higher is better). If that
pushes the archive past capacity, the single lowest-fitness (worst)
archived member is removed. Empty populations are skipped.
This method is sense-blind: it argmaxes highest = best and evicts
lowest = worst, which is correct only in canonical (maximise) space. The
caller is responsible for passing canonical fitness — for a
Minimize objective the natural cost must be negated first, or the
highest-cost (worst) individual would be crowned champion.
§Panics
Panics if a population’s fitness tensor cannot be read back to host as
f32 (a device→host transfer failure). A legitimately empty population
is a valid non-error host-read and is skipped, not a panic.
Trait Implementations§
Auto Trait Implementations§
impl<B> Freeze for HallOfFame<B>
impl<B> RefUnwindSafe for HallOfFame<B>where
<B as BackendTypes>::FloatTensorPrimitive: RefUnwindSafe,
<B as BackendTypes>::QuantizedTensorPrimitive: RefUnwindSafe,
impl<B> Send for HallOfFame<B>
impl<B> Sync for HallOfFame<B>
impl<B> Unpin for HallOfFame<B>where
<B as BackendTypes>::FloatTensorPrimitive: Unpin,
<B as BackendTypes>::QuantizedTensorPrimitive: Unpin,
impl<B> UnsafeUnpin for HallOfFame<B>
impl<B> UnwindSafe for HallOfFame<B>where
<B as BackendTypes>::FloatTensorPrimitive: UnwindSafe,
<B as BackendTypes>::QuantizedTensorPrimitive: 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<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