radiate-selectors 1.2.22

Selection strategies for the Radiate genetic algorithm library.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use radiate_core::{Chromosome, Objective, Population, Select};

#[derive(Debug, Default)]
pub struct EliteSelector;

impl EliteSelector {
    pub fn new() -> Self {
        EliteSelector
    }
}

impl<C: Chromosome + Clone> Select<C> for EliteSelector {
    fn select(&self, population: &Population<C>, _: &Objective, count: usize) -> Population<C> {
        population.iter().take(count).cloned().collect()
    }
}