Class TournamentSelection
java.lang.Object
org.apache.commons.math3.genetics.TournamentSelection
- All Implemented Interfaces:
SelectionPolicy
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
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetArity()Gets the arity (number of chromosomes drawn to the tournament).select(Population population) Select two chromosomes from the population.voidsetArity(int arity) Sets the arity (number of chromosomes drawn to the tournament).
-
Constructor Details
-
TournamentSelection
Creates a new TournamentSelection instance.- Parameters:
arity- how many chromosomes will be drawn to the tournament
-
-
Method Details
-
select
Select two chromosomes from the population. Each of the two selected chromosomes is selected based on n-ary tournament -- this is done by drawingarityrandom chromosomes without replacement from the population, and then selecting the fittest chromosome among them.- Specified by:
selectin interfaceSelectionPolicy- Parameters:
population- the population from which the chromosomes are chosen.- Returns:
- the selected chromosomes.
- Throws:
MathIllegalArgumentException- if the tournament arity is bigger than the population size
-
getArity
Gets the arity (number of chromosomes drawn to the tournament).- Returns:
- arity of the tournament
-
setArity
Sets the arity (number of chromosomes drawn to the tournament).- Parameters:
arity- arity of the tournament
-