Struct genetic_algorithm::chromosome::Chromosome
source · pub struct Chromosome<G: Genotype> {
pub genes: G::Genes,
pub fitness_score: Option<FitnessValue>,
pub age: usize,
pub reference_id: usize,
}Expand description
The Chromosome is used as an individual in the Population. It holds the genes and knows how to sort between itself with regard to it’s fitness score. Chromosomes crossover, mutate and compete with each other in the Evolve strategy
Fields§
§genes: G::Genes§fitness_score: Option<FitnessValue>§age: usize§reference_id: usizeUser controlled alternative to genes_key(), set manually in
custom Fitness implementation. Defaults to 0
Implementations§
source§impl<G: Genotype> Chromosome<G>
impl<G: Genotype> Chromosome<G>
Cannot Hash floats
source§impl<G: Genotype> Chromosome<G>
impl<G: Genotype> Chromosome<G>
pub fn new(genes: G::Genes) -> Self
sourcepub fn taint_fitness_score(&mut self)
pub fn taint_fitness_score(&mut self)
Reset fitness_score for recalculation
Trait Implementations§
source§impl<G: Clone + Genotype> Clone for Chromosome<G>
impl<G: Clone + Genotype> Clone for Chromosome<G>
source§fn clone(&self) -> Chromosome<G>
fn clone(&self) -> Chromosome<G>
Returns a copy 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<G: Genotype> Display for Chromosome<G>
impl<G: Genotype> Display for Chromosome<G>
source§impl<G: Genotype> Ord for Chromosome<G>
impl<G: Genotype> Ord for Chromosome<G>
source§impl<G: Genotype> PartialEq for Chromosome<G>
impl<G: Genotype> PartialEq for Chromosome<G>
source§impl<G: Genotype> PartialOrd for Chromosome<G>
impl<G: Genotype> PartialOrd for Chromosome<G>
impl<G: Genotype> Eq for Chromosome<G>
Auto Trait Implementations§
impl<G> Freeze for Chromosome<G>
impl<G> RefUnwindSafe for Chromosome<G>
impl<G> Send for Chromosome<G>
impl<G> Sync for Chromosome<G>
impl<G> Unpin for Chromosome<G>
impl<G> UnwindSafe for Chromosome<G>
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)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