org.jgap.impl
Class WeightedRouletteSelector
- java.lang.Object
-
- org.jgap.NaturalSelector
-
- org.jgap.NaturalSelectorExt
-
- 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
-
-
Constructor Summary
Constructors Constructor and Description WeightedRouletteSelector()Default constructor.WeightedRouletteSelector(Configuration a_config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description java.lang.Objectclone()voidempty()Empty out the working pool of Chromosomes.booleanequals(java.lang.Object o)booleangetDoubletteChromosomesAllowed()booleanreturnsUniqueChromosomes()voidselectChromosomes(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.voidsetDoubletteChromosomesAllowed(boolean a_doublettesAllowed)Not supported by this selector! Please do not use it.-
Methods inherited from class org.jgap.NaturalSelectorExt
select
-
Methods inherited from class org.jgap.NaturalSelector
getConfiguration
-
-
-
-
Constructor Detail
-
WeightedRouletteSelector
public WeightedRouletteSelector() throws InvalidConfigurationExceptionDefault 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
-
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.- Parameters:
a_howManyToSelect- the number of Chromosomes to selecta_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:
emptyin interfaceINaturalSelector- Since:
- 1.0
-
returnsUniqueChromosomes
public boolean returnsUniqueChromosomes()
- Specified by:
returnsUniqueChromosomesin interfaceINaturalSelector- 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:
setDoubletteChromosomesAllowedin classNaturalSelectorExt- Parameters:
a_doublettesAllowed- do not use- Since:
- 2.0
-
getDoubletteChromosomesAllowed
public boolean getDoubletteChromosomesAllowed()
- Overrides:
getDoubletteChromosomesAllowedin classNaturalSelectorExt- Returns:
- TRUE: doublette chromosomes allowed to be added by the selector
- Since:
- 2.0
-
clone
public java.lang.Object clone()
- Specified by:
clonein interfaceICloneable- Overrides:
clonein classjava.lang.Object- Returns:
- deep clone of this instance
- Since:
- 3.2
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classNaturalSelectorExt- Parameters:
o- the object to compare- Returns:
- true: compared object is seen as equal to current instance
-
-
DMelt 3.0 © DataMelt by jWork.ORG