pub struct GeneticAlgorithm<B: Backend> { /* private fields */ }Expand description
Real-valued canonical Genetic Algorithm.
§Example
use burn::backend::NdArray;
use rlevo_evolution::algorithms::ga::{
GaConfig, GaCrossover, GaReplacement, GaSelection, GeneticAlgorithm,
};
let strategy = GeneticAlgorithm::<NdArray>::new();
let params = GaConfig {
pop_size: 64,
genome_dim: 10,
bounds: (-5.12, 5.12),
mutation_sigma: 0.3,
selection: GaSelection::Tournament { size: 2 },
crossover: GaCrossover::BlxAlpha { alpha: 0.5 },
replacement: GaReplacement::Elitist { elitism_k: 2 },
};
let _ = (strategy, params);Implementations§
Trait Implementations§
Source§impl<B: Clone + Backend> Clone for GeneticAlgorithm<B>
impl<B: Clone + Backend> Clone for GeneticAlgorithm<B>
Source§fn clone(&self) -> GeneticAlgorithm<B>
fn clone(&self) -> GeneticAlgorithm<B>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<B: Default + Backend> Default for GeneticAlgorithm<B>
impl<B: Default + Backend> Default for GeneticAlgorithm<B>
Source§fn default() -> GeneticAlgorithm<B>
fn default() -> GeneticAlgorithm<B>
Returns the “default value” for a type. Read more
Source§impl<B: Backend> Strategy<B> for GeneticAlgorithm<B>
impl<B: Backend> Strategy<B> for GeneticAlgorithm<B>
Source§fn init(
&self,
params: &GaConfig,
rng: &mut dyn Rng,
device: &B::Device,
) -> GaState<B>
fn init( &self, params: &GaConfig, rng: &mut dyn Rng, device: &B::Device, ) -> GaState<B>
Build the initial state. Read more
Source§fn ask(
&self,
params: &GaConfig,
state: &GaState<B>,
rng: &mut dyn Rng,
device: &B::Device,
) -> (Tensor<B, 2>, GaState<B>)
fn ask( &self, params: &GaConfig, state: &GaState<B>, rng: &mut dyn Rng, device: &B::Device, ) -> (Tensor<B, 2>, GaState<B>)
Propose the next population. Read more
impl<B: Copy + Backend> Copy for GeneticAlgorithm<B>
Auto Trait Implementations§
impl<B> Freeze for GeneticAlgorithm<B>
impl<B> RefUnwindSafe for GeneticAlgorithm<B>
impl<B> Send for GeneticAlgorithm<B>
impl<B> Sync for GeneticAlgorithm<B>
impl<B> Unpin for GeneticAlgorithm<B>
impl<B> UnsafeUnpin for GeneticAlgorithm<B>
impl<B> UnwindSafe for GeneticAlgorithm<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
Mutably borrows from an owned value. Read more
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>
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 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>
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