JGAP

org.jgap.impl
Class BestChromosomesSelector

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

public class BestChromosomesSelector
extends NaturalSelector

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.FitnessValueComparator
 
Constructor Summary
BestChromosomesSelector()
          Default constructor.
BestChromosomesSelector(Configuration a_config)
          Using original rate of 1.0
BestChromosomesSelector(Configuration a_config, double a_originalRate)
           
 
Method Summary
protected  void add(IChromosome a_chromosomeToAdd)
          Add a Chromosome instance to this selector's working pool of Chromosomes.
 void empty()
          Empties out the working pool of Chromosomes.
 boolean getDoubletteChromosomesAllowed()
           
 double getOriginalRate()
           
 boolean returnsUniqueChromosomes()
           
 void select(int a_howManyToSelect, Population a_from_pop, Population a_to_pop)
          Selects 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.
 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.
 
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

BestChromosomesSelector

public BestChromosomesSelector()
                        throws InvalidConfigurationException
Default 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

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 specimen to add to the pool
Since:
1.1

select

public void select(int a_howManyToSelect,
                   Population a_from_pop,
                   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_from_pop - the population the Chromosomes will be selected from
a_to_pop - the population the Chromosomes will be added to
a_howManyToSelect - the number of Chromosomes to select
Since:
1.1

empty

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

Since:
1.1

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

returnsUniqueChromosomes

public boolean returnsUniqueChromosomes()
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

JGAP