pub struct Phenotype<C>where
C: Chromosome,{ /* private fields */ }Expand description
A Phenotype is a representation of an individual in the population. It contains:
Genotype- the genetic representation of the individualScore- the score (fitness) of the individual as calculated by the fitness functionGeneration- the generation in which the individual was createdid- a unique identifier for the Phenotype
The Phenotype is a wrapper around the Genotype that adds additional information about the individual. In traditional (biological) genetics, a phenotype is “the set of observable characteristics of an individual resulting from the interaction of its genotype with the environment”. As such, the Phenotype is the ‘observable’ part of the individual (Genotype) that is being evolved by the genetic algorithm, hence the Score and generation fields. This allows the Phenotype to be sorted and compared based on the fitness (Score) of the individual (Genotype)
§Type Parameters
C: The type of chromosome used in the genotype, which must implement theChromosometrait.
Implementations§
Source§impl<C> Phenotype<C>where
C: Chromosome,
impl<C> Phenotype<C>where
C: Chromosome,
pub fn genotype(&self) -> &Genotype<C>
pub fn genotype_mut(&mut self) -> &mut Genotype<C>
pub fn take_genotype(&mut self) -> Result<Genotype<C>, RadiateError>
pub fn set_genotype(&mut self, genotype: Genotype<C>)
pub fn set_score(&mut self, score: Option<Score>)
pub fn generation(&self) -> usize
pub fn score(&self) -> Option<&Score>
pub fn id(&self) -> PhenotypeId
pub fn family(&self) -> FamilyId
pub fn invalidate(&mut self, generation: usize)
Trait Implementations§
Source§impl<C> AsRef<[f32]> for Phenotype<C>where
C: Chromosome,
Implement the AsRef<[f32]> trait for the Phenotype. This allows the Phenotype to be converted to a slice of f32
which will be the Score of the Phenotype. This is used when adding a Phenotype to a pareto Front for sorting.
impl<C> AsRef<[f32]> for Phenotype<C>where
C: Chromosome,
Implement the AsRef<[f32]> trait for the Phenotype. This allows the Phenotype to be converted to a slice of f32
which will be the Score of the Phenotype. This is used when adding a Phenotype to a pareto Front for sorting.
Source§impl<C> Distance<Phenotype<C>> for DistanceDiversityAdapter<C>where
C: Chromosome,
impl<C> Distance<Phenotype<C>> for DistanceDiversityAdapter<C>where
C: Chromosome,
Source§impl<C> From<(Vec<C>, usize)> for Phenotype<C>where
C: Chromosome,
This is a convenience method that allows you to create a Phenotype from a list of Chromosomes.
Without it, we end up needing to create a list of Gene’s
then a list of Chromosomes then a Genotype, it’s just a lot.
This method allows you to create a Phenotype from a list of chromosomes directly.
impl<C> From<(Vec<C>, usize)> for Phenotype<C>where
C: Chromosome,
This is a convenience method that allows you to create a Phenotype from a list of Chromosomes. Without it, we end up needing to create a list of Gene’s then a list of Chromosomes then a Genotype, it’s just a lot. This method allows you to create a Phenotype from a list of chromosomes directly.
Source§impl<C> FromIterator<Phenotype<C>> for Population<C>where
C: Chromosome,
impl<C> FromIterator<Phenotype<C>> for Population<C>where
C: Chromosome,
Source§fn from_iter<I>(iter: I) -> Population<C>where
I: IntoIterator<Item = Phenotype<C>>,
fn from_iter<I>(iter: I) -> Population<C>where
I: IntoIterator<Item = Phenotype<C>>,
Source§impl<C> Hash for Phenotype<C>where
C: Chromosome,
impl<C> Hash for Phenotype<C>where
C: Chromosome,
Source§impl<C> PartialOrd for Phenotype<C>where
C: Chromosome + PartialEq,
impl<C> PartialOrd for Phenotype<C>where
C: Chromosome + PartialEq,
Source§impl<C> Valid for Phenotype<C>where
C: Chromosome,
Implement the Valid trait for the Phenotype. This allows the Phenotype to be checked for validity.
A Phenotype is valid if the Genotype is valid. The GeneticEngine checks the validity of the Phenotype
and will remove any invalid individuals from the population, replacing them with new individuals at the given generation.
impl<C> Valid for Phenotype<C>where
C: Chromosome,
Implement the Valid trait for the Phenotype. This allows the Phenotype to be checked for validity.
A Phenotype is valid if the Genotype is valid. The GeneticEngine checks the validity of the Phenotype
and will remove any invalid individuals from the population, replacing them with new individuals at the given generation.
impl<C> Eq for Phenotype<C>where
C: Chromosome + PartialEq,
impl<C> StructuralPartialEq for Phenotype<C>where
C: Chromosome,
Auto Trait Implementations§
impl<C> Freeze for Phenotype<C>
impl<C> RefUnwindSafe for Phenotype<C>where
C: RefUnwindSafe,
impl<C> Send for Phenotype<C>
impl<C> Sync for Phenotype<C>
impl<C> Unpin for Phenotype<C>where
C: Unpin,
impl<C> UnsafeUnpin for Phenotype<C>
impl<C> UnwindSafe for Phenotype<C>where
C: 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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.