Ultra 0.9.4
Loading...
Searching...
No Matches
ultra::replacement::tournament< E > Class Template Reference

#include <evolution_replacement.h>

Inheritance diagram for ultra::replacement::tournament< E >:
ultra::replacement::strategy< E >

Public Member Functions

template<Population P>
bool operator() (P &, const scored_t &, status_t &) const
template<Population P>
bool operator() (P &pop, const scored_t &offspring, status_t &status) const
template<SizedRandomAccessPopulation P>
std::vector< typename tournament< E >::scored_t > operator() (const P &pop) const
template<SizedRandomAccessPopulation P>
std::vector< typename tournament< E >::scored_t > operator() (const P &pop) const
Public Member Functions inherited from ultra::replacement::strategy< E >
 strategy (E &, const parameters &)

Additional Inherited Members

Public Types inherited from ultra::replacement::strategy< E >
using individual_t = evaluator_individual_t<E>
using fitness_t = evaluator_fitness_t<E>
using scored_t = scored_individual<individual_t, fitness_t>
using status_t = evolution_status<individual_t, fitness_t>
Protected Attributes inherited from ultra::replacement::strategy< E >
E & eva_
const parameters & params_

Detailed Description

template<Evaluator E>
class ultra::replacement::tournament< E >

Tournament based replacement scheme (aka kill tournament).

This strategy select an individual for replacement by kill tournament: pick a number of individuals at random and replace the worst.

See also
https://github.com/morinim/ultra/wiki/bibliography#24

Member Function Documentation

◆ operator()() [1/4]

template<Evaluator E>
template<SizedRandomAccessPopulation P>
std::vector< typename tournament< E >::scored_t > ultra::replacement::tournament< E >::operator() ( const P & pop) const
Parameters
[in]popa population
Returns
a collection of scored individuals ordered in descending fitness
Precondition
Parameters must have been initialised (no auto-tune values)

Tournament selection works by selecting a number of individuals from the population at random (a tournament) and then choosing only the best of those individuals. Recall that better individuals have higher fitness.

Used parameters: evolution.mate_zone, evolution.tournament_size.

Remarks
Different compilers may optimize the code producing slightly different sortings (due to floating point approximations). This is a known issue. Anyway we keep using the < operator because:
  • it's faster than the std::fabs(delta) approach;
  • the additional noise is marginal (for the GA/GP standard);
  • for debugging purposes compiler-stability is enough (and we have faith in the test suite).
Warning
This function assumes exclusive access to the population. If other threads can change the individuals, race conditions may happen.

◆ operator()() [2/4]

template<Evaluator E>
template<SizedRandomAccessPopulation P>
std::vector< typename tournament< E >::scored_t > ultra::replacement::tournament< E >::operator() ( const P & pop) const
Parameters
[in]popa population
Returns
a collection of scored individuals ordered in descending fitness
Precondition
Parameters must have been initialised (no auto-tune values)

Tournament selection works by selecting a number of individuals from the population at random (a tournament) and then choosing only the best of those individuals. Recall that better individuals have higher fitness.

Used parameters: evolution.mate_zone, evolution.tournament_size.

Remarks
Different compilers may optimize the code producing slightly different sortings (due to floating point approximations). This is a known issue. Anyway we keep using the < operator because:
  • it's faster than the std::fabs(delta) approach;
  • the additional noise is marginal (for the GA/GP standard);
  • for debugging purposes compiler-stability is enough (and we have faith in the test suite).
Warning
This function assumes exclusive access to the population. If other threads can change the individuals, race conditions may happen.

◆ operator()() [3/4]

template<Evaluator E>
template<Population P>
bool ultra::replacement::tournament< E >::operator() ( P & pop,
const scored_t & offspring,
status_t & status ) const
Parameters
[in]popa population
[in]offspringthe scored child to be considered for replacement
[out]statuscurrent evolution status

Used parameters:

  • evolution.elitism;
  • evolution.tournament_size;

◆ operator()() [4/4]

template<Evaluator E>
template<Population P>
bool ultra::replacement::tournament< E >::operator() ( P & pop,
const scored_t & offspring,
status_t & status ) const
Parameters
[in]popa population
[in]offspringthe scored child to be considered for replacement
[out]statuscurrent evolution status

Used parameters:

  • evolution.elitism;
  • evolution.tournament_size;

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