Module io.jenetics.base
Package io.jenetics
Class TournamentSelector<G extends Gene<?,G>,C extends Comparable<? super C>>  
java.lang.Object
io.jenetics.TournamentSelector<G,C> 
- All Implemented Interfaces:
 Selector<G,C> 
public class TournamentSelector<G extends Gene<?,G>,C extends Comparable<? super C>>  
extends Object
implements Selector<G,C> 
In tournament selection the best individual from a random sample of s
 individuals is chosen from the population Pg. The samples
 are drawn with replacement. An individual will win a tournament only if its
 fitness is greater than the fitness of the other s-1  competitors.
 Note that the worst individual never survives, and the best individual wins
 in all the tournaments it participates. The selection pressure can be varied
 by changing the tournament size s . For large values of s, weak
 individuals have less chance being selected.
- Since:
 - 1.0
 - Version:
 - 6.0
 - See Also:
 
- 
Constructor Summary
ConstructorsConstructorDescriptionCreate a tournament selector with sample size two.TournamentSelector(int sampleSize) Create a tournament selector with the give sample size.TournamentSelector(Comparator<? super Phenotype<G, C>> comparator, int sampleSize) Create a tournament selector with the givecomparatorand sample size. - 
Method Summary
 
- 
Constructor Details
- 
TournamentSelector
Create a tournament selector with the givecomparatorand sample size. The sample size must be greater than one.- Parameters:
 comparator- the comparator use for comparing two individuals during a tournamentsampleSize- the number of individuals involved in one tournament- Throws:
 IllegalArgumentException- if the sample size is smaller than twoNullPointerException- if the givencomparatorisnull- Since:
 - 6.0
 
 - 
TournamentSelector
Create a tournament selector with the give sample size. The sample size must be greater than one.- Parameters:
 sampleSize- the number of individuals involved in one tournament- Throws:
 IllegalArgumentException- if the sample size is smaller than two.
 - 
TournamentSelector
public TournamentSelector()Create a tournament selector with sample size two. 
 - 
 - 
Method Details
- 
sampleSize
Return the sample size of the tournament selector.- Returns:
 - the sample size of the tournament selector
 - Since:
 - 5.0
 
 - 
select
Description copied from interface:SelectorSelect phenotypes from the Population.- Specified by:
 selectin interfaceSelector<G extends Gene<?,G>, C extends Comparable<? super C>> - Parameters:
 population- The population to select from.count- The number of phenotypes to select.opt- Determines whether the individuals with higher fitness values or lower fitness values must be selected. This parameter determines whether the GA maximizes or minimizes the fitness function.- Returns:
 - The selected phenotypes (a new Population).
 
 - 
toString
 
 -