solverforge_solver/termination/
move_count.rs1use std::fmt::Debug;
4use std::marker::PhantomData;
5
6use solverforge_core::domain::PlanningSolution;
7use solverforge_scoring::ScoreDirector;
8
9use super::Termination;
10use crate::scope::SolverScope;
11
12#[derive(Clone)]
33pub struct MoveCountTermination<S: PlanningSolution> {
34 limit: u64,
35 _phantom: PhantomData<fn() -> S>,
36}
37
38impl<S: PlanningSolution> Debug for MoveCountTermination<S> {
39 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
40 f.debug_struct("MoveCountTermination")
41 .field("limit", &self.limit)
42 .finish()
43 }
44}
45
46impl<S: PlanningSolution> MoveCountTermination<S> {
47 pub fn new(limit: u64) -> Self {
52 Self {
53 limit,
54 _phantom: PhantomData,
55 }
56 }
57}
58
59impl<S: PlanningSolution, D: ScoreDirector<S>> Termination<S, D> for MoveCountTermination<S> {
60 fn is_terminated(&self, solver_scope: &SolverScope<'_, S, D>) -> bool {
61 solver_scope.stats().moves_evaluated >= self.limit
62 }
63}