GEGELATI

Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
Selector::TournamentSelector Class Reference

Selection class that will do a selection with a tournament. More...

`#include <tournamentSelector.h>`

Inheritance diagram for Selector::TournamentSelector:

## Public Member Functions
| TournamentSelector (std::shared_ptr< TPG::TPGGraph > graph, const Learn::LearningParameters &params)
| Constructor for Selector.
virtual void | launchSelection (std::multimap< std::shared_ptr< Learn::EvaluationResult >, const TPG::TPGVertex * > &results, Mutator::RNG &rng) override
| override of doSelection method.
virtual void | doSelection (std::multimap< std::shared_ptr< Learn::EvaluationResult >, const TPG::TPGVertex * > &results, Mutator::RNG &rng) override
| override of doSelection method
void | addToVerticesToDelete (const TPG::TPGVertex *vertex)
| add a vertex to the verticesToDelete set.
virtual const SelectionContext & | updateContext () override
| Specialization of updateContext for tournament purposes.
virtual void | updateAfterPopulate () override
| Specialization of updateAfterPopulate for tournament purposes.
virtual const std::set< const TPG::TPGVertex * > & | getVerticesToDelete ()
| getter of the verticesToDelete set.
Public Member Functions inherited from Selector::Selector
| Selector (std::shared_ptr< TPG::TPGGraph > graph, const Learn::LearningParameters &params)
| Constructor for Selector.
virtual std::shared_ptr< SelectionMetrics > | createSelectionMetrics ()
virtual void | keepBestPolicy ()
| This method keeps only the bes tRoot policy in the TPGGraph.
virtual void | updateEvaluationRecords (const std::multimap< std::shared_ptr< Learn::EvaluationResult >, const TPG::TPGVertex * > &results)
| Update the bestRoot and resultsPerRoot attributes.
virtual void | updateResultsPerRoot (const std::multimap< std::shared_ptr< Learn::EvaluationResult >, const TPG::TPGVertex * > &results)
| Update the resultsPerRoot.
virtual void | updateBestRoot (const std::multimap< std::shared_ptr< Learn::EvaluationResult >, const TPG::TPGVertex * > &results)
| Update the bestRoot attribute.
virtual const std::pair< const TPG::TPGVertex *, std::shared_ptr< Learn::EvaluationResult > > & | getBestRoot () const
| Get the best root TPG::Vertex encountered since the last init.
virtual std::shared_ptr< TPG::TPGGraph > | getGraph ()
| Getter for the TPGGraph built by the LearningAgent.
virtual void | forgetPreviousResults ()
| This method resets the previous registered scores per root.
virtual const std::map< const TPG::TPGVertex *, std::shared_ptr< Learn::EvaluationResult > > & | getResultsPerRoot () const
| Return the resultsPerRoot map.

## Protected Attributes
std::set< const TPG::TPGVertex * > | verticesToDelete
| set of TPGVertex filled during the selection process, containing the vertices that went through the tournament en survived it. The TPGVertex in the set will be deleted at the end of the TPGMutator::PopulateTPG method.
Protected Attributes inherited from Selector::Selector
std::shared_ptr< TPG::TPGGraph > | graph
| TPGGraph on which the TPGVertex can be selected or deleted.
const Learn::LearningParameters & | params
| Parameters for the selection.
std::pair< const TPG::TPGVertex *, std::shared_ptr< Learn::EvaluationResult > > | bestRoot {nullptr, nullptr}
std::map< const TPG::TPGVertex *, std::shared_ptr< Learn::EvaluationResult > > | resultsPerRoot
| Map associating root TPG::TPGVertex to their EvaluationResult.
SelectionContext | context
| context used by the TPGMutator to populate the TPGGraph.

## Detailed Description

Selection class that will do a selection with a tournament.

A small proportion X of the best agents is kept and saved from the tournament, X is an hyperparameter.

The remaining of the population is randomly put in tournament tables of size Y, Y is an hyperparameter. The best agents of each tournment is selected, the others are deleted.

During mutation process, the best agents saved are not used in the mutation process, only the survivors of the tournament. However this survivors are deleted after the offspring creation.

## Constructor & Destructor Documentation

## ◆ TournamentSelector()

Selector::TournamentSelector::TournamentSelector | ( | std::shared_ptr< TPG::TPGGraph > | graph,
|  | const Learn::LearningParameters & | params )
| inline

Constructor for Selector.

Parameters

  [in] | graph | shared pointer of the graph on which the selection is done.
  [in] | params | parameters used by the Selector.

## Member Function Documentation

## ◆ addToVerticesToDelete()

void Selector::TournamentSelector::addToVerticesToDelete | ( | const TPG::TPGVertex * | vertex | ) |

add a vertex to the verticesToDelete set.

Parameters

  [in] | vertex | TPGVertex added to the vertices to remove

## ◆ doSelection()

void Selector::TournamentSelector::doSelection | ( | std::multimap< std::shared_ptr< Learn::EvaluationResult >, const TPG::TPGVertex * > & | results,
|  | Mutator::RNG & | rng )
| override virtual

override of doSelection method

A small proportion X of the best agents is kept and saved from the tournament, X is an hyperparameter.

The remaining of the population is randomly put in tournament tables of size Y, Y is an hyperparameter. The best agents of each tournment is selected, the others are deleted.

During mutation process, the best agents saved are not used in the mutation process, only the survivors of the tournament. However this survivors are deleted after the offspring creation.

The tournament selection is not secured when the ratioTeamOverAction is between 0 and 1 It can be used, but it could happen that one "population" take over the other one

Parameters

  [in,out] | results | a multimap containing root TPGVertex associated to their score during an evaluation.
  [in] | rng | Random Number Generator used in the mutation process.

Reimplemented from Selector::Selector.

## ◆ launchSelection()

void Selector::TournamentSelector::launchSelection | ( | std::multimap< std::shared_ptr< Learn::EvaluationResult >, const TPG::TPGVertex * > & | results,
|  | Mutator::RNG & | rng )
| override virtual

override of doSelection method.

Reset the verticesToDelete list

Parameters

  [in,out] | results | a multimap containing root TPGVertex associated to their score during an evaluation.
  [in] | rng | Random Number Generator used in the mutation process.

Reimplemented from Selector::Selector.

## ◆ updateAfterPopulate()

void Selector::TournamentSelector::updateAfterPopulate | ( |  | ) |
| override virtual

Specialization of updateAfterPopulate for tournament purposes.

This method erase the agents that have survived the tournaments and have generated new offsprings.

Reimplemented from Selector::Selector.

## ◆ updateContext()

const Selector::SelectionContext & Selector::TournamentSelector::updateContext | ( |  | ) |
| override virtual

Specialization of updateContext for tournament purposes.

The method will remove the elite agents from the clonableVertices vectors, and will remove the not elite agents from the preExistingVertices vectors

Reimplemented from Selector::Selector.

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

- D:/a/gegelati/gegelati/gegelatilib/include/selector/tournamentSelector.h
- D:/a/gegelati/gegelati/gegelatilib/src/selector/tournamentSelector.cpp