pub struct CmsaEsState<B: Backend> { /* private fields */ }Expand description
Generation state for CmsaEs.
All adaptive quantities live here (not in CmsaEsConfig) so instances stay
lock-free across parallel runs. Linear-algebra state — the mean and
covariance — is held host-side as Vec<f32>; only the offspring population
crosses to the device.
Implementations§
Source§impl<B: Backend> CmsaEsState<B>
impl<B: Backend> CmsaEsState<B>
Sourcepub fn try_new(
mean: Vec<f32>,
cov: Vec<f32>,
sigma: f32,
offspring_sigmas: Vec<f32>,
generation: usize,
best_genome: Option<Tensor<B, 2>>,
best_fitness: f32,
) -> Result<Self, ConfigError>
pub fn try_new( mean: Vec<f32>, cov: Vec<f32>, sigma: f32, offspring_sigmas: Vec<f32>, generation: usize, best_genome: Option<Tensor<B, 2>>, best_fitness: f32, ) -> Result<Self, ConfigError>
Assembles a CMSA-ES state, checking the distribution parameters are
dimensionally consistent and normalizing cov to exact symmetry.
The supplied cov is symmetrized in place via
crate::ops::linalg::symmetrize before construction. The in-loop
covariance blend in tell already preserves bit-exact
symmetry — IEEE-754 multiplication is commutative and the two triangle
entries C[i,j] / C[j,i] accumulate the identical rank-μ terms in the
identical order — so caller-supplied construction is the only asymmetry
entry point. Normalizing it here mirrors pycma practice and the
ADR 0034 sanitize-at-chokepoint convention.
§Errors
Returns a ConfigError if mean is empty, if cov is not D × D
row-major (D = mean.len()), or if sigma is not strictly positive and
finite. No length constraint is imposed on offspring_sigmas: it may be
empty (the pre-ask state) or any length — tell falls
back to sigma for any missing entry.
Sourcepub fn offspring_sigmas(&self) -> &[f32]
pub fn offspring_sigmas(&self) -> &[f32]
Per-offspring step sizes σᵢ, carried ask → tell (empty before the
first ask).
Sourcepub fn generation(&self) -> usize
pub fn generation(&self) -> usize
Completed-generation counter.
Sourcepub fn best_genome(&self) -> Option<&Tensor<B, 2>>
pub fn best_genome(&self) -> Option<&Tensor<B, 2>>
Best-so-far genome (shape (1, D)), or None before the first tell.
Sourcepub fn best_fitness(&self) -> f32
pub fn best_fitness(&self) -> f32
Best-so-far (canonical, maximise) fitness.
Trait Implementations§
Auto Trait Implementations§
impl<B> Freeze for CmsaEsState<B>where
<B as BackendTypes>::FloatTensorPrimitive: Freeze,
<B as BackendTypes>::QuantizedTensorPrimitive: Freeze,
impl<B> RefUnwindSafe for CmsaEsState<B>where
<B as BackendTypes>::FloatTensorPrimitive: RefUnwindSafe,
<B as BackendTypes>::QuantizedTensorPrimitive: RefUnwindSafe,
impl<B> Send for CmsaEsState<B>
impl<B> Sync for CmsaEsState<B>
impl<B> Unpin for CmsaEsState<B>where
<B as BackendTypes>::FloatTensorPrimitive: Unpin,
<B as BackendTypes>::QuantizedTensorPrimitive: Unpin,
impl<B> UnsafeUnpin for CmsaEsState<B>where
<B as BackendTypes>::FloatTensorPrimitive: UnsafeUnpin,
<B as BackendTypes>::QuantizedTensorPrimitive: UnsafeUnpin,
impl<B> UnwindSafe for CmsaEsState<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