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
use super::{
super::utilities::{parameters::Parameters, Solution},
team::Team,
};
#[derive(Clone, Debug)]
pub struct Cohort<T> {
parameters: Parameters,
team_list: Vec<Team<T>>,
}
impl<T: Clone + Solution<T>> Cohort<T> {
pub fn new(parameters: Parameters) -> Cohort<T> {
let teams = vec![Team::new(parameters.clone()); parameters.number_of_teams];
Cohort {
parameters,
team_list: teams,
}
}
pub fn solve(&mut self) {
for i in 0..self.parameters.number_of_teams {
self.team_list[i].solve();
}
}
pub fn iterate(&mut self) {
for i in 0..self.parameters.number_of_teams {
self.team_list[i].iterate();
}
}
pub fn get_best_solution(&mut self) -> f64 {
let mut best_solution = self.team_list[0].pull_best_solution();
for i in 1..self.team_list.len() {
if best_solution > self.team_list[i].pull_best_solution() {
best_solution = self.team_list[i].pull_best_solution();
}
}
best_solution.get_quality_scalar()
}
}