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
use super::*;
use crate::algorithms::nsga2::Objective;
pub struct TotalUnassignedJobs {}
impl Default for TotalUnassignedJobs {
fn default() -> Self {
Self {}
}
}
impl Objective for TotalUnassignedJobs {
type Solution = InsertionContext;
fn total_order(&self, a: &Self::Solution, b: &Self::Solution) -> Ordering {
let fitness_a = a.solution.unassigned.len();
let fitness_b = b.solution.unassigned.len();
fitness_a.cmp(&fitness_b)
}
fn distance(&self, a: &Self::Solution, b: &Self::Solution) -> f64 {
a.solution.unassigned.len() as f64 - b.solution.unassigned.len() as f64
}
fn fitness(&self, solution: &Self::Solution) -> f64 {
solution.solution.unassigned.len() as f64
}
}