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
13namespace Selector {
14
20 {
21 protected:
23 std::shared_ptr<TPG::TPGGraph> graph;
24
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>>
50
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
Definition rng.h:52
SelectionContext context
context used by the TPGMutator to populate the TPGGraph.
Definition selector.h:60
std::map< const TPG::TPGVertex *, std::shared_ptr< Learn::EvaluationResult > > resultsPerRoot
Map associating root TPG::TPGVertex to their EvaluationResult.
Definition selector.h:49
const Learn::LearningParameters & params
Parameters for the selection.
Definition selector.h:26
virtual void updateAfterPopulate()
Method to call at the end of TPGMutator::populateTPG.
Definition selector.h:234
std::shared_ptr< TPG::TPGGraph > graph
TPGGraph on which the TPGVertex can be selected or deleted.
Definition selector.h:23
Selector(std::shared_ptr< TPG::TPGGraph > graph, const Learn::LearningParameters &params)
Constructor for Selector.
Definition selector.h:70
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:55
Structure to interface between the selector and the TPGMutator.
Definition selectionContext.h:17