GEGELATI
Loading...
Searching...
No Matches
selector.h
1
36#ifndef SELECTOR_H
37#define SELECTOR_H
38
39#include "learn/evaluationResult.h"
40#include "mutator/rng.h"
41#include "selector/selectionContext.h"
42#include "selector/selectionMetrics.h"
43#include "selector/selectionParameters.h"
44#include "tpg/tpgGraph.h"
45
46namespace Selector {
47
53 {
54 protected:
56 std::shared_ptr<TPG::TPGGraph> graph;
57
60
63 std::pair<const TPG::TPGVertex*,
64 std::shared_ptr<Learn::EvaluationResult>>
65 bestRoot{nullptr, nullptr};
66
80 std::map<const TPG::TPGVertex*,
81 std::shared_ptr<Learn::EvaluationResult>>
83
94
95 public:
103 Selector(std::shared_ptr<TPG::TPGGraph> graph,
104 const Learn::LearningParameters& params)
105 : graph{graph}, params{params}
106 {
107 }
108
120 virtual void launchSelection(
121 std::multimap<std::shared_ptr<Learn::EvaluationResult>,
122 const TPG::TPGVertex*>& results,
123 Mutator::RNG& rng);
124
138 virtual void doSelection(
139 std::multimap<std::shared_ptr<Learn::EvaluationResult>,
140 const TPG::TPGVertex*>& results,
141 Mutator::RNG& rng);
142
149 virtual std::shared_ptr<SelectionMetrics> createSelectionMetrics();
150
157 virtual void keepBestPolicy();
158
179 virtual void updateEvaluationRecords(
180 const std::multimap<std::shared_ptr<Learn::EvaluationResult>,
181 const TPG::TPGVertex*>& results);
182
188 virtual void updateResultsPerRoot(
189 const std::multimap<std::shared_ptr<Learn::EvaluationResult>,
190 const TPG::TPGVertex*>& results);
191
212 virtual void updateBestRoot(
213 const std::multimap<std::shared_ptr<Learn::EvaluationResult>,
214 const TPG::TPGVertex*>& results);
215
224 virtual const std::pair<const TPG::TPGVertex*,
225 std::shared_ptr<Learn::EvaluationResult>>&
226 getBestRoot() const;
227
233 virtual std::shared_ptr<TPG::TPGGraph> getGraph();
234
243 virtual void forgetPreviousResults();
244
248 virtual const std::map<const TPG::TPGVertex*,
249 std::shared_ptr<Learn::EvaluationResult>>&
250 getResultsPerRoot() const;
251
260 virtual const SelectionContext& updateContext();
261
267 virtual void updateAfterPopulate() {
268 /* Empty because sub-class does not need to inherrit from it.*/
269 };
270 };
271}; // namespace Selector
272
273#endif // SELECTION_H
Definition rng.h:52
SelectionContext context
context used by the TPGMutator to populate the TPGGraph.
Definition selector.h:93
std::map< const TPG::TPGVertex *, std::shared_ptr< Learn::EvaluationResult > > resultsPerRoot
Map associating root TPG::TPGVertex to their EvaluationResult.
Definition selector.h:82
const Learn::LearningParameters & params
Parameters for the selection.
Definition selector.h:59
virtual void updateAfterPopulate()
Method to call at the end of TPGMutator::populateTPG.
Definition selector.h:267
std::shared_ptr< TPG::TPGGraph > graph
TPGGraph on which the TPGVertex can be selected or deleted.
Definition selector.h:56
Selector(std::shared_ptr< TPG::TPGGraph > graph, const Learn::LearningParameters &params)
Constructor for Selector.
Definition selector.h:103
Abstract class representing the vertices of a TPGGraph.
Definition tpgVertex.h:55
Definition mapElitesArchiveLogger.h:45
Structure for simplifying the transmission of LearningParameters to functions.
Definition learningParameters.h:56
Structure to interface between the selector and the TPGMutator.
Definition selectionContext.h:50