7 #include "chromosome.h"
8 #include "generation.h"
9 #include "generator/bitGenerator.h"
11 #include "selection/rouletteSelection.h"
12 #include "selection/linearRankSelection.h"
13 #include "crossover/crossover.h"
14 #include "mutation/mutation.h"
15 #include "fitness/wsti.h"
17 #include "algorithm.h"
18 #include "condition/condition.h"
19 #include "condition/generationLimitCondition.h"
22 using namespace genetic;
25 typedef Gene<bool> _Gene;
26 typedef Chromosome<_Gene> _Chromosome;
28 typedef WSTI<_Chromosome> _Fitness;
29 typedef LinearRankSelection<_Chromosome> _Selection;
30 typedef Crossover<_Chromosome> _Crossover;
31 typedef Mutation<_Chromosome> _Mutation;
33 typedef generator::BitGenerator<_Chromosome> _Generator;
34 typedef Algorithm<_Chromosome, _Selection, _Crossover, _Mutation, _Fitness> _Algorithm;
35 typedef GenerationLimitCondition<_Chromosome> _Condition;
37 const int chromosomeSize = 10;
38 const int generationSize = 200;
39 const double crossoverChance = 0.75;
40 const double mutationChance = 0.01;
42 _Fitness fitness(0.5, 2.5);
43 _Generator generationGenerator(generationSize, chromosomeSize);
45 _Algorithm algorithm(generationGenerator, fitness, crossoverChance, mutationChance);
46 _Condition condition(1000);
48 algorithm.searchForResult(condition);