Trait Problem

Source
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.

Required Methods§

Source

fn encode(&self) -> Genotype<C>

Source

fn decode(&self, genotype: &Genotype<C>) -> T

Source

fn eval(&self, individual: &Genotype<C>) -> Score

Provided Methods§

Source

fn eval_batch(&self, individuals: &[Genotype<C>]) -> Vec<Score>

Implementors§

Source§

impl<C: Chromosome, T> Problem<C, T> for EngineProblem<C, T>