-
-
Notifications
You must be signed in to change notification settings - Fork 344
###How can I change the mutation rate? The mutation rate can be changed on MutationProbability property of GeneticAlgorithm class:
var ga = new GeneticAlgorithm(population, fitness, selection, crossover, mutation);
ga.MutationProbability = 0.2f;
ga.Start();###How can I change the size of the population? The Population class allow you to define the minimum and maximum size of population in constructor:
// The line bellow will create a population that has a min size of 50 chromosomes and a max size of 70 chromosomes.
var population = new Population (50, 70, chromosome);
var ga = new GeneticAlgorithm(population, fitness, selection, crossover, mutation);
ga.Start();###How can I define the maximum generation number of the genetic algorithm? When the method Start of GeneticAlgorithm is called the GA will run until the current termination be reached. You can define the termination in the Termination property.
The default termination property is one generation:
ga.Termination = new GenerationNumberTermination(1);If you want to run your GA until 100 generations, just set it:
ga.Termination = new GenerationNumberTermination(100);
ga.Start();###What is the default mutation probability? The default mutation probability is defined in the constant GeneticAlgorithm.DefaultMutationProbability. The current value is 0.1f;