JGAP

org.jgap.impl
Class TournamentSelector

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

public class TournamentSelector
extends NaturalSelector

Implementation of a NaturalSelector that plays tournaments to determine the chromosomes to be taken to the next generation.

The tournament size can be adjusted as well as the probability for selecting an individual.

Since:
2.0
See Also:
Serialized Form

Constructor Summary
TournamentSelector()
          Default constructor.
TournamentSelector(Configuration a_config, int a_tournament_size, double a_probability)
           
 
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.
 double getProbability()
           
 int getTournamentSize()
           
 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 setProbability(double a_probability)
           
 void setTournamentSize(int a_tournament_size)
           
 
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

TournamentSelector

public TournamentSelector()
Default constructor.

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


TournamentSelector

public TournamentSelector(Configuration a_config,
                          int a_tournament_size,
                          double a_probability)
Parameters:
a_config - the configuration to use
a_tournament_size - the size of each tournament to play
a_probability - probability for selecting the best individuals
Since:
2.0
Method Detail

setTournamentSize

public void setTournamentSize(int a_tournament_size)

getTournamentSize

public int getTournamentSize()

getProbability

public double getProbability()

setProbability

public void setProbability(double a_probability)

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 will be guided by the fitness values. The chromosomes with the best fitness value win.

Parameters:
a_howManyToSelect - int
a_from_pop - the population the Chromosomes will be selected from
a_to_pop - the population the Chromosomes will be added to
Since:
2.0

returnsUniqueChromosomes

public boolean returnsUniqueChromosomes()
Returns:
false as we allow to return the same chromosome multiple times
Since:
2.0

empty

public void empty()
Description copied from interface: INaturalSelector
Empty out the working pool of Chromosomes. This will be invoked after each evolution cycle so that the natural selector can be reused for the next one.


add

protected void add(IChromosome a_chromosomeToAdd)
Description copied from class: NaturalSelector
Add a Chromosome instance to this selector's working pool of Chromosomes.

Specified by:
add in class NaturalSelector
Parameters:
a_chromosomeToAdd - the Chromosome to add
Since:
2.0

JGAP