GALib-Parallel
Header-only C++ library for parallel evolutionary algorithms
Loading...
Searching...
No Matches
Public Member Functions | List of all members
galib::TournamentSelection< GeneType > Class Template Reference

Performs k-way tournament selection. More...

#include <TournamentSelection.h>

Inheritance diagram for galib::TournamentSelection< GeneType >:
[legend]

Public Member Functions

 TournamentSelection (size_t tournament_size)
 Constructs the selector.
 
std::size_t getTournamentSize () const
 
const Individual< GeneType > & select (const Population< GeneType > &population) override
 Conducts a tournament and returns the winner.
 
- Public Member Functions inherited from galib::Selection< GeneType >
virtual ~Selection ()=default
 

Detailed Description

template<typename GeneType>
class galib::TournamentSelection< GeneType >

Performs k-way tournament selection.

Randomly samples k individuals from the population and returns the one with the best fitness. Higher tournament sizes result in higher selection pressure.

Template Parameters
GeneTypeThe numeric type of the genes.

Definition at line 23 of file TournamentSelection.h.

Constructor & Destructor Documentation

◆ TournamentSelection()

template<typename GeneType >
galib::TournamentSelection< GeneType >::TournamentSelection ( size_t  tournament_size)
inlineexplicit

Constructs the selector.

Parameters
tournament_sizeNumber of candidates per tournament. Must be >= 1.
Exceptions
std::invalid_argumentif tournament_size is 0.

Definition at line 32 of file TournamentSelection.h.

Member Function Documentation

◆ getTournamentSize()

template<typename GeneType >
std::size_t galib::TournamentSelection< GeneType >::getTournamentSize ( ) const
inline

Definition at line 38 of file TournamentSelection.h.

◆ select()

template<typename GeneType >
const Individual< GeneType > & galib::TournamentSelection< GeneType >::select ( const Population< GeneType > &  population)
inlineoverridevirtual

Conducts a tournament and returns the winner.

Parameters
populationSource population.
Returns
Reference to the fittest individual in the sampled group.

Implements galib::Selection< GeneType >.

Definition at line 45 of file TournamentSelection.h.

References galib::Individual< GeneType >::getFitness(), and galib::Population< GeneType >::size().


The documentation for this class was generated from the following file: