+#include <command/command.h>
+#include <command/option.h>
+
#include "gene.h"
#include "chromosome.h"
#include "generation.h"
using namespace genetic;
-int main() {
+int chromosomeSize = 10;
+int generationSize = 10;
+int generationLimit = 100;
+double crossoverChance = 0.75;
+double mutationChance = 0.01;
+
+int main(int argc, char* argv[]) {
typedef Gene<bool> _Gene;
typedef Chromosome<_Gene> _Chromosome;
typedef Algorithm<_Chromosome, _Selection, _Crossover, _Mutation, _Fitness> _Algorithm;
typedef GenerationLimitCondition<_Chromosome> _Condition;
- const int chromosomeSize = 10;
- const int generationSize = 500;
- const double crossoverChance = 0.75;
- const double mutationChance = 0.01;
+ command::Command command(argc, argv, {
+ new command::Option<int>("--chromosome-size", "Chromosome size", [](int value)->void { chromosomeSize = value; }),
+ new command::Option<int>("--generation-size", "Generation size", [](int value)->void { generationSize = value; }),
+ new command::Option<float>("--crossover", "Crossover chance", [](float value)->void { crossoverChance = value; }),
+ new command::Option<float>("--mutation", "Mutation chance", [](float value)->void { mutationChance = value; }),
+ new command::Option<float>("--generation-limit", "Limit of generations", [](float value)->void { mutationChance = value; }),
+ });
_Fitness fitness(0.5, 2.5);
_Generator generationGenerator(generationSize, chromosomeSize);
_Algorithm algorithm(generationGenerator, fitness, crossoverChance, mutationChance);
- _Condition condition(10000);
+ _Condition condition(generationLimit);
algorithm.searchForResult(condition);