Rename GenerationLimit to GenerationLimitCondition. Add test for this class.
[genetic.git] / tests / condition / generationLimitCondition / check.cpp
1 #include <iostream>
2 #include <vector>
3
4 #include "gene.h"
5 #include "chromosome.h"
6 #include "generation.h"
7 #include "generator/bitGenerator.h"
8 #include "condition/generationLimitCondition.h"
9
10 using namespace std;
11 using namespace genetic;
12
13 int main() {
14     typedef Gene<int> _Gene;
15     typedef Chromosome<_Gene> _Chromosome;
16     typedef Generation<_Chromosome> _Generation;
17     typedef generator::BitGenerator<_Chromosome> _Generator;
18     typedef GenerationLimitCondition<_Chromosome> _Condition;
19
20     const unsigned int chromosomeSize = 20;
21     const unsigned int generationSize = 100;
22     const unsigned int numberOfChecks = 20;
23
24     _Generator generator(generationSize, chromosomeSize);
25     _Generation generation = generator.breed();
26     _Condition condition(numberOfChecks);
27
28     unsigned int i = 0;
29     while(condition.check(generation)) {
30         if (i > numberOfChecks) {
31             cout << "GenerationLimitCondition got outside limit\n";
32             return 1;
33         }
34         i++;
35     }
36
37     cout << "BitGenerator breeded correctly\n";
38     return 0;
39 }
40