[−][src]Trait oxigen::genotype::Genotype
This trait defines an individual of a population in the genetic algorithm. It defines the fitness and mutation functions and the type of the individual representation.
Associated Types
type ProblemSize: Default + Send + Sync
The type that represents the problem size of the genotype. For example,
in the N Queens problem the size of the ProblemSize
is a numeric type
(the number of queens).
Required methods
fn iter(&self) -> Iter<T>
Returns an iterator over the genes of the individual.
fn into_iter(self) -> IntoIter<T>
Consumes the individual into an iterator over its genes.
fn generate(size: &Self::ProblemSize) -> Self
Randomly initiailzes an individual.
fn fitness(&self) -> f64
Returns a fitness value for an individual.
fn mutate(&mut self, rgen: &mut SmallRng, index: usize)
Defines the manner in which an individual is mutated when an elemennt of the individual is selected to mutate.
fn is_solution(&self, fitness: f64) -> bool
Defines if an individual is a valid solution to the problem.
Provided methods
fn fix(&mut self)
Fix the individual to satisfy the problem restrictions. The default implementation is to remain the individual unmodified always.