GEGELATI

Loading...
Searching...
No Matches
mapElitesSelector.h
1
2
3#ifndef MAP_ELITES_SELECTOR_H
4#define MAP_ELITES_SELECTOR_H
5
6#include "selector/mapElites/mapElitesArchive.h"
7#include "selector/mapElites/mapElitesDescriptor.h"
8#include "selector/mapElites/mapElitesSelectionMetrics.h"
9#include "selector/selector.h"
10
11#include "learn/learningEnvironment.h"
12
13 namespace Selector {
14 namespace MapElites {
15
23 class MapElitesSelector : public Selector
24 {
25 protected:
27 std::map<std::shared_ptr<const MapElitesDescriptor>,
28 std::shared_ptr<MapElitesArchive>>
29 mapEliteArchives;
30
31 public:
40 MapElitesSelector(std::shared_ptr<TPG::TPGGraph> graph,
41 const Learn::LearningParameters& params)
42 : Selector{graph, params}
43 {
44 }
45
51 virtual std::shared_ptr<const MapElitesArchive>
52 getMapElitesArchiveAt(
53 std::shared_ptr<const MapElitesDescriptor> descriptor);
54
58 virtual const std::map<std::shared_ptr<const MapElitesDescriptor>,
59 std::shared_ptr<MapElitesArchive>>&
60 getMapElitesArchives();
61
67 virtual std::shared_ptr<SelectionMetrics> createSelectionMetrics()
68 override;
69
78 virtual std::shared_ptr<const MapElitesArchive>
79 addArchiveFromDescriptor(
80 size_t nbBins,
81 std::shared_ptr<const MapElitesDescriptor> descriptor,
82 Learn::LearningEnvironment& le);
83
104 virtual std::shared_ptr<const MapElitesArchive>
105 addCvtArchiveFromDescriptor(
106 size_t nbCentroids,
107 std::shared_ptr<const MapElitesDescriptor> descriptor,
108 Learn::LearningEnvironment& le, Mutator::RNG& rng,
109 size_t nbIterationInit = 300, size_t nbDotsInit = 1000,
110 double a1 = 0.5, double b1 = 0.5, double a2 = 0.5,
111 double b2 = 0.5);
112
122 virtual void doSelection(
123 std::multimap<std::shared_ptr<Learn::EvaluationResult>,
124 const TPG::TPGVertex*>& results,
125 Mutator::RNG& rng) override;
126
130 virtual const SelectionContext& updateContext() override;
131 };
132 }; // namespace MapElites
133
138 using MapElitesSelector = MapElites::MapElitesSelector;
139}; // namespace Selector
140
141#endif // MAP_ELITES_SELECTOR_H
Learn::LearningEnvironment
Interface for creating a Learning Environment.
Definition learningEnvironment.h:81
Mutator::RNG
Definition rng.h:52
Selector::MapElites::MapElitesSelector
Selection class that will do a selection with a Map Elites algorithm.
Definition mapElitesSelector.h:24
Selector::MapElites::MapElitesSelector::MapElitesSelector
MapElitesSelector(std::shared_ptr< TPG::TPGGraph > graph, const Learn::LearningParameters &params)
Constructor for Selector.
Definition mapElitesSelector.h:40
Selector::MapElites::MapElitesSelector::mapEliteArchives
std::map< std::shared_ptr< const MapElitesDescriptor >, std::shared_ptr< MapElitesArchive > > mapEliteArchives
Map of descriptor to their corresponding archive.
Definition mapElitesSelector.h:29
Selector::MapElites::MapElitesSelector::doSelection
virtual void doSelection(std::multimap< std::shared_ptr< Learn::EvaluationResult >, const TPG::TPGVertex * > &results, Mutator::RNG &rng) override
override of doSelection method
Definition mapElitesSelector.cpp:79
Selector::MapElites::MapElitesSelector::getMapElitesArchiveAt
virtual std::shared_ptr< const MapElitesArchive > getMapElitesArchiveAt(std::shared_ptr< const MapElitesDescriptor > descriptor)
Get the archive corresponding to a given descriptor.
Definition mapElitesSelector.cpp:6
Selector::MapElites::MapElitesSelector::createSelectionMetrics
virtual std::shared_ptr< SelectionMetrics > createSelectionMetrics() override
Definition mapElitesSelector.cpp:24
Selector::MapElites::MapElitesSelector::getMapElitesArchives
virtual const std::map< std::shared_ptr< const MapElitesDescriptor >, std::shared_ptr< MapElitesArchive > > & getMapElitesArchives()
Get all the map elites archives.
Definition mapElitesSelector.cpp:18
Selector::MapElites::MapElitesSelector::addCvtArchiveFromDescriptor
virtual std::shared_ptr< const MapElitesArchive > addCvtArchiveFromDescriptor(size_t nbCentroids, std::shared_ptr< const MapElitesDescriptor > descriptor, Learn::LearningEnvironment &le, Mutator::RNG &rng, size_t nbIterationInit=300, size_t nbDotsInit=1000, double a1=0.5, double b1=0.5, double a2=0.5, double b2=0.5)
Add a CVT archive for a given descriptor.
Definition mapElitesSelector.cpp:60
Selector::MapElites::MapElitesSelector::updateContext
virtual const SelectionContext & updateContext() override
Specialization of updateContext for MapElites purposes.
Definition mapElitesSelector.cpp:166
Selector::MapElites::MapElitesSelector::addArchiveFromDescriptor
virtual std::shared_ptr< const MapElitesArchive > addArchiveFromDescriptor(size_t nbBins, std::shared_ptr< const MapElitesDescriptor > descriptor, Learn::LearningEnvironment &le)
Add an archive for a given descriptor.
Definition mapElitesSelector.cpp:44
Selector::Selector::params
const Learn::LearningParameters & params
Parameters for the selection.
Definition selector.h:26
Selector::Selector::graph
std::shared_ptr< TPG::TPGGraph > graph
TPGGraph on which the TPGVertex can be selected or deleted.
Definition selector.h:23
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