Watchmaker Framework for Evolutionary Computation API
(Version 0.7.1)

org.uncommons.watchmaker.framework.selection
Class TruncationSelection

java.lang.Object
  extended by org.uncommons.watchmaker.framework.selection.TruncationSelection
All Implemented Interfaces:
SelectionStrategy<Object>

public class TruncationSelection
extends Object
implements SelectionStrategy<Object>

Implements selection of n candidates from a population by simply selecting the n candidates with the highest fitness scores (the rest are discarded). A candidate is never selected more than once.

Author:
Daniel Dyer

Constructor Summary
TruncationSelection(double selectionRatio)
           
TruncationSelection(NumberGenerator<Double> selectionRatio)
          Creates a truncation selection strategy that is controlled by the variable selection ratio provided by the specified NumberGenerator.
 
Method Summary
<S> List<S>
select(List<EvaluatedCandidate<S>> population, boolean naturalFitnessScores, int selectionSize, Random rng)
          Selects the fittest candidates.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TruncationSelection

public TruncationSelection(NumberGenerator<Double> selectionRatio)
Creates a truncation selection strategy that is controlled by the variable selection ratio provided by the specified NumberGenerator.

Parameters:
selectionRatio - A number generator that produces values in the range 0 < r < 1. These values are used to determine the proportion of the population that is retained in any given selection.

TruncationSelection

public TruncationSelection(double selectionRatio)
Parameters:
selectionRatio - The proportion of the highest ranked candidates to select from the population. The value must be positive and less than 1.
Method Detail

select

public <S> List<S> select(List<EvaluatedCandidate<S>> population,
                          boolean naturalFitnessScores,
                          int selectionSize,
                          Random rng)
Selects the fittest candidates. If the selectionRatio results in fewer selected candidates than required, then these candidates are selected multiple times to make up the shortfall.

Specified by:
select in interface SelectionStrategy<Object>
Type Parameters:
S - The type of evolved entity that is being selected.
Parameters:
population - The population of evolved and evaluated candidates from which to select.
naturalFitnessScores - Whether higher fitness values represent fitter individuals or not.
selectionSize - The number of candidates to select from the evolved population.
rng - A source of randomness (not used by this selection implementation since truncation selection is deterministic).
Returns:
The selected candidates.

toString

public String toString()

Overrides:
toString in class Object

Watchmaker Framework for Evolutionary Computation API
(Version 0.7.1)