GEGELATI

Loading...
Searching...
No Matches
selector.h
1
2
3#ifndef SELECTOR_H
4#define SELECTOR_H
5
6#include "learn/evaluationResult.h"
7#include "mutator/rng.h"
8#include "selector/selectionContext.h"
9#include "selector/selectionMetrics.h"
10#include "selector/selectionParameters.h"
11#include "tpg/tpgGraph.h"
12
13 namespace Selector {
14
19 class Selector
20 {
21 protected:
23 std::shared_ptr<TPG::TPGGraph> graph;
24
26 const Learn::LearningParameters& params;
27
30 std::pair<const TPG::TPGVertex*,
31 std::shared_ptr<Learn::EvaluationResult>>
32 bestRoot{nullptr, nullptr};
33
47 std::map<const TPG::TPGVertex*,
48 std::shared_ptr<Learn::EvaluationResult>>
49 resultsPerRoot;
50
60 SelectionContext context;
61
62 public:
70 Selector(std::shared_ptr<TPG::TPGGraph> graph,
71 const Learn::LearningParameters& params)
72 : graph{graph}, params{params}
73 {
74 }
75
87 virtual void launchSelection(
88 std::multimap<std::shared_ptr<Learn::EvaluationResult>,
89 const TPG::TPGVertex*>& results,
90 Mutator::RNG& rng);
91
105 virtual void doSelection(
106 std::multimap<std::shared_ptr<Learn::EvaluationResult>,
107 const TPG::TPGVertex*>& results,
108 Mutator::RNG& rng);
109
116 virtual std::shared_ptr<SelectionMetrics> createSelectionMetrics();
117
124 virtual void keepBestPolicy();
125
146 virtual void updateEvaluationRecords(
147 const std::multimap<std::shared_ptr<Learn::EvaluationResult>,
148 const TPG::TPGVertex*>& results);
149
155 virtual void updateResultsPerRoot(
156 const std::multimap<std::shared_ptr<Learn::EvaluationResult>,
157 const TPG::TPGVertex*>& results);
158
179 virtual void updateBestRoot(
180 const std::multimap<std::shared_ptr<Learn::EvaluationResult>,
181 const TPG::TPGVertex*>& results);
182
191 virtual const std::pair<const TPG::TPGVertex*,
192 std::shared_ptr<Learn::EvaluationResult>>&
193 getBestRoot() const;
194
200 virtual std::shared_ptr<TPG::TPGGraph> getGraph();
201
210 virtual void forgetPreviousResults();
211
215 virtual const std::map<const TPG::TPGVertex*,
216 std::shared_ptr<Learn::EvaluationResult>>&
217 getResultsPerRoot() const;
218
227 virtual const SelectionContext& updateContext();
228
234 virtual void updateAfterPopulate() {
235 /* Empty because sub-class does not need to inherrit from it.*/
236 };
237 };
238}; // namespace Selector
239
240#endif // SELECTION_H
Mutator::RNG
Definition rng.h:52
Selector::Selector::context
SelectionContext context
context used by the TPGMutator to populate the TPGGraph.
Definition selector.h:60
Selector::Selector::resultsPerRoot
std::map< const TPG::TPGVertex *, std::shared_ptr< Learn::EvaluationResult > > resultsPerRoot
Map associating root TPG::TPGVertex to their EvaluationResult.
Definition selector.h:49
Selector::Selector::params
const Learn::LearningParameters & params
Parameters for the selection.
Definition selector.h:26
Selector::Selector::updateAfterPopulate
virtual void updateAfterPopulate()
Method to call at the end of TPGMutator::populateTPG.
Definition selector.h:234
Selector::Selector::graph
std::shared_ptr< TPG::TPGGraph > graph
TPGGraph on which the TPGVertex can be selected or deleted.
Definition selector.h:23
Selector::Selector::Selector
Selector(std::shared_ptr< TPG::TPGGraph > graph, const Learn::LearningParameters &params)
Constructor for Selector.
Definition selector.h:70
TPG::TPGVertex
Abstract class representing the vertices of a TPGGraph.
Definition tpgVertex.h:55
Selector
Definition mapElitesArchiveLogger.h:45
Learn::LearningParameters
Structure for simplifying the transmission of LearningParameters to functions.
Definition learningParameters.h:55
Selector::SelectionContext
Structure to interface between the selector and the TPGMutator.
Definition selectionContext.h:17