Package org.apache.commons.math.genetics
Class TournamentSelection
- java.lang.Object
-
- org.apache.commons.math.genetics.TournamentSelection
-
- All Implemented Interfaces:
SelectionPolicy
public class TournamentSelection extends java.lang.Object implements SelectionPolicy
Tournament selection scheme. Each of the two selected chromosomes is selected based on n-ary tournament -- this is done by drawingarity
random chromosomes without replacement from the population, and then selecting the fittest chromosome among them.- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description TournamentSelection(int arity)
Creates a new TournamentSelection instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getArity()
Gets the arity (number of chromosomes drawn to the tournament).ChromosomePair
select(Population population)
Select two chromosomes from the population.void
setArity(int arity)
Sets the arity (number of chromosomes drawn to the tournament).
-
-
-
Method Detail
-
select
public ChromosomePair select(Population population)
Select two chromosomes from the population. Each of the two selected chromosomes is selected based on n-ary tournament -- this is done by drawingarity
random chromosomes without replacement from the population, and then selecting the fittest chromosome among them.- Specified by:
select
in interfaceSelectionPolicy
- Parameters:
population
- the population from which the chromosomes are choosen.- Returns:
- the selected chromosomes.
-
getArity
public int getArity()
Gets the arity (number of chromosomes drawn to the tournament).- Returns:
- arity of the tournament
-
setArity
public void setArity(int arity)
Sets the arity (number of chromosomes drawn to the tournament).- Parameters:
arity
- arity of the tournament
-
-