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:
Selector::Selector

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 SelectionContextupdateContext () 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< SelectionMetricscreateSelectionMetrics ()
 
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::TPGGraphgetGraph ()
 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::TPGGraphgraph
 TPGGraph on which the TPGVertex can be selected or deleted.
 
const Learn::LearningParametersparams
 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]graphshared pointer of the graph on which the selection is done.
[in]paramsparameters 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]vertexTPGVertex 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 )
overridevirtual

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]resultsa multimap containing root TPGVertex associated to their score during an evaluation.
[in]rngRandom 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 )
overridevirtual

override of doSelection method.

Reset the verticesToDelete list

Parameters
[in,out]resultsa multimap containing root TPGVertex associated to their score during an evaluation.
[in]rngRandom Number Generator used in the mutation process.

Copyright or © or Copr. IETR/INSA - Rennes (2025) :

Quentin Vacher qvach.nosp@m.er@i.nosp@m.nsa-r.nosp@m.enne.nosp@m.s.fr (2025)

GEGELATI is an open-source reinforcement learning framework for training artificial intelligence based on Tangled Program Graphs (TPGs).

This software is governed by the CeCILL-C license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL-C license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info".

As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability.

In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security.

The fact that you are presently reading this means that you have had knowledge of the CeCILL-C license and that you accept its terms.

Reimplemented from Selector::Selector.

◆ updateAfterPopulate()

void Selector::TournamentSelector::updateAfterPopulate ( )
overridevirtual

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 ( )
overridevirtual

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: