Watchmaker Framework for Evolutionary Computation API
(Version 0.7.1)

org.uncommons.watchmaker.framework.selection
Class TournamentSelection

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

public class TournamentSelection
extends Object
implements SelectionStrategy<Object>

Selection strategy that picks a pair of candidates at random and then selects the fitter of the two candidates with probability p, where p is the configured selection probability (therefore the probability of the less fit candidate being selected is 1 - p).

Author:
Daniel Dyer

Constructor Summary
TournamentSelection(NumberGenerator<Probability> selectionProbability)
          Creates a tournament selection strategy that is controlled by the variable selection probability provided by the specified NumberGenerator.
TournamentSelection(Probability selectionProbability)
          Creates a tournament selection strategy with a fixed probability.
 
Method Summary
<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()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TournamentSelection

public TournamentSelection(NumberGenerator<Probability> selectionProbability)
Creates a tournament selection strategy that is controlled by the variable selection probability provided by the specified NumberGenerator.

Parameters:
selectionProbability - A number generator that produces values in the range 0.5 < p < 1. These values are used as the probability of the fittest candidate being selected in any given tournament.

TournamentSelection

public TournamentSelection(Probability selectionProbability)
Creates a tournament selection strategy with a fixed probability.

Parameters:
selectionProbability - The probability that the fitter of two randomly chosen candidates will be selected. Since this is a probability it must be between 0.0 and 1.0. This implementation adds the further restriction that the probability must be greater than 0.5 since any lower value would favour weaker candidates over strong ones, negating the "survival of the fittest" aspect of the evolutionary algorithm.
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 interface SelectionStrategy<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.

toString

public String toString()

Overrides:
toString in class Object

Watchmaker Framework for Evolutionary Computation API
(Version 0.7.1)