Skip to main content

EvolutionaryProgramming

Struct EvolutionaryProgramming 

Source
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§

Source§

impl<B: Backend> EvolutionaryProgramming<B>

Source

pub fn new() -> Self

Builds a new (stateless) strategy object.

Trait Implementations§

Source§

impl<B: Clone + Backend> Clone for EvolutionaryProgramming<B>

Source§

fn clone(&self) -> EvolutionaryProgramming<B>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<B: Copy + Backend> Copy for EvolutionaryProgramming<B>

Source§

impl<B: Debug + Backend> Debug for EvolutionaryProgramming<B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<B: Default + Backend> Default for EvolutionaryProgramming<B>

Source§

fn default() -> EvolutionaryProgramming<B>

Returns the “default value” for a type. Read more
Source§

impl<B: Backend> Strategy<B> for EvolutionaryProgramming<B>
where B::Device: Clone,

Source§

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>)

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:

  1. Applies the log-normal σ update to each parent: σ'_i = σ_i · exp(τ · N(0, 1)), host-sampled via seed_stream with SeedPurpose::Other.
  2. Mutates each parent by its updated σ using gaussian_mutation_per_row, host-sampled via seed_stream with SeedPurpose::Mutation.
  3. Clamps offspring to params.bounds.
  4. Appends the offspring σ values to state.sigmas, making it length so Strategy::tell can 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)

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:

  1. Builds the (μ + μ) combined pool of parents and offspring (and their σ values from Strategy::ask).
  2. Runs q-tournament selection: each of the members plays params.tournament_q random 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 via seed_stream with SeedPurpose::Selection.
  3. Updates best_genome/best_fitness from the offspring fitness if improved.

Returns the updated EpState and a StrategyMetrics snapshot covering the current offspring generation’s fitness distribution.

Source§

fn best(&self, state: &EpState<B>) -> Option<(Tensor<B, 2>, f32)>

Returns the best-so-far genome and its canonical (maximise) fitness.

Returns None before the first Strategy::tell call, when EpState::best_genome is still None.

Source§

type Params = EpConfig

Static parameters for a run.
Source§

type State = EpState<B>

Generation-to-generation state.
Source§

type Genome = Tensor<B, 2>

Genome container produced by ask.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Adaptor<()> for T

Source§

fn adapt(&self)

Adapt the type to be passed to a metric.
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<C> CloneExpand for C
where C: Clone,

Source§

fn __expand_clone_method(&self, _scope: &mut Scope) -> C

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoComptime for T

Source§

fn comptime(self) -> Self

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> TuneInputs for T
where T: Clone + Send + Sync + 'static,

Source§

type At<'a> = T

The concrete input type at lifetime 'a.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more