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.
10///
11pub trait Select<C: Chromosome>: Send + Sync {
12 fn name(&self) -> &'static str {
13 std::any::type_name::<Self>()
14 .split("<")
15 .next()
16 .unwrap_or(std::any::type_name::<Self>())
17 .split("::")
18 .last()
19 .unwrap_or("Unknown Selector")
20 }
21
22 fn select(
23 &self,
24 population: &Population<C>,
25 optimize: &Objective,
26 count: usize,
27 ) -> Population<C>;
28}