GEGELATI

Loading...
Searching...
No Matches
mapElitesSelectionMetrics.h
1
2
3#ifndef MAP_ELITES_SELECTION_METRICS_H
4#define MAP_ELITES_SELECTION_METRICS_H
5
6#include <numeric>
7
8#include "selector/mapElites/mapElitesDescriptor.h"
9#include "selector/selectionMetrics.h"
10
11 namespace Selector {
12
13 namespace MapElites {
14
23 class MapElitesSelectionMetrics : public SelectionMetrics
24 {
25 protected:
31 std::map<std::shared_ptr<const MapElitesDescriptor>,
32 std::vector<double>>
33 mapDescriptors;
34
35 public:
42 MapElitesSelectionMetrics(
43 std::vector<std::shared_ptr<const MapElitesDescriptor>>
44 descriptors)
45 {
46 for (auto descriptor : descriptors) {
47 mapDescriptors.insert({descriptor, {}});
48 }
49 }
50
59 MapElitesSelectionMetrics(
60 double score,
61 const std::map<std::shared_ptr<const MapElitesDescriptor>,
62 std::vector<double>>& mapDescriptors)
63 : SelectionMetrics(score), mapDescriptors(mapDescriptors){};
64
71 MapElitesSelectionMetrics(double score) : SelectionMetrics(score){};
72
76 const std::map<std::shared_ptr<const MapElitesDescriptor>,
77 std::vector<double>>&
78 getMapDescriptors() const;
79
83 void initMetrics(
84 const TPG::TPGVertex* agent,
85 const Learn::LearningEnvironment& learningEnvironment) override;
86
91 void extractMetricsStep(
92 const TPG::TPGVertex* agent, std::vector<double> actionValues,
93 const Learn::LearningEnvironment& learningEnvironment) override;
94
99 void extractMetricsEpisode(
100 const TPG::TPGVertex* agent, size_t nbStepsExecuted,
101 const Learn::LearningEnvironment& learningEnvironment) override;
102
107 virtual void weightedSum(std::shared_ptr<SelectionMetrics> other,
108 size_t nbEvaluation,
109 size_t nbEvaluationOther) override;
110 };
111 } // namespace MapElites
112
113}; // namespace Selector
114
115#endif // MAP_ELITES_SELECTION_METRICS_H
Learn::LearningEnvironment
Interface for creating a Learning Environment.
Definition learningEnvironment.h:81
Selector::MapElites::MapElitesSelectionMetrics
Class to extract metrics from either the agent or the environment.
Definition mapElitesSelectionMetrics.h:24
Selector::MapElites::MapElitesSelectionMetrics::mapDescriptors
std::map< std::shared_ptr< const MapElitesDescriptor >, std::vector< double > > mapDescriptors
Map storing a descriptor and a Vector storing a double value per descriptor (i.e. per Action) of a cl...
Definition mapElitesSelectionMetrics.h:33
Selector::MapElites::MapElitesSelectionMetrics::MapElitesSelectionMetrics
MapElitesSelectionMetrics(std::vector< std::shared_ptr< const MapElitesDescriptor > > descriptors)
Default constructor of MapEliteselectionMetrics with a vector of descriptors.
Definition mapElitesSelectionMetrics.h:42
Selector::MapElites::MapElitesSelectionMetrics::weightedSum
virtual void weightedSum(std::shared_ptr< SelectionMetrics > other, size_t nbEvaluation, size_t nbEvaluationOther) override
Specialization of weightedSum method to add the score per class and nbEvalPerClass.
Definition mapElitesSelectionMetrics.cpp:44
Selector::MapElites::MapElitesSelectionMetrics::MapElitesSelectionMetrics
MapElitesSelectionMetrics(double score)
Constructor of MapEliteselectionMetrics with a vector of scores.
Definition mapElitesSelectionMetrics.h:71
Selector::MapElites::MapElitesSelectionMetrics::initMetrics
void initMetrics(const TPG::TPGVertex *agent, const Learn::LearningEnvironment &learningEnvironment) override
Specialization of the initialisation of the metrics.
Definition mapElitesSelectionMetrics.cpp:12
Selector::MapElites::MapElitesSelectionMetrics::getMapDescriptors
const std::map< std::shared_ptr< const MapElitesDescriptor >, std::vector< double > > & getMapDescriptors() const
Get a const ref to the scorePerClass attribute.
Definition mapElitesSelectionMetrics.cpp:7
Selector::MapElites::MapElitesSelectionMetrics::extractMetricsStep
void extractMetricsStep(const TPG::TPGVertex *agent, std::vector< double > actionValues, const Learn::LearningEnvironment &learningEnvironment) override
Specialization of the extraction of the metrics at the end of an episode.
Definition mapElitesSelectionMetrics.cpp:21
Selector::MapElites::MapElitesSelectionMetrics::MapElitesSelectionMetrics
MapElitesSelectionMetrics(double score, const std::map< std::shared_ptr< const MapElitesDescriptor >, std::vector< double > > &mapDescriptors)
Constructor of MapEliteselectionMetrics with a vector of scores.
Definition mapElitesSelectionMetrics.h:59
Selector::MapElites::MapElitesSelectionMetrics::extractMetricsEpisode
void extractMetricsEpisode(const TPG::TPGVertex *agent, size_t nbStepsExecuted, const Learn::LearningEnvironment &learningEnvironment) override
Specialization of the extraction of the metrics at the end of an episode.
Definition mapElitesSelectionMetrics.cpp:31
Selector::SelectionMetrics
Class to extract metrics from either the agent or the environment.
Definition selectionMetrics.h:18
Selector::SelectionMetrics::score
double score
Definition selectionMetrics.h:23
TPG::TPGVertex
Abstract class representing the vertices of a TPGGraph.
Definition tpgVertex.h:55
Selector
Definition mapElitesArchiveLogger.h:45