X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=src%2Fmain.cpp;h=36dd6028c472b0b983d04aaeab8652eb0d04e1c5;hb=5e4a04634f1d31d4c774b44184cf08d3faf4d02a;hp=f82cc9221370ef8a2efce8b16e0e1d6f59648b1d;hpb=171bb6f1ba7b2ee5d9be674beb8b828910c8e659;p=genetic.git diff --git a/src/main.cpp b/src/main.cpp index f82cc92..36dd602 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,12 +9,14 @@ #include "generator/bit.h" #include "selection/roulette.h" +#include "selection/linearRankSelection.h" #include "crossover/crossover.h" #include "mutation/mutation.h" #include "fitness/wsti.h" #include "algorithm.h" #include "condition/condition.h" +#include "condition/generationLimit.h" using namespace std; using namespace genetic; @@ -24,13 +26,13 @@ int main() { typedef Chromosome<_Gene> _Chromosome; typedef WSTI<_Chromosome> _Fitness; - typedef Roulette<_Chromosome> _Selection; + typedef LinearRankSelection<_Chromosome> _Selection; typedef Crossover<_Chromosome> _Crossover; typedef Mutation<_Chromosome> _Mutation; typedef generator::Bit<_Chromosome> _Generator; typedef Algorithm<_Chromosome, _Selection, _Crossover, _Mutation, _Fitness> _Algorithm; - typedef Condition<_Chromosome> _Condition; + typedef GenerationLimit<_Chromosome> _Condition; const int chromosomeSize = 10; const int generationSize = 200; @@ -41,7 +43,7 @@ int main() { _Generator generationGenerator(generationSize, chromosomeSize); _Algorithm algorithm(generationGenerator, fitness, crossoverChance, mutationChance); - _Condition condition; + _Condition condition(1000); algorithm.searchForResult(condition);