1 #ifndef __CONDITION_CONDITION_H
2 #define __CONDITION_CONDITION_H
4 #include "chromosome.h"
5 #include "generation.h"
9 * Base Condition class.
10 * It is used for checking if algorithm should stop.
12 template < typename _Chromosome>
16 * Check calculations for current generation if it passes stop condition
17 * If condition is satisfied, we can check another generation.
18 * All the custom Condition checks should be invoked in this method.
20 * @param generation reference of current generation to check
22 * @return true if condition is satisfied and another generation can checked;
23 * false if condition is not satisfied and algorithm should stop.
25 virtual bool do_check(const Generation<_Chromosome>&) = 0;
29 * Checks if current generation passes stop condition.
30 * If condition is satisfied, we can check another generation.
32 * @param generation reference of current generation to check
34 * @return true if condition is satisfied and another generation can checked;
35 * false if condition is not satisfied and algorithm should stop.
37 bool check(const Generation<_Chromosome>& generation) {
38 return do_check(generation);
43 #endif /* __CONDITION_CONDITION_H */