1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use crate::refinement::{Individuum, RefinementContext};
pub trait Termination {
fn is_termination(&self, refinement_ctx: &mut RefinementContext, solution: (&Individuum, bool)) -> bool;
}
mod goal_satisfaction;
pub use self::goal_satisfaction::GoalSatisfaction;
mod max_generation;
pub use self::max_generation::MaxGeneration;
mod quota_reached;
pub use self::quota_reached::QuotaReached;
pub struct CompositeTermination {
terminations: Vec<Box<dyn Termination>>,
}
impl CompositeTermination {
pub fn new(terminations: Vec<Box<dyn Termination>>) -> Self {
Self { terminations }
}
}
impl Default for CompositeTermination {
fn default() -> Self {
Self::new(vec![Box::new(MaxGeneration::default())])
}
}
impl Termination for CompositeTermination {
fn is_termination(&self, refinement_ctx: &mut RefinementContext, solution: (&Individuum, bool)) -> bool {
self.terminations.iter().any(|t| t.is_termination(refinement_ctx, solution))
}
}