shark::TournamentSelection< Predicate > Struct Template Reference

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...
 

Detailed Description

template<class Predicate>
struct shark::TournamentSelection< Predicate >

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.

Constructor & Destructor Documentation

◆ TournamentSelection()

template<class Predicate>
shark::TournamentSelection< Predicate >::TournamentSelection ( std::size_t  size = 2)
inline

Member Function Documentation

◆ operator()() [1/2]

template<class Predicate>
template<typename IteratorType1 , typename IteratorType2 >
void shark::TournamentSelection< Predicate >::operator() ( random::rng_type &  rng,
IteratorType1  inIt,
IteratorType1  inItE,
IteratorType2  outIt,
IteratorType2  outItE 
)
inline

Definition at line 56 of file TournamentSelection.h.

◆ operator()() [2/2]

template<class Predicate>
template<typename Iterator >
Iterator shark::TournamentSelection< Predicate >::operator() ( random::rng_type &  rng,
Iterator  it,
Iterator  itE 
) const
inline

Selects an individual from the range of individuals with prob. proportional to its fitness.

Parameters
[in]itIterator pointing to the first valid element.
[in]itEIterator pointing to the first invalid element.
Returns
An iterator pointing to the selected individual.

Definition at line 73 of file TournamentSelection.h.

Member Data Documentation

◆ tournamentSize

template<class Predicate>
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().


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