org.jgap.impl
Class BestChromosomesSelector
- java.lang.Object
-
- org.jgap.NaturalSelector
-
- org.jgap.NaturalSelectorExt
-
- org.jgap.impl.BestChromosomesSelector
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, Configurable, INaturalSelector, ICloneable
public class BestChromosomesSelector extends NaturalSelectorExt implements ICloneable
Implementation of a NaturalSelector that takes the top n chromosomes into the next generation. n can be specified. Which chromosomes are the best is decided by evaluating their fitness value.- Since:
- 1.1
- 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 BestChromosomesSelector()Default constructor.BestChromosomesSelector(Configuration a_config)Using original rate of 1.0BestChromosomesSelector(Configuration a_config, double a_originalRate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description java.lang.Objectclone()voidempty()Empties out the working pool of Chromosomes.booleanequals(java.lang.Object a_o)doublegetOriginalRate()booleanreturnsUniqueChromosomes()voidselectChromosomes(int a_howManyToSelect, Population a_to_pop)Selects a given number of chromosomes from the pool that will move on to the next generation population.voidsetOriginalRate(double a_originalRate)Setting this parameter controls how many chromosomes of the original population will be considered for selection to the next population.-
Methods inherited from class org.jgap.NaturalSelectorExt
getDoubletteChromosomesAllowed, select, setDoubletteChromosomesAllowed
-
Methods inherited from class org.jgap.NaturalSelector
getConfiguration
-
-
-
-
Constructor Detail
-
BestChromosomesSelector
public BestChromosomesSelector() throws InvalidConfigurationExceptionDefault constructor. Attention: The configuration used is the one set with the static method Genotype.setConfiguration.- Throws:
InvalidConfigurationException- Since:
- 1.1
-
BestChromosomesSelector
public BestChromosomesSelector(Configuration a_config) throws InvalidConfigurationException
Using original rate of 1.0- Parameters:
a_config- the configuration to use- Throws:
InvalidConfigurationException- Since:
- 3.0
-
BestChromosomesSelector
public BestChromosomesSelector(Configuration a_config, double a_originalRate) throws InvalidConfigurationException
- Throws:
InvalidConfigurationException
-
-
Method Detail
-
selectChromosomes
public void selectChromosomes(int a_howManyToSelect, Population a_to_pop)Selects a given number of chromosomes from the pool that will move on to the next generation population. This selection will be guided by the fitness values. The chromosomes with the best fitness value win.- Parameters:
a_to_pop- the population the chromosomes will be added toa_howManyToSelect- the number of chromosomes to select- Since:
- 1.1
-
empty
public void empty()
Empties out the working pool of Chromosomes.- Specified by:
emptyin interfaceINaturalSelector- Since:
- 1.1
-
returnsUniqueChromosomes
public boolean returnsUniqueChromosomes()
- Specified by:
returnsUniqueChromosomesin interfaceINaturalSelector- Returns:
- always true as no Chromosome can be returnd multiple times
- Since:
- 2.0
-
setOriginalRate
public void setOriginalRate(double a_originalRate)
Setting this parameter controls how many chromosomes of the original population will be considered for selection to the next population. If the value is 1 then the whole original population is considered, if it is 0.5 only half of the chromosomes are considered. If doublettes are allowed, then a number of chromosomes missing (number of to be selected minus number selected) will be added.- Parameters:
a_originalRate- the rate of how many of the original chromosomes will be selected according to BestChromosomeSelector's strategy. The rest (non-original) of the chromosomes is added as duplicates- Since:
- 2.0
-
getOriginalRate
public double getOriginalRate()
- Returns:
- see setOriginalRate
- Since:
- 2.0
-
equals
public boolean equals(java.lang.Object a_o)
- Overrides:
equalsin classNaturalSelectorExt- Parameters:
a_o- the object to compare- Returns:
- true: compared object is seen as equal to current instance
-
clone
public java.lang.Object clone()
- Specified by:
clonein interfaceICloneable- Overrides:
clonein classjava.lang.Object- Returns:
- clone of the current object instance
-
-
DMelt 3.0 © DataMelt by jWork.ORG