radiate_core/
selector.rs

1use crate::Chromosome;
2use crate::genome::population::Population;
3use crate::objectives::Objective;
4
5/// A trait for selection algorithms. Selection algorithms are used to select
6/// individuals from a population to be used in the next generation. The
7/// selection process is (most of the time) based on the fitness of the individuals in the
8/// population. The selection process can be based on the fitness of the individuals
9/// in the population, or it can be based on the individuals themselves.
10pub trait Select<C: Chromosome>: Send + Sync {
11    fn name(&self) -> &'static str {
12        std::any::type_name::<Self>()
13            .split("<")
14            .next()
15            .unwrap_or(std::any::type_name::<Self>())
16            .split("::")
17            .last()
18            .unwrap_or("Unknown Selector")
19    }
20
21    fn select(
22        &self,
23        population: &Population<C>,
24        optimize: &Objective,
25        count: usize,
26    ) -> Population<C>;
27}