pub struct EvolutionStrategy<B: Backend> { /* private fields */ }Expand description
Classical Evolution Strategy.
§Example
use burn::backend::Flex;
use rlevo_evolution::algorithms::es_classical::{EsConfig, EsKind, EvolutionStrategy};
let strategy = EvolutionStrategy::<Flex>::new();
let params = EsConfig::default_for(EsKind::MuPlusLambda { mu: 5, lambda: 20 }, 10);
let _ = (strategy, params);Implementations§
Trait Implementations§
Source§impl<B: Clone + Backend> Clone for EvolutionStrategy<B>
impl<B: Clone + Backend> Clone for EvolutionStrategy<B>
Source§fn clone(&self) -> EvolutionStrategy<B>
fn clone(&self) -> EvolutionStrategy<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 EvolutionStrategy<B>
Source§impl<B: Default + Backend> Default for EvolutionStrategy<B>
impl<B: Default + Backend> Default for EvolutionStrategy<B>
Source§fn default() -> EvolutionStrategy<B>
fn default() -> EvolutionStrategy<B>
Source§impl<B: Backend> Strategy<B> for EvolutionStrategy<B>
impl<B: Backend> Strategy<B> for EvolutionStrategy<B>
Source§fn init(
&self,
params: &EsConfig,
rng: &mut dyn Rng,
device: &<B as BackendTypes>::Device,
) -> EsState<B>
fn init( &self, params: &EsConfig, rng: &mut dyn Rng, device: &<B as BackendTypes>::Device, ) -> EsState<B>
Samples the initial parent population uniformly from params.bounds
via a deterministic seed_stream (host-RNG convention) and
initializes all σ values to params.initial_sigma.
Source§fn ask(
&self,
params: &EsConfig,
state: &EsState<B>,
rng: &mut dyn Rng,
device: &<B as BackendTypes>::Device,
) -> (Tensor<B, 2>, EsState<B>)
fn ask( &self, params: &EsConfig, state: &EsState<B>, rng: &mut dyn Rng, device: &<B as BackendTypes>::Device, ) -> (Tensor<B, 2>, EsState<B>)
Generates the offspring population for the current generation.
On the very first call (before any tell), returns the initial parents
unchanged so that they can be fitness-evaluated as the seed population.
On subsequent calls, duplicates parents by uniform random selection,
applies log-normal σ adaptation (multi-parent variants) or inherits the
shared σ ((1+1) / (1+λ)), then mutates via per-individual Gaussian
noise. All stochastic draws go through seed_stream
(host-RNG convention); offspring σ values are appended to
state.sigmas for consumption by tell.
Source§fn tell(
&self,
params: &EsConfig,
offspring: Tensor<B, 2>,
fitness: Tensor<B, 1>,
state: EsState<B>,
_rng: &mut dyn Rng,
) -> (EsState<B>, StrategyMetrics)
fn tell( &self, params: &EsConfig, offspring: Tensor<B, 2>, fitness: Tensor<B, 1>, state: EsState<B>, _rng: &mut dyn Rng, ) -> (EsState<B>, StrategyMetrics)
Applies variant-specific selection and σ adaptation, then returns the updated state and a per-generation metrics snapshot.
Variant behaviour:
(1+1): greedy replacement; σ updated by Rechenberg’s 1/5th success rule every10·Dsteps.(1+λ): best offspring replaces the parent only if it strictly improves fitness; σ is carried over unchanged.(μ,λ): selects the μ best offspring; parent pool discarded. Survivor σ values are gathered by the same truncation indices.(μ+λ): selects the μ best of the combined parent + offspring pool. Survivor σ values are drawn from the concatenated σ vector by the same indices.
The first tell after init bootstraps parent_fitness from the
initial-population evaluation rather than running selection.
Auto Trait Implementations§
impl<B> Freeze for EvolutionStrategy<B>
impl<B> RefUnwindSafe for EvolutionStrategy<B>
impl<B> Send for EvolutionStrategy<B>
impl<B> Sync for EvolutionStrategy<B>
impl<B> Unpin for EvolutionStrategy<B>
impl<B> UnsafeUnpin for EvolutionStrategy<B>
impl<B> UnwindSafe for EvolutionStrategy<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