Additional optimization. Removed get() method from Generation.
[genetic.git] / src / main.cpp
1 #include <iostream>
2 #include <vector>
3 #include <map>
4 #include <string>
5
6 #include "gene.h"
7 #include "chromosome.h"
8 #include "generation.h"
9 #include "generator/generation.h"
10
11 #include "selection/roulette.h"
12 #include "crossover/crossover.h"
13 #include "mutation/mutation.h"
14 #include "fitness/wsti.h"
15
16 #include "algorithm.h"
17 #include "condition/condition.h"
18
19 using namespace std;
20 using namespace genetic;
21
22 int main() {
23     typedef Gene<int> _Gene;
24     typedef Chromosome<_Gene> _Chromosome;
25
26     typedef WSTI<_Chromosome> _Fitness;
27     typedef Roulette<_Chromosome> _Selection;
28     typedef Crossover<_Chromosome> _Crossover;
29     typedef Mutation<_Chromosome> _Mutation;
30
31     typedef generator::Generation<_Chromosome> _Generator;
32     typedef Algorithm<_Chromosome, _Selection, _Crossover, _Mutation, _Fitness> _Algorithm;
33     typedef Condition<_Chromosome> _Condition;
34
35     const int chromosomeSize = 10;
36     const int generationSize = 200;
37     const double crossoverChance = 0.75;
38     const double mutationChance = 0.1;
39
40     _Fitness fitness(0.5, 2.5);
41     _Generator generationGenerator(generationSize, chromosomeSize);
42
43     _Algorithm algorithm(generationGenerator, fitness, crossoverChance, mutationChance);
44     _Condition condition;
45
46     algorithm.searchForResult(condition);
47
48     return 0;
49 }