Click or drag to resize

SelectionAlgorithm

Selection is the stage of a genetic algorithm in which individual genomes are chosen from a population for later breeding (recombination or crossover).

SelectionAlgorithmT is an abstract class that derives basic selection techniques for picking the individuals from the population based on randomness and/or fitness.

This topic contains the following sections:

Each selection algorithm implementation involves the following methods:

Uniform Selection
Roulette Selection

Roulette selection procedure is implemented as follows:

  1. The fitness function is scaled for each individual

  2. The area of the section of the wheel corresponding to an individual is proportional to the individual's scaled fitness.

  3. The algorithm uses a random number to select one of the sections with a probability equal to its area.

The following constructor is used to initialize an instance of RouletteSelectionT algorithm:

methodRouletteSelectionT(RandomGenerator)

Stochastic Uniform Selection

Stochastic Uniform selection procedure is implemented as follows:

  1. The fitness function is scaled for each individual

  2. Each parent corresponds to a section of the line of length proportional to its scaled value.

  3. A random step size is chosen.

  4. The algorithm moves along the line in steps of equal size. At each step, the algorithm allocates a parent from the section it lands on.

The following constructor is used to initialize an instance of StochasticUniformSelectionT algorithm:

methodStochasticUniformSelectionT(RandomGenerator)

Tournament Selection
Code Sample

This section presents an example that shows how to create a custom selection algorithm for the genetic algorithm. The created customSelection chooses the best individual out of the set using tournament selection.

C#
1// Initialize random generator which is used during selection process.
2RandomGenerator r = new RandomGenerator(RandomGeneratorType.MCG31);
3
4// Initialize new selection algorithm class instance.
5SelectionAlgorithm<RastriginFunction> customSelection = new TournamentSelection<RastriginFunction>(r, 10, 10);
6
7ga.SelectionAlgorithm = customSelection;

See Also

Other Resources