Class RouletteWheelSelection

  • All Implemented Interfaces:
    SelectionStrategy<Object>

    public class RouletteWheelSelection
    extends Object
    implements SelectionStrategy<Object>

    Implements selection of n candidates from a population by selecting n candidates at random where the probability of each candidate getting selected is proportional to its fitness score. This is analogous to each candidate being assigned an area on a roulette wheel proportionate to its fitness and the wheel being spun i times. Candidates may be selected more than once.

    In some instances, particularly with small population sizes, the randomness of selection may result in excessively high occurrences of particular candidates. If this is a problem, StochasticUniversalSampling provides an alternative fitness-proportionate strategy for selection.

    • Constructor Detail

      • RouletteWheelSelection

        public RouletteWheelSelection()
    • Method Detail

      • select

        public <S> List<S> select​(List<EvaluatedCandidate<S>> population,
                                  boolean naturalFitnessScores,
                                  int selectionSize,
                                  Random rng)
        Selects the required number of candidates from the population with the probability of selecting any particular candidate being proportional to that candidate's fitness score. Selection is with replacement (the same candidate may be selected multiple times).
        Specified by:
        select in interface SelectionStrategy<Object>
        Type Parameters:
        S - The type of the evolved objects in the population.
        Parameters:
        population - The candidates to select from.
        naturalFitnessScores - True if higher fitness scores indicate fitter individuals, false if lower fitness scores indicate fitter individuals.
        selectionSize - The number of selections to make.
        rng - A source of randomness.
        Returns:
        The selected candidates.