pub trait Valid {
// Provided method
fn is_valid(&self) -> bool { ... }
}Expand description
A Valid type is a type that can be checked for validity. This is used for checking if a gene
or a chromosome is valid. For example, a gene that represents a number between 0 and 1 can be checked
for validity by ensuring that the allele is between 0 and 1.
The GeneticEngine will check the validity of the Chromosome and Phenotype and remove any
invalid individuals from the population, replacing them with new individuals at the given generation.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Implementors§
impl Valid for BitChromosome
Every BitGene is valid, so the BitChromosome is also valid.
impl Valid for BitGene
Because a BitGene is either true or false it is always valid.
impl Valid for CharChromosome
impl Valid for CharGene
impl Valid for Rate
impl<A> Valid for PermutationChromosome<A>
impl<A> Valid for PermutationGene<A>
impl<C> Valid for Genotype<C>where
C: Chromosome,
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<F> Valid for FloatChromosome<F>where
F: Float,
impl<F> Valid for FloatGene<F>where
F: Float,
The is_valid method checks if the allele of the FloatGene is between the min and max values.
The GeneticEngine will check the validity of the Chromosome and Phenotype and remove any
invalid individuals from the population, replacing them with new individuals at the given generation.
impl<T> Valid for IntChromosome<T>where
T: Integer,
impl<T> Valid for IntGene<T>where
T: Integer,
Note: the bounds are used for crossover and mutation.