solverforge_solver/phase/
mod.rs1pub mod construction;
11pub mod exhaustive;
12pub mod localsearch;
13pub mod partitioned;
14pub mod vnd;
15
16use std::fmt::Debug;
17
18use solverforge_core::domain::PlanningSolution;
19use solverforge_scoring::ScoreDirector;
20
21use crate::scope::SolverScope;
22
23pub trait Phase<S: PlanningSolution, D: ScoreDirector<S>>: Send + Debug {
32 fn solve(&mut self, solver_scope: &mut SolverScope<'_, S, D>);
37
38 fn phase_type_name(&self) -> &'static str;
40}
41
42impl<S: PlanningSolution, D: ScoreDirector<S>> Phase<S, D> for () {
44 fn solve(&mut self, _solver_scope: &mut SolverScope<'_, S, D>) {
45 }
47
48 fn phase_type_name(&self) -> &'static str {
49 "NoOp"
50 }
51}
52
53impl<S, D, P1> Phase<S, D> for ((), P1)
55where
56 S: PlanningSolution,
57 D: ScoreDirector<S>,
58 P1: Phase<S, D>,
59{
60 fn solve(&mut self, solver_scope: &mut SolverScope<'_, S, D>) {
61 self.1.solve(solver_scope);
62 }
63
64 fn phase_type_name(&self) -> &'static str {
65 self.1.phase_type_name()
66 }
67}
68
69impl<S, D, P1, P2> Phase<S, D> for (((), P1), P2)
71where
72 S: PlanningSolution,
73 D: ScoreDirector<S>,
74 P1: Phase<S, D>,
75 P2: Phase<S, D>,
76{
77 fn solve(&mut self, solver_scope: &mut SolverScope<'_, S, D>) {
78 (self.0).1.solve(solver_scope);
79 self.1.solve(solver_scope);
80 }
81
82 fn phase_type_name(&self) -> &'static str {
83 "PhaseTuple"
84 }
85}
86
87impl<S, D, P1, P2, P3> Phase<S, D> for ((((), P1), P2), P3)
89where
90 S: PlanningSolution,
91 D: ScoreDirector<S>,
92 P1: Phase<S, D>,
93 P2: Phase<S, D>,
94 P3: Phase<S, D>,
95{
96 fn solve(&mut self, solver_scope: &mut SolverScope<'_, S, D>) {
97 ((self.0).0).1.solve(solver_scope);
98 (self.0).1.solve(solver_scope);
99 self.1.solve(solver_scope);
100 }
101
102 fn phase_type_name(&self) -> &'static str {
103 "PhaseTuple"
104 }
105}
106
107impl<S, D, P1, P2, P3, P4> Phase<S, D> for (((((), P1), P2), P3), P4)
109where
110 S: PlanningSolution,
111 D: ScoreDirector<S>,
112 P1: Phase<S, D>,
113 P2: Phase<S, D>,
114 P3: Phase<S, D>,
115 P4: Phase<S, D>,
116{
117 fn solve(&mut self, solver_scope: &mut SolverScope<'_, S, D>) {
118 (((self.0).0).0).1.solve(solver_scope);
119 ((self.0).0).1.solve(solver_scope);
120 (self.0).1.solve(solver_scope);
121 self.1.solve(solver_scope);
122 }
123
124 fn phase_type_name(&self) -> &'static str {
125 "PhaseTuple"
126 }
127}