JGAP

org.jgap.impl
Class WeightedRouletteSelector

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

public class WeightedRouletteSelector
extends NaturalSelectorExt
implements ICloneable

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.AgeFitnessValueComparator, NaturalSelector.FitnessAgeValueComparator, NaturalSelector.FitnessValueComparator
 
Field Summary
 
Fields inherited from class org.jgap.NaturalSelector
m_monitor, m_monitorActive
 
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.
 java.lang.Object clone()
           
 void empty()
          Empty out the working pool of Chromosomes.
 boolean equals(java.lang.Object o)
           
 boolean getDoubletteChromosomesAllowed()
           
 boolean returnsUniqueChromosomes()
           
 void selectChromosomes(int a_howManyToSelect, 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)
          Not supported by this selector!
 
Methods inherited from class org.jgap.NaturalSelectorExt
init, select, selectChromosome
 
Methods inherited from class org.jgap.NaturalSelector
getConfiguration
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WeightedRouletteSelector

public WeightedRouletteSelector()
                         throws InvalidConfigurationException
Default constructor.

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

Throws:
InvalidConfigurationException
Since:
2.0

WeightedRouletteSelector

public WeightedRouletteSelector(Configuration a_config)
                         throws InvalidConfigurationException
Parameters:
a_config - the configuration to use
Throws:
InvalidConfigurationException
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 NaturalSelectorExt
Parameters:
a_chromosomeToAdd - the chromosom to add to the pool
Since:
1.0

selectChromosomes

public void selectChromosomes(int a_howManyToSelect,
                              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.

Specified by:
selectChromosomes in class NaturalSelectorExt
Parameters:
a_howManyToSelect - the number of Chromosomes to select
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.

Specified by:
empty in interface INaturalSelector
Since:
1.0

returnsUniqueChromosomes

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

setDoubletteChromosomesAllowed

public void setDoubletteChromosomesAllowed(boolean a_doublettesAllowed)
Not supported by this selector! Please do not use it.

Overrides:
setDoubletteChromosomesAllowed in class NaturalSelectorExt
Parameters:
a_doublettesAllowed - do not use
Since:
2.0

getDoubletteChromosomesAllowed

public boolean getDoubletteChromosomesAllowed()
Overrides:
getDoubletteChromosomesAllowed in class NaturalSelectorExt
Returns:
TRUE: doublette chromosomes allowed to be added by the selector
Since:
2.0

clone

public java.lang.Object clone()
Specified by:
clone in interface ICloneable
Overrides:
clone in class java.lang.Object
Returns:
deep clone of this instance
Since:
3.2

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class NaturalSelectorExt
Parameters:
o - the object to compare
Returns:
true: compared object is seen as equal to current instance

JGAP