Tournament selection operator. More...
#include <shark/Algorithms/DirectSearch/Operators/Selection/TournamentSelection.h>
Public Member Functions | |
TournamentSelection (std::size_t size=2) | |
template<typename IteratorType1 , typename IteratorType2 > | |
void | operator() (random::rng_type &rng, IteratorType1 inIt, IteratorType1 inItE, IteratorType2 outIt, IteratorType2 outItE) |
template<typename Iterator > | |
Iterator | operator() (random::rng_type &rng, Iterator it, Iterator itE) const |
Selects an individual from the range of individuals with prob. proportional to its fitness. More... | |
Public Attributes | |
std::size_t | tournamentSize |
Size of the tournament. 2 by default. More... | |
Tournament selection operator.
Selects k individuals at random and returns the best. By default k is 2. The Template parameter represents a Predicate that compares two individuals. It is assumed that this is transitive, that is pred(a,b) = true && pred(b,c) == true => pred(a,c) == true. Possible predicates could compare fitness values or the rank of the two individuals.
The size of the tournament can either be set in the constructor or by setting the variable tournamentSize
Definition at line 50 of file TournamentSelection.h.
|
inline |
Definition at line 51 of file TournamentSelection.h.
References shark::TournamentSelection< Predicate >::tournamentSize.
|
inline |
Definition at line 56 of file TournamentSelection.h.
|
inline |
Selects an individual from the range of individuals with prob. proportional to its fitness.
[in] | it | Iterator pointing to the first valid element. |
[in] | itE | Iterator pointing to the first invalid element. |
Definition at line 73 of file TournamentSelection.h.
std::size_t shark::TournamentSelection< Predicate >::tournamentSize |
Size of the tournament. 2 by default.
Definition at line 92 of file TournamentSelection.h.
Referenced by shark::TournamentSelection< Predicate >::TournamentSelection().