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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! Termination determines when to stop the process of the genetic algorithm.
//! Common termination conditions are:
//!
//! * A solution is found that satisfies minimum criteria
//! * A fixed number of generations is reached
//! * An allocated budget (computation time/money) is reached
//! * The highest ranking solution's fitness is reaching or has reached a
//! plateau such that successive iterations no longer produce better results
//! * ...or a combination of such termination conditions.
//!
//! Termination conditions are defined by implementing the `Termination` trait.
//! Each kind of termination condition should be implemented as a separate
//! type. Terminations conditions are combined using combinators such as
//! logical and and logical or.
//!
//! A combinator is a special `Termination` condition that combines two other
//! `Termination` conditions with a logical operation. The most important
//! combinators are provided in the `combinator` package.
//!
//! For convenience the provided combinators can be instantiated by using
//! the public functions `and` and `or` which are reexported by this module.
pub use ;
use crate::;
/// The `StopFlag` is the result of the `Termination` function. It tells
/// the simulation whether it shall stop or if it can continue.
///
/// If the `StopFlag` indicates that the simulation must stop, also the reason
/// (`StopReason`) must be specified.
/// A `StopReason` should explain to the user of the simulation why the
/// simulation has been stopped. Examples:
/// * "Simulation stopped after the maximum of 100 generations have been
/// processed"
/// * "Simulation stopped after a solution with a fitness value of 81 has
/// been found which is above the target fitness of 80.
pub type StopReason = String;
/// A `Termination` defines a condition when the `Simulation` shall stop.
///
/// One implementation of the trait `Termination` should only handle one
/// single termination condition. In the simulation multiple termination
/// conditions can be combined through `combinator`s.