GEGELATI

Loading...
Searching...
No Matches
learningEnvironment.h
1
37#ifndef LEARNING_ENVIRONMENT_H
38#define LEARNING_ENVIRONMENT_H
39
40#include "data/dataHandler.h"
41#include <cstdint>
42#include <vector>
43
44 namespace Learn {
45
58 enum class LearningMode
59 {
60 TRAINING,
61 VALIDATION,
62 TESTING
63 };
64
80 class LearningEnvironment
81 {
82 protected:
85 const uint64_t nbActions;
86
88 LearningEnvironment(const LearningEnvironment& other) = default;
89
92 const bool isDiscreteEnvironment;
93
96 const std::vector<uint64_t> initActions;
97
98 public:
102 LearningEnvironment() = delete;
103
105 virtual ~LearningEnvironment() = default;
106
118 LearningEnvironment(
119 uint64_t nbAct, bool isDiscreteEnv = true,
120 const std::vector<uint64_t>& initAct = std::vector<uint64_t>())
121 : nbActions{nbAct}, isDiscreteEnvironment{isDiscreteEnv},
122 initActions{initAct.empty() && !isDiscreteEnv
123 ? std::vector<uint64_t>(nbAct, 0)
124 : initAct} {};
125
134 virtual LearningEnvironment* clone() const;
135
143 virtual bool isCopyable() const;
144
152 virtual bool isUsingUtility() const;
153
160 uint64_t getNbActions() const
161 {
162 return this->nbActions;
163 };
164
171 const std::vector<uint64_t>& getInitActions() const
172 {
173 return initActions;
174 };
175
182 const bool isDiscrete() const
183 {
184 return isDiscreteEnvironment;
185 }
186
201 virtual void doAction(double actionID);
202
223 virtual void doActions(std::vector<double> vectActionID);
224
245 virtual void reset(size_t seed = 0,
246 LearningMode mode = LearningMode::TRAINING,
247 uint16_t iterationNumber = 0,
248 uint64_t generationNumber = 0) = 0;
249
265 virtual std::vector<std::reference_wrapper<const Data::DataHandler>>
266 getDataSources() = 0;
267
276 virtual double getScore() const = 0;
277
285 virtual double getUtility() const;
286
301 virtual bool isTerminal() const = 0;
302 };
303}; // namespace Learn
304
305#endif
Learn::LearningEnvironment
Interface for creating a Learning Environment.
Definition learningEnvironment.h:81
Learn::LearningEnvironment::isCopyable
virtual bool isCopyable() const
Can the LearningEnvironment be copy constructed to evaluate several LearningAgent in parallel.
Definition learningEnvironment.cpp:47
Learn::LearningEnvironment::LearningEnvironment
LearningEnvironment()=delete
Delete the default constructor of a LearningEnvironment.
Learn::LearningEnvironment::nbActions
const uint64_t nbActions
Definition learningEnvironment.h:85
Learn::LearningEnvironment::getDataSources
virtual std::vector< std::reference_wrapper< const Data::DataHandler > > getDataSources()=0
Get the data sources for this LearningEnvironment.
Learn::LearningEnvironment::reset
virtual void reset(size_t seed=0, LearningMode mode=LearningMode::TRAINING, uint16_t iterationNumber=0, uint64_t generationNumber=0)=0
Reset the LearningEnvironment.
Learn::LearningEnvironment::LearningEnvironment
LearningEnvironment(const LearningEnvironment &other)=default
Make the default copy constructor protected.
Learn::LearningEnvironment::isTerminal
virtual bool isTerminal() const =0
Method for checking if the LearningEnvironment has reached a terminal state.
Learn::LearningEnvironment::getUtility
virtual double getUtility() const
Returns the current utility of the Environment.
Definition learningEnvironment.cpp:93
Learn::LearningEnvironment::isUsingUtility
virtual bool isUsingUtility() const
Is the LearningEnvrionment using a utility in addition to the reward. Information needed for the logs...
Definition learningEnvironment.cpp:52
Learn::LearningEnvironment::LearningEnvironment
LearningEnvironment(uint64_t nbAct, bool isDiscreteEnv=true, const std::vector< uint64_t > &initAct=std::vector< uint64_t >())
Constructor for LearningEnviroment.
Definition learningEnvironment.h:118
Learn::LearningEnvironment::getInitActions
const std::vector< uint64_t > & getInitActions() const
Get the vector of initial actions available for this LearningEnvironment.
Definition learningEnvironment.h:171
Learn::LearningEnvironment::getNbActions
uint64_t getNbActions() const
Get the number of actions available for this LearningEnvironment.
Definition learningEnvironment.h:160
Learn::LearningEnvironment::isDiscreteEnvironment
const bool isDiscreteEnvironment
Definition learningEnvironment.h:92
Learn::LearningEnvironment::doActions
virtual void doActions(std::vector< double > vectActionID)
Execute actions on the LearningEnvironment.
Definition learningEnvironment.cpp:71
Learn::LearningEnvironment::initActions
const std::vector< uint64_t > initActions
Definition learningEnvironment.h:96
Learn::LearningEnvironment::doAction
virtual void doAction(double actionID)
Execute an action on the LearningEnvironment.
Definition learningEnvironment.cpp:57
Learn::LearningEnvironment::isDiscrete
const bool isDiscrete() const
Get the information of the nature of the environment action type.
Definition learningEnvironment.h:182
Learn::LearningEnvironment::getScore
virtual double getScore() const =0
Returns the current score of the Environment.
Learn::LearningEnvironment::~LearningEnvironment
virtual ~LearningEnvironment()=default
Default virtual destructor.
Learn::LearningEnvironment::clone
virtual LearningEnvironment * clone() const
Get a copy of the LearningEnvironment.
Definition learningEnvironment.cpp:42
Learn
Definition classificationLearningEnvironment.h:44
Learn::LearningMode
LearningMode
Different modes in which the LearningEnvironment can be reset.
Definition learningEnvironment.h:59