|
GEGELATI
|
Selection class that will do a selection with a tournament. More...
#include <tournamentSelector.h>
Public Member Functions | |
| TournamentSelector (std::shared_ptr< TPG::TPGGraph > graph, const Learn::LearningParameters ¶ms) | |
| 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 ¶ms) | |
| 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. | |
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.
|
inline |
| void Selector::TournamentSelector::addToVerticesToDelete | ( | const TPG::TPGVertex * | vertex | ) |
add a vertex to the verticesToDelete set.
| [in] | vertex | TPGVertex added to the vertices to remove |
|
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
| [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.
|
overridevirtual |
override of doSelection method.
Reset the verticesToDelete list
| [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.
|
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.
|
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.