pub mod prelude;
use crate::{
algorithm::EvaluatedPopulation,
genetic::{Children, Fitness, Genotype, Offspring, Parents},
random::Rng,
};
pub trait SingleObjective {}
pub trait MultiObjective {}
pub trait GeneticOperator: Clone {
fn name() -> String;
}
pub trait SelectionOp<G, F>: GeneticOperator
where
G: Genotype,
F: Fitness,
{
fn select_from<R>(
&self,
population: &EvaluatedPopulation<G, F>,
rng: &mut R,
) -> Vec<Parents<G>>
where
R: Rng + Sized;
}
pub trait CrossoverOp<G>: GeneticOperator
where
G: Genotype,
{
fn crossover<R>(&self, parents: Parents<G>, rng: &mut R) -> Children<G>
where
R: Rng + Sized;
}
pub trait MutationOp<G>: GeneticOperator
where
G: Genotype,
{
fn mutate<R>(&self, genome: G, rng: &mut R) -> G
where
R: Rng + Sized;
}
pub trait ReinsertionOp<G, F>: GeneticOperator
where
G: Genotype,
F: Fitness,
{
fn combine<R>(
&self,
offspring: &mut Offspring<G>,
population: &EvaluatedPopulation<G, F>,
rng: &mut R,
) -> Vec<G>
where
R: Rng + Sized;
}