Class StochasticUniversalSampling
- java.lang.Object
-
- org.uncommons.watchmaker.framework.selection.StochasticUniversalSampling
-
- All Implemented Interfaces:
SelectionStrategy<Object>
public class StochasticUniversalSampling extends Object implements SelectionStrategy<Object>
An alternative toRouletteWheelSelection
as a fitness-proportionate selection strategy. Ensures that the frequency of selection for each candidate is consistent with its expected frequency of selection.
-
-
Constructor Summary
Constructors Constructor Description StochasticUniversalSampling()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <S> List<S>
select(List<EvaluatedCandidate<S>> population, boolean naturalFitnessScores, int selectionSize, Random rng)
Select the specified number of candidates from the population.String
toString()
-
-
-
Method Detail
-
select
public <S> List<S> select(List<EvaluatedCandidate<S>> population, boolean naturalFitnessScores, int selectionSize, Random rng)
Description copied from interface:SelectionStrategy
Select the specified number of candidates from the population. Implementations may assume that the population is sorted in descending order according to fitness (so the fittest individual is the first item in the list).
It is an error to call this method with an empty or null population.
- Specified by:
select
in interfaceSelectionStrategy<Object>
- Type Parameters:
S
- The type of evolved entity that we are selecting, a sub-type of T.- Parameters:
population
- The population from which to select.naturalFitnessScores
- Whether higher fitness values represent fitter individuals or not.selectionSize
- The number of individual selections to make (not necessarily the number of distinct candidates to select, since the same individual may potentially be selected more than once).rng
- Source of randomness for stochastic selection strategies.- Returns:
- A list containing the selected candidates. Some individual canidates may potentially have been selected multiple times.
-
-