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 {
31 let step_index = phase_scope.step_count();
32 Self {
33 phase_scope,
34 step_index,
35 step_score: None,
36 }
37 }
38
39 pub fn step_index(&self) -> u64 {
40 self.step_index
41 }
42
43 pub fn step_score(&self) -> Option<&S::Score> {
44 self.step_score.as_ref()
45 }
46
47 pub fn set_step_score(&mut self, score: S::Score) {
48 self.step_score = Some(score);
49 }
50
51 pub fn complete(&mut self) {
53 self.phase_scope.increment_step_count();
54 }
55
56 pub fn phase_scope(&self) -> &PhaseScope<'t, 'b, S, D, BestCb> {
57 self.phase_scope
58 }
59
60 pub fn phase_scope_mut(&mut self) -> &mut PhaseScope<'t, 'b, S, D, BestCb> {
61 self.phase_scope
62 }
63
64 pub fn score_director(&self) -> &D {
65 self.phase_scope.score_director()
66 }
67
68 pub fn score_director_mut(&mut self) -> &mut D {
69 self.phase_scope.score_director_mut()
70 }
71
72 pub fn calculate_score(&mut self) -> S::Score {
74 self.phase_scope.calculate_score()
75 }
76}