Created custom Condition class: GenerationLimit.
[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/bit.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 #include "condition/generationLimit.h"
19
20 using namespace std;
21 using namespace genetic;
22
23 int main() {
24     typedef Gene<int> _Gene;
25     typedef Chromosome<_Gene> _Chromosome;
26
27     typedef WSTI<_Chromosome> _Fitness;
28     typedef Roulette<_Chromosome> _Selection;
29     typedef Crossover<_Chromosome> _Crossover;
30     typedef Mutation<_Chromosome> _Mutation;
31
32     typedef generator::Bit<_Chromosome> _Generator;
33     typedef Algorithm<_Chromosome, _Selection, _Crossover, _Mutation, _Fitness> _Algorithm;
34     typedef GenerationLimit<_Chromosome> _Condition;
35
36     const int chromosomeSize = 10;
37     const int generationSize = 200;
38     const double crossoverChance = 0.75;
39     const double mutationChance = 0.01;
40
41     _Fitness fitness(0.5, 2.5);
42     _Generator generationGenerator(generationSize, chromosomeSize);
43
44     _Algorithm algorithm(generationGenerator, fitness, crossoverChance, mutationChance);
45     _Condition condition(1000);
46
47     algorithm.searchForResult(condition);
48
49     return 0;
50 }