## org.biojavax.ga.functions
Class TournamentSelection

    java.lang.Object
      org.biojavax.ga.functions.TournamentSelection

All Implemented Interfaces:
  SelectionFunction

    public class TournamentSelection

extends Object
implements SelectionFunction

Tournament Selection chooses the best organisms from n random subsets of a given population. Currently it assumes a maximization problem. Perhaps this could be selected depending on the Genetic Algorithm utilized.

Author:
  Susanne Merz

Nested Class Summary

Nested classes/interfaces inherited from interface org.biojavax.ga.functions.SelectionFunction
`SelectionFunction.SelectAll, SelectionFunction.Threshold`

Field Summary

Fields inherited from interface org.biojavax.ga.functions.SelectionFunction
`DEFAULT`

Constructor Summary
`TournamentSelection()` Default constructor: sets the selection pressure to the value of 10.

Method Summary
`Population` `select(Population pop, GeneticAlgorithm genAlg)` Standard call to select organisms, will select a number of Organisms corresponding to 75 % of the population.
`Population` `selectNIndividuals(Population pop, GeneticAlgorithm ga, int n)` This method selects n Organism from the population it is given, using the tournament selection method
`void` `setSelectionPressure(int numberOfIndividuals)` sets the parameter controlling selection pressure

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### TournamentSelection

    public TournamentSelection()

  Default constructor: sets the selection pressure to the value of 10.

Method Detail

### setSelectionPressure

    public void setSelectionPressure(int numberOfIndividuals)

  sets the parameter controlling selection pressure

  Parameters:
    `numberOfIndividuals` - the number of Individuals the best is selected from, ranges from 1 (random selection) to the size of the population (elitism)

### select

    public Population select(Population pop,
                             GeneticAlgorithm genAlg)
                      throws ChangeVetoException

  Standard call to select organisms, will select a number of Organisms corresponding to 75 % of the population.

  Specified by:
    `select` in interface `SelectionFunction`
  Parameters:
    `pop` - the `Population` to select from.
    `genAlg` - the parent `GeneticAlgorithm`.
  Returns:
    the `Organism`s selected
  Throws:
    `ChangeVetoException` - if the function attempts to change the population and it is vetoed.
  See Also:
    `SelectionFunction.select(org.biojavax.ga.Population, org.biojavax.ga.GeneticAlgorithm)`

### selectNIndividuals

    public Population selectNIndividuals(Population pop,
                                         GeneticAlgorithm ga,
                                         int n)

  This method selects n Organism from the population it is given, using the tournament selection method

  Parameters:
    `pop` - the population to select from
    `ga` - the `GeneticAlgorithm` this selection belongs to
    `n` - number of individuals to be selected.
  Returns:
    nextgen a `Population` containing the selected Organisms