Top Description Fields Constructors Methods
org.apache.commons.math3.genetics

public Class TournamentSelection

extends Object
implements SelectionPolicy
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.genetics.SelectionPolicy
Imports
java.util.ArrayList, .List, org.apache.commons.math3.exception.MathIllegalArgumentException, org.apache.commons.math3.exception.util.LocalizedFormats

Tournament selection scheme. Each of the two selected chromosomes is selected based on n-ary tournament -- this is done by drawing arity random chromosomes without replacement from the population, and then selecting the fittest chromosome among them.
Since
2.0

Field Summary

Modifier and TypeField and Description
private int
arity

number of chromosomes included in the tournament selections

Constructor Summary

AccessConstructor and Description
public
TournamentSelection(final int
how many chromosomes will be drawn to the tournament
arity
)

Creates a new TournamentSelection instance.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

arity of the tournament
getArity
()

Gets the arity (number of chromosomes drawn to the tournament).

public ChromosomePair

Returns:

the selected chromosomes.
select
(final Population
the population from which the chromosomes are chosen.
population
)

Implements org.apache.commons.math3.genetics.SelectionPolicy.select.

Select two chromosomes from the population.

public void
setArity(final int
arity of the tournament
arity
)

Sets the arity (number of chromosomes drawn to the tournament).

private Chromosome

Returns:

the selected chromosome.
tournament
(final ListPopulation
the population from which the chromosomes are chosen.
population
)

Helper for select(Population).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

arityback to summary
private int arity

number of chromosomes included in the tournament selections

Constructor Detail

TournamentSelectionback to summary
public TournamentSelection(final int arity)

Creates a new TournamentSelection instance.

Parameters
arity:int

how many chromosomes will be drawn to the tournament

Method Detail

getArityback to summary
public int getArity()

Gets the arity (number of chromosomes drawn to the tournament).

Returns:int

arity of the tournament

selectback to summary
public ChromosomePair select(final Population population) throws MathIllegalArgumentException

Implements org.apache.commons.math3.genetics.SelectionPolicy.select.

Select two chromosomes from the population. Each of the two selected chromosomes is selected based on n-ary tournament -- this is done by drawing arity random chromosomes without replacement from the population, and then selecting the fittest chromosome among them.

Parameters
population:Population

the population from which the chromosomes are chosen.

Returns:ChromosomePair

the selected chromosomes.

Exceptions
MathIllegalArgumentException:
if the tournament arity is bigger than the population size
setArityback to summary
public void setArity(final int arity)

Sets the arity (number of chromosomes drawn to the tournament).

Parameters
arity:int

arity of the tournament

tournamentback to summary
private Chromosome tournament(final ListPopulation population) throws MathIllegalArgumentException

Helper for select(Population). Draw arity random chromosomes without replacement from the population, and then select the fittest chromosome among them.

Parameters
population:ListPopulation

the population from which the chromosomes are chosen.

Returns:Chromosome

the selected chromosome.

Exceptions
MathIllegalArgumentException:
if the tournament arity is bigger than the population size