org.jgap
Class WeightedRouletteSelector

java.lang.Object
  |
  +--org.jgap.WeightedRouletteSelector
All Implemented Interfaces:
NaturalSelector

public class WeightedRouletteSelector
extends java.lang.Object
implements NaturalSelector

A basic implementation of NaturalSelector that models a roulette wheel. When a Chromosome is added, it gets a number of "slots" on the wheel equal to its fitness value. When the select method is invoked, the wheel is "spun" and the Chromosome occupying the spot on which it lands is selected. Then the wheel is spun again and again until the requested number of Chromosomes have been selected. Since Chromosomes with higher fitness values get more slots on the wheel, there's a higher statistical probability that they'll be chosen, but it's not guaranteed.

Author:
Neil Rotstan (neil at bluesock.org)

Constructor Summary
WeightedRouletteSelector()
           
 
Method Summary
 void add(org.jgap.Chromosome chromosome, int fitness)
          Add a Chromosome instance and corresponding fitness value to this selector's working pool of Chromosomes.
 void empty()
          Empty out the working pool of Chromosomes.
 org.jgap.Chromosome[] select(int howMany)
          Select a given number of Chromosomes from the pool that will continue to survive.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WeightedRouletteSelector

public WeightedRouletteSelector()
Method Detail

add

public void add(org.jgap.Chromosome chromosome,
                int fitness)
Description copied from interface: NaturalSelector
Add a Chromosome instance and corresponding fitness value to this selector's working pool of Chromosomes.

Specified by:
add in interface NaturalSelector

select

public org.jgap.Chromosome[] select(int howMany)
Description copied from interface: NaturalSelector
Select a given number of Chromosomes from the pool that will continue to survive. This selection should be guided by the fitness values, but fitness should be treated as a statistical probability of survival, not as the sole determining factor. In other words, Chromosomes with higher fitness values are more likely to be selected than those with lower fitness values, but it's not guaranteed.

Specified by:
select in interface NaturalSelector
Returns:
An array of the selected Chromosomes.

empty

public void empty()
Description copied from interface: NaturalSelector
Empty out the working pool of Chromosomes.

Specified by:
empty in interface NaturalSelector