Package io.jenetics
Class RouletteWheelSelector<G extends Gene<?,G>,N extends Number & Comparable<? super N>>
- java.lang.Object
-
- io.jenetics.ProbabilitySelector<G,N>
-
- io.jenetics.RouletteWheelSelector<G,N>
-
- All Implemented Interfaces:
Selector<G,N>
- Direct Known Subclasses:
StochasticUniversalSelector
public class RouletteWheelSelector<G extends Gene<?,G>,N extends Number & Comparable<? super N>> extends ProbabilitySelector<G,N>
The roulette-wheel selector is also known as fitness proportional selector, but in the Jenetics library it is implemented as probability selector. The fitness value fi is used to calculate the selection probability of individual i.- Since:
- 1.0
- Version:
- 5.0
- See Also:
- Wikipedia: Roulette wheel selection
-
-
Field Summary
-
Fields inherited from class io.jenetics.ProbabilitySelector
_reverter, _sorted, POPULATION_COMPARATOR
-
-
Constructor Summary
Constructors Modifier Constructor Description RouletteWheelSelector()
protected
RouletteWheelSelector(boolean sorted)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected double[]
probabilities(Seq<Phenotype<G,N>> population, int count)
Return an Probability array, which corresponds to the given Population.String
toString()
-
Methods inherited from class io.jenetics.ProbabilitySelector
probabilities, select
-
-
-
-
Constructor Detail
-
RouletteWheelSelector
public RouletteWheelSelector()
-
RouletteWheelSelector
protected RouletteWheelSelector(boolean sorted)
-
-
Method Detail
-
probabilities
protected double[] probabilities(Seq<Phenotype<G,N>> population, int count)
Description copied from class:ProbabilitySelector
Return an Probability array, which corresponds to the given Population. The probability array and the population must have the same size. The population is not sorted. If a subclass needs a sorted population, the subclass is responsible to sort the population.
The implementer always assumes that higher fitness values are better. The base class inverts the probabilities, by reverting the returned probability array, if the GA is supposed to minimize the fitness function.- Specified by:
probabilities
in classProbabilitySelector<G extends Gene<?,G>,N extends Number & Comparable<? super N>>
- Parameters:
population
- The unsorted population.count
- The number of phenotypes to select. This parameter is not needed for most implementations.- Returns:
- Probability array. The returned probability array must have the
length
population.size()
and must sum to one. The returned value is checked withassert(Math.abs(math.sum(probabilities) - 1.0) < 0.0001)
in the base class.
-
-