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