solverforge_solver/scope/
step.rs1use solverforge_core::domain::PlanningSolution;
4use solverforge_scoring::Director;
5
6use super::solver::BestSolutionCallback;
7use super::PhaseScope;
8
9pub struct StepScope<'t, 'a, 'b, S: PlanningSolution, D: Director<S>, BestCb = ()> {
19 phase_scope: &'a mut PhaseScope<'t, 'b, S, D, BestCb>,
21 step_index: u64,
23 step_score: Option<S::Score>,
25}
26
27impl<'t, 'a, 'b, S: PlanningSolution, D: Director<S>, BestCb: BestSolutionCallback<S>>
28 StepScope<'t, 'a, 'b, S, D, BestCb>
29{
30 pub fn new(phase_scope: &'a mut PhaseScope<'t, 'b, S, D, BestCb>) -> Self {
32 let step_index = phase_scope.step_count();
33 Self {
34 phase_scope,
35 step_index,
36 step_score: None,
37 }
38 }
39
40 pub fn step_index(&self) -> u64 {
42 self.step_index
43 }
44
45 pub fn step_score(&self) -> Option<&S::Score> {
47 self.step_score.as_ref()
48 }
49
50 pub fn set_step_score(&mut self, score: S::Score) {
52 self.step_score = Some(score);
53 }
54
55 pub fn complete(&mut self) {
57 self.phase_scope.increment_step_count();
58 }
59
60 pub fn phase_scope(&self) -> &PhaseScope<'t, 'b, S, D, BestCb> {
62 self.phase_scope
63 }
64
65 pub fn phase_scope_mut(&mut self) -> &mut PhaseScope<'t, 'b, S, D, BestCb> {
67 self.phase_scope
68 }
69
70 pub fn score_director(&self) -> &D {
72 self.phase_scope.score_director()
73 }
74
75 pub fn score_director_mut(&mut self) -> &mut D {
77 self.phase_scope.score_director_mut()
78 }
79
80 pub fn calculate_score(&mut self) -> S::Score {
82 self.phase_scope.calculate_score()
83 }
84}