1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
mod elitism;
pub use self::elitism::DominanceOrder;
pub use self::elitism::DominanceOrdered;
pub use self::elitism::Elitism;
pub use self::elitism::Shuffled;
mod greedy;
pub use self::greedy::Greedy;
mod rosomaxa;
pub use self::rosomaxa::Rosomaxa;
pub use self::rosomaxa::RosomaxaConfig;
pub use self::rosomaxa::RosomaxaWeighted;
use crate::prelude::*;
use std::cmp::Ordering;
use std::fmt::Display;
#[derive(Debug, PartialEq, Eq, Hash)]
pub enum SelectionPhase {
Initial,
Exploration,
Exploitation,
}
pub trait HeuristicPopulation: Display + Send + Sync {
type Objective: HeuristicObjective;
type Individual: HeuristicSolution;
fn add_all(&mut self, individuals: Vec<Self::Individual>) -> bool;
fn add(&mut self, individual: Self::Individual) -> bool;
fn on_generation(&mut self, statistics: &HeuristicStatistics);
fn cmp(&self, a: &Self::Individual, b: &Self::Individual) -> Ordering;
fn select<'a>(&'a self) -> Box<dyn Iterator<Item = &Self::Individual> + 'a>;
fn ranked<'a>(&'a self) -> Box<dyn Iterator<Item = (&Self::Individual, usize)> + 'a>;
fn all<'a>(&'a self) -> Box<dyn Iterator<Item = &Self::Individual> + 'a>;
fn size(&self) -> usize;
fn selection_phase(&self) -> SelectionPhase;
}