pub struct CartesianGeneticProgramming<B: Backend> { /* private fields */ }Expand description
Classical Cartesian GP with (1 + λ) ES.
§Example
use burn::backend::Flex;
use rlevo_evolution::algorithms::gp_cgp::{CartesianGeneticProgramming, CgpConfig};
let strategy = CartesianGeneticProgramming::<Flex>::new();
let params = CgpConfig::default_for(1);
assert!(params.genome_len() > 0);
let _ = strategy;Implementations§
Trait Implementations§
Source§impl<B: Clone + Backend> Clone for CartesianGeneticProgramming<B>
impl<B: Clone + Backend> Clone for CartesianGeneticProgramming<B>
Source§fn clone(&self) -> CartesianGeneticProgramming<B>
fn clone(&self) -> CartesianGeneticProgramming<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 CartesianGeneticProgramming<B>
Source§impl<B: Default + Backend> Default for CartesianGeneticProgramming<B>
impl<B: Default + Backend> Default for CartesianGeneticProgramming<B>
Source§fn default() -> CartesianGeneticProgramming<B>
fn default() -> CartesianGeneticProgramming<B>
Source§impl<B: Backend> Strategy<B> for CartesianGeneticProgramming<B>
impl<B: Backend> Strategy<B> for CartesianGeneticProgramming<B>
Source§fn init(
&self,
params: &CgpConfig,
rng: &mut dyn Rng,
device: &<B as BackendTypes>::Device,
) -> CgpState<B>
fn init( &self, params: &CgpConfig, rng: &mut dyn Rng, device: &<B as BackendTypes>::Device, ) -> CgpState<B>
Samples the initial parent genome by drawing random node functions and
feed-forward input connections via rng, then uploads the genotype as
a (1, genome_len) integer tensor.
Source§fn ask(
&self,
params: &CgpConfig,
state: &CgpState<B>,
rng: &mut dyn Rng,
device: &<B as BackendTypes>::Device,
) -> (Tensor<B, 2, Int>, CgpState<B>)
fn ask( &self, params: &CgpConfig, state: &CgpState<B>, rng: &mut dyn Rng, device: &<B as BackendTypes>::Device, ) -> (Tensor<B, 2, Int>, CgpState<B>)
Returns the offspring population for the current generation.
On the first call (parent fitness not yet set), returns the single
parent genome unchanged for initial fitness evaluation.
On subsequent calls, produces params.lambda children by cloning the
parent and applying per-gene point mutation, with mutation draws taken
from a deterministic seed_stream (host-RNG convention).
Source§fn tell(
&self,
_params: &CgpConfig,
offspring: Tensor<B, 2, Int>,
fitness: Tensor<B, 1>,
state: CgpState<B>,
_rng: &mut dyn Rng,
) -> (CgpState<B>, StrategyMetrics)
fn tell( &self, _params: &CgpConfig, offspring: Tensor<B, 2, Int>, fitness: Tensor<B, 1>, state: CgpState<B>, _rng: &mut dyn Rng, ) -> (CgpState<B>, StrategyMetrics)
Applies (1+λ) selection and returns the updated state.
The canonical CGP tie-breaking rule is used: an offspring replaces the parent when its fitness is less than or equal to the parent’s, allowing neutral mutations to accumulate and maintain genetic diversity in the inactive (non-coding) portion of the genome.
The first tell after init bootstraps the parent fitness from the
initial single-genome evaluation rather than running selection.
Auto Trait Implementations§
impl<B> Freeze for CartesianGeneticProgramming<B>
impl<B> RefUnwindSafe for CartesianGeneticProgramming<B>
impl<B> Send for CartesianGeneticProgramming<B>
impl<B> Sync for CartesianGeneticProgramming<B>
impl<B> Unpin for CartesianGeneticProgramming<B>
impl<B> UnsafeUnpin for CartesianGeneticProgramming<B>
impl<B> UnwindSafe for CartesianGeneticProgramming<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