pub struct EvolutionaryProgramming<B: Backend> { /* private fields */ }Expand description
Classical Fogel EP.
§Example
use burn::backend::Flex;
use rlevo_evolution::algorithms::ep::{EpConfig, EvolutionaryProgramming};
let strategy = EvolutionaryProgramming::<Flex>::new();
let params = EpConfig::default_for(30, 10);
let _ = (strategy, params);Implementations§
Trait Implementations§
Source§impl<B: Clone + Backend> Clone for EvolutionaryProgramming<B>
impl<B: Clone + Backend> Clone for EvolutionaryProgramming<B>
Source§fn clone(&self) -> EvolutionaryProgramming<B>
fn clone(&self) -> EvolutionaryProgramming<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 EvolutionaryProgramming<B>
Source§impl<B: Default + Backend> Default for EvolutionaryProgramming<B>
impl<B: Default + Backend> Default for EvolutionaryProgramming<B>
Source§fn default() -> EvolutionaryProgramming<B>
fn default() -> EvolutionaryProgramming<B>
Source§impl<B: Backend> Strategy<B> for EvolutionaryProgramming<B>
impl<B: Backend> Strategy<B> for EvolutionaryProgramming<B>
Source§fn init(
&self,
params: &EpConfig,
rng: &mut dyn Rng,
device: &<B as BackendTypes>::Device,
) -> EpState<B>
fn init( &self, params: &EpConfig, rng: &mut dyn Rng, device: &<B as BackendTypes>::Device, ) -> EpState<B>
Samples the initial parent population uniformly within
params.bounds, initializes per-parent σ to
params.initial_sigma, and returns an EpState with an empty
fitness cache.
Initial sampling goes through seed_stream rather than
B::seed + Tensor::random to keep results reproducible across
parallel test threads.
Source§fn ask(
&self,
params: &EpConfig,
state: &EpState<B>,
rng: &mut dyn Rng,
device: &<B as BackendTypes>::Device,
) -> (Tensor<B, 2>, EpState<B>)
fn ask( &self, params: &EpConfig, state: &EpState<B>, rng: &mut dyn Rng, device: &<B as BackendTypes>::Device, ) -> (Tensor<B, 2>, EpState<B>)
Proposes the offspring population for this generation.
First call (fitness cache empty): returns the initial parents unchanged so the caller can evaluate them before any mutation step.
Subsequent calls:
- Applies the log-normal σ update to each parent:
σ'_i = σ_i · exp(τ · N(0, 1)), host-sampled viaseed_streamwithSeedPurpose::Other. - Mutates each parent by its updated σ using
gaussian_mutation_per_row, host-sampled viaseed_streamwithSeedPurpose::Mutation. - Clamps offspring to
params.bounds. - Appends the offspring σ values to
state.sigmas, making it length2μsoStrategy::tellcan select over the combined pool without re-deriving them.
Returns the offspring tensor and the updated state.
Source§fn tell(
&self,
params: &EpConfig,
offspring: Tensor<B, 2>,
fitness: Tensor<B, 1>,
state: EpState<B>,
rng: &mut dyn Rng,
) -> (EpState<B>, StrategyMetrics)
fn tell( &self, params: &EpConfig, offspring: Tensor<B, 2>, fitness: Tensor<B, 1>, state: EpState<B>, rng: &mut dyn Rng, ) -> (EpState<B>, StrategyMetrics)
Consumes the evaluated offspring and advances the state.
First call (fitness cache empty): stores the initial parent
fitness, initializes best_genome/best_fitness, resets σ to
params.initial_sigma, and increments the generation counter.
Subsequent calls:
- Builds the
(μ + μ)combined pool of parents and offspring (and their2μσ values fromStrategy::ask). - Runs q-tournament selection: each of the
2μmembers playsparams.tournament_qrandom opponents; the member wins a bout if its fitness is strictly higher. The μ members with the most wins survive; ties are broken by fitness (higher wins). Tournament indices are host-sampled viaseed_streamwithSeedPurpose::Selection. - Updates
best_genome/best_fitnessfrom the offspring fitness if improved.
Returns the updated EpState and a StrategyMetrics snapshot
covering the current offspring generation’s fitness distribution.
Auto Trait Implementations§
impl<B> Freeze for EvolutionaryProgramming<B>
impl<B> RefUnwindSafe for EvolutionaryProgramming<B>
impl<B> Send for EvolutionaryProgramming<B>
impl<B> Sync for EvolutionaryProgramming<B>
impl<B> Unpin for EvolutionaryProgramming<B>
impl<B> UnsafeUnpin for EvolutionaryProgramming<B>
impl<B> UnwindSafe for EvolutionaryProgramming<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