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
use super::*;
pub struct TotalUnassignedJobs {
unassigned_goal: Option<(f64, bool)>,
variation_goal: Option<VariationCoefficient>,
}
impl Default for TotalUnassignedJobs {
fn default() -> Self {
Self { unassigned_goal: None, variation_goal: None }
}
}
impl TotalUnassignedJobs {
pub fn new(desired_unassigned: Option<usize>, variation_goal: Option<(usize, f64)>) -> Self {
Self {
unassigned_goal: desired_unassigned.map(|unassigned| (unassigned as f64, true)),
variation_goal: variation_goal
.map(|(sample, threshold)| VariationCoefficient::new(sample, threshold, "unassigned_vc")),
}
}
}
impl Objective for TotalUnassignedJobs {
fn estimate_cost(&self, _: &mut RefinementContext, insertion_ctx: &InsertionContext) -> ObjectiveCostType {
Box::new(MeasurableObjectiveCost::new(insertion_ctx.solution.unassigned.len() as Cost))
}
fn is_goal_satisfied(
&self,
refinement_ctx: &mut RefinementContext,
insertion_ctx: &InsertionContext,
) -> Option<bool> {
let actual_unassigned = insertion_ctx.solution.unassigned.len() as f64;
check_value_variation_goals(refinement_ctx, actual_unassigned, &self.unassigned_goal, &self.variation_goal)
}
}