pub struct GepStrategy<B: Backend, F: FunctionSet> { /* private fields */ }Expand description
Gene Expression Programming as a generational Strategy.
The genome is a Tensor<B, 2, Int> of shape (pop_size, head_len + tail_len). Selection is roulette-wheel (fitness-proportionate) with
elitism, following Ferreira (2001): the best-so-far individual is copied
unchanged into every new generation, while the rest are produced by
roulette selection followed by crossover, transposition, and locus-class
point mutation. All randomness is host-side via
seed_stream; each operator draws from its own
SeedPurpose stream.
Decoding and phenotype evaluation are not part of the strategy — they
live in the BatchFitnessFn (see GepSymRegression), keeping the
ask/tell loop free of program interpretation.
Implementations§
Trait Implementations§
Source§impl<B: Clone + Backend, F: Clone + FunctionSet> Clone for GepStrategy<B, F>
impl<B: Clone + Backend, F: Clone + FunctionSet> Clone for GepStrategy<B, F>
Source§fn clone(&self) -> GepStrategy<B, F>
fn clone(&self) -> GepStrategy<B, F>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<B: Debug + Backend, F: Debug + FunctionSet> Debug for GepStrategy<B, F>
impl<B: Debug + Backend, F: Debug + FunctionSet> Debug for GepStrategy<B, F>
Source§impl<B: Backend, F: FunctionSet> Strategy<B> for GepStrategy<B, F>
impl<B: Backend, F: FunctionSet> Strategy<B> for GepStrategy<B, F>
Source§fn init(
&self,
params: &GepConfig,
rng: &mut dyn Rng,
device: &<B as BackendTypes>::Device,
) -> GepState<B>
fn init( &self, params: &GepConfig, rng: &mut dyn Rng, device: &<B as BackendTypes>::Device, ) -> GepState<B>
Samples the initial population: each chromosome’s head loci hold any symbol and its tail loci hold terminals, so every individual is valid by construction.
Source§fn ask(
&self,
params: &GepConfig,
state: &GepState<B>,
rng: &mut dyn Rng,
device: &<B as BackendTypes>::Device,
) -> (Tensor<B, 2, Int>, GepState<B>)
fn ask( &self, params: &GepConfig, state: &GepState<B>, rng: &mut dyn Rng, device: &<B as BackendTypes>::Device, ) -> (Tensor<B, 2, Int>, GepState<B>)
Returns the population to evaluate this generation.
On the first call (no fitness cached yet) the initial population is
returned unchanged. On subsequent calls a new generation is bred from
the current one: roulette selection, then one-/two-point crossover,
IS/RIS transposition, and locus-class point mutation, with the
best-so-far individual copied into row 0 (elitism). Each operator draws
from its own SeedPurpose stream off a single base seed.
Source§fn tell(
&self,
_params: &GepConfig,
population: Tensor<B, 2, Int>,
fitness: Tensor<B, 1>,
state: GepState<B>,
_rng: &mut dyn Rng,
) -> (GepState<B>, StrategyMetrics)
fn tell( &self, _params: &GepConfig, population: Tensor<B, 2, Int>, fitness: Tensor<B, 1>, state: GepState<B>, _rng: &mut dyn Rng, ) -> (GepState<B>, StrategyMetrics)
Caches the evaluated population and its fitness, then updates the
best-so-far record. The returned population becomes the current
generation that the next ask breeds from.
Auto Trait Implementations§
impl<B, F> Freeze for GepStrategy<B, F>where
F: Freeze,
impl<B, F> RefUnwindSafe for GepStrategy<B, F>where
F: RefUnwindSafe,
impl<B, F> Send for GepStrategy<B, F>
impl<B, F> Sync for GepStrategy<B, F>
impl<B, F> Unpin for GepStrategy<B, F>where
F: Unpin,
impl<B, F> UnsafeUnpin for GepStrategy<B, F>where
F: UnsafeUnpin,
impl<B, F> UnwindSafe for GepStrategy<B, F>where
F: 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