dlife.ga
Class RouletteWheel
java.lang.Object
dlife.ga.RouletteWheel
- All Implemented Interfaces:
- ParentSelector, Serializable
public class RouletteWheel
- extends Object
- implements ParentSelector
An implementation of weighted roulette wheel selection. Each Individual in
the Population is given a slot on a hypothetical roulette wheel. The size of
each Individual's slot is proportional to its fitness. The wheel is then spun
and the Individual on which it stops is selected as the parent.
This ParentSelector only works if all individuals have positive fitness. Use
a FitnessScaler in order to work with populations where non-positive fitness
values are valid.
- Version:
- Jan 7, 2007
- Author:
- Grant Braught, Dickinson College
- See Also:
- Serialized Form
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RouletteWheel
public RouletteWheel()
pickParent
public Individual pickParent(Population pop)
- Use a weighted roulette wheel technique to select an Individual from the
Population.
- Specified by:
pickParent in interface ParentSelector
- Parameters:
pop - the Population to choose from.
- Returns:
- the Individual selected to become a Parent.
- Throws:
IllegalStateException - if any Individual has negative fitness or if
all Individuals have 0 fitness.