JGAP

org.jgap.impl
Class WeightedRouletteSelector

java.lang.Object
  extended by org.jgap.NaturalSelector
      extended by org.jgap.impl.WeightedRouletteSelector
All Implemented Interfaces:
java.io.Serializable, Configurable, INaturalSelector

public class WeightedRouletteSelector
extends 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.

Since:
1.0
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jgap.NaturalSelector
NaturalSelector.FitnessValueComparator
 
Constructor Summary
WeightedRouletteSelector()
          Default constructor.
WeightedRouletteSelector(Configuration a_config)
           
 
Method Summary
protected  void add(IChromosome a_chromosomeToAdd)
          Add a Chromosome instance to this selector's working pool of Chromosomes.
 void empty()
          Empty out the working pool of Chromosomes.
 boolean getDoubletteChromosomesAllowed()
           
 boolean returnsUniqueChromosomes()
           
 void select(int a_howManyToSelect, Population a_from_pop, Population a_to_pop)
          Select a given number of Chromosomes from the pool that will move on to the next generation population.
 void setDoubletteChromosomesAllowed(boolean a_doublettesAllowed)
          Determines whether doublette chromosomes may be added to the selector or will be ignored.
 
Methods inherited from class org.jgap.NaturalSelector
getConfiguration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WeightedRouletteSelector

public WeightedRouletteSelector()
Default constructor.

Attention: The configuration used is the one set with the static method Genotype.setConfiguration.

Since:
2.0

WeightedRouletteSelector

public WeightedRouletteSelector(Configuration a_config)
Parameters:
a_config - the configuration to use
Since:
3.0
Method Detail

add

protected void add(IChromosome a_chromosomeToAdd)
Add a Chromosome instance to this selector's working pool of Chromosomes.

Specified by:
add in class NaturalSelector
Parameters:
a_chromosomeToAdd - the chromosom to add to the pool
Since:
1.0

select

public void select(int a_howManyToSelect,
                   Population a_from_pop,
                   Population a_to_pop)
Select a given number of Chromosomes from the pool that will move on to the next generation population. 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 should be more likely to be selected than those with lower fitness values, but it should not be guaranteed.

Parameters:
a_howManyToSelect - the number of Chromosomes to select
a_from_pop - the population the Chromosomes will be selected from
a_to_pop - the population the Chromosomes will be added to
Since:
1.0

empty

public void empty()
Empty out the working pool of Chromosomes.

Since:
1.0

returnsUniqueChromosomes

public boolean returnsUniqueChromosomes()
Returns:
always false as some Chromosome's could be returnd multiple times
Since:
2.0

setDoubletteChromosomesAllowed

public void setDoubletteChromosomesAllowed(boolean a_doublettesAllowed)
Determines whether doublette chromosomes may be added to the selector or will be ignored.

Parameters:
a_doublettesAllowed - true: doublette chromosomes allowed to be added to the selector. FALSE: doublettes will be ignored and not added
Since:
2.0

getDoubletteChromosomesAllowed

public boolean getDoubletteChromosomesAllowed()
Returns:
TRUE: doublette chromosomes allowed to be added to the selector
Since:
2.0

JGAP