static void Main(string[] args) { // Crossover = 80% // Mutation = 5% // Population size = 100 // Generations = 2000 // Genome size = 2 var crossover = 0.8; var mutationRate = 0.05; var populationSize = 100; var generations = 2000; var genomeSize = 2; //create objects var random = new Random((int)DateTime.Now.Ticks); var genesFactory = new GenesFactory(random); var genomeFactory = new GenomeFactory(genesFactory, random, mutationRate); var geneticAlghoritm = new GeneticAlghoritm(random, FitnessFunction, genomeFactory, crossover, populationSize, generations, genomeSize); //execute alghoritm geneticAlghoritm.Execute(); //show results ShowResults(true, geneticAlghoritm); ShowResults(false, geneticAlghoritm); // Console.ReadKey(); }
public GenomeFactory(GenesFactory genesFactory, Random random, double mutationRate) { _genesFactory = genesFactory; _random = random; _mutationRate = mutationRate; }