Trait genetic_algorithm::genotype::Genotype
source · [−]pub trait Genotype: Clone + Send + Debug + Display + TryFrom<GenotypeBuilder<Self>> {
type Allele: Clone + Send + Debug;
fn genes_size(&self) -> usize;
fn chromosome_factory<R: Rng>(&self, rng: &mut R) -> Chromosome<Self>;
fn mutate_chromosome_random<R: Rng>(
&self,
chromosome: &mut Chromosome<Self>,
rng: &mut R
);
fn crossover_points(&self) -> Vec<usize> { ... }
fn crossover_indexes(&self) -> Vec<usize> { ... }
fn builder() -> GenotypeBuilder<Self> { ... }
}Expand description
Standard genotype, suitable for Evolve. Each implemented genotype handles its own random genes initialization and mutation.
Required Associated Types
Required Methods
fn genes_size(&self) -> usize
fn chromosome_factory<R: Rng>(&self, rng: &mut R) -> Chromosome<Self>
fn chromosome_factory<R: Rng>(&self, rng: &mut R) -> Chromosome<Self>
a random chromosome factory to seed the initial population for Evolve
fn mutate_chromosome_random<R: Rng>(
&self,
chromosome: &mut Chromosome<Self>,
rng: &mut R
)
fn mutate_chromosome_random<R: Rng>(
&self,
chromosome: &mut Chromosome<Self>,
rng: &mut R
)
a random mutation of the chromosome
Provided Methods
fn crossover_points(&self) -> Vec<usize>
fn crossover_points(&self) -> Vec<usize>
to guard against invalid crossover strategies which break the internal consistency of the genes, unique genotypes can’t simply exchange genes without gene duplication issues
fn crossover_indexes(&self) -> Vec<usize>
fn crossover_indexes(&self) -> Vec<usize>
to guard against invalid crossover strategies which break the internal consistency of the genes, unique genotypes can’t simply exchange genes without gene duplication issues