1 #ifndef __ALGORITHM_CONDITION_H
2 #define __ALGORITHM_CONDITION_H
4 #include "chromosome.h"
5 #include "generation.h"
12 * It is used for checking if algorithm should stop.
14 * By default stops algorithm after 1000 of generations.
16 template < typename _Chromosome>
20 unsigned int currentGeneration = 0;
22 const unsigned int maxNumberOfGenerations = 1000;
27 * Checks if current generation passes stop condition.
28 * If condition is satisfied, we can check another generation.
30 * @param generation current generation to check
32 * @return true if condition is satisfied and another generation can checked;
33 * false if condition is not satisfied and algorithm should stop.
35 virtual bool check(Generation<_Chromosome> generation) {
36 if (currentGeneration >= maxNumberOfGenerations) {
46 #endif /* __ALGORITHM_CONDITION_H */