Skip to content
Diego Giacomelli edited this page Jan 14, 2023 · 8 revisions

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 allows you to define the minimum and maximum size of a population in the constructor:

// The line below 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();

How can I use NSGA-II or other multi-objective GAs with GeneticSharp?

GeneticSharp does not support multi-objective GAs and there is no plan for something like this.

What is the default mutation probability?

The default mutation probability is defined in the constant GeneticAlgorithm.DefaultMutationProbability. The current value is 0.1f;

Your question is not here?

Take a look on the issues with "question" tag.