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