pub trait Problem<C: Chromosome, T>: Send + Sync {
// Required methods
fn encode(&self) -> Genotype<C>;
fn decode(&self, genotype: &Genotype<C>) -> T;
fn eval(&self, individual: &Genotype<C>) -> Score;
// Provided method
fn eval_batch(&self, individuals: &[Genotype<C>]) -> Vec<Score> { ... }
}
Expand description
Problem represents the interface for the fitness function or evaluation and encoding/decoding of a genotype to a phenotype within the genetic algorithm framework.
To run the genetic algorithm the three things that must be supplied are the encoding & decoding of the Genotype and the fitness function. Problem wraps all three into a single trait that can be supplied to the engine builder.