AIToolbox
A library that offers tools for AI problem solving.
RLearning.hpp
Go to the documentation of this file.
1 #ifndef AI_TOOLBOX_MDP_RLEARNING_HEADER_FILE
2 #define AI_TOOLBOX_MDP_RLEARNING_HEADER_FILE
3 
4 #include <stddef.h>
5 
9 
10 namespace AIToolbox::MDP {
48  class RLearning {
49  public:
61  RLearning(size_t S, size_t A, double alpha = 0.1, double rho = 0.1);
62 
78  template <IsGenerativeModel M>
79  RLearning(const M& model, double alpha = 0.1, double rho = 0.1);
80 
104  void setAlphaLearningRate(double a);
105 
111  double getAlphaLearningRate() const;
112 
124  void setRhoLearningRate(double r);
125 
131  double getRhoLearningRate() const;
132 
145  void stepUpdateQ(size_t s, size_t a, size_t s1, double rew);
146 
152  size_t getS() const;
153 
159  size_t getA() const;
160 
169  const QFunction & getQFunction() const;
170 
176  double getAverageReward() const;
177 
189  void setQFunction(const QFunction & qfun);
190 
191  private:
192  size_t S, A;
193  double alpha_, rho_;
194  double rAvg_;
195 
196  QFunction q_;
197  };
198 
199  template <IsGenerativeModel M>
200  RLearning::RLearning(const M& model, const double alpha, const double rho) :
201  RLearning(model.getS(), model.getA(), alpha, rho) {}
202 }
203 #endif
AIToolbox::MDP::RLearning::setQFunction
void setQFunction(const QFunction &qfun)
This function allows to directly set the internal QFunction.
AIToolbox::MDP::RLearning::RLearning
RLearning(size_t S, size_t A, double alpha=0.1, double rho=0.1)
Basic constructor.
AIToolbox::MDP::QFunction
Matrix2D QFunction
Definition: Types.hpp:52
AIToolbox::MDP::RLearning::stepUpdateQ
void stepUpdateQ(size_t s, size_t a, size_t s1, double rew)
This function updates the internal QFunction using the discount set during construction.
AIToolbox::MDP::RLearning::getQFunction
const QFunction & getQFunction() const
This function returns a reference to the internal QFunction.
AIToolbox::MDP::RLearning::getRhoLearningRate
double getRhoLearningRate() const
This function will return the current set rho learning rate parameter.
AIToolbox::MDP::RLearning
This class represents the RLearning algorithm.
Definition: RLearning.hpp:48
AIToolbox::MDP::RLearning::getAverageReward
double getAverageReward() const
This function returns the learned average reward.
AIToolbox::MDP::RLearning::getA
size_t getA() const
This function returns the number of actions on which QLearning is working.
AIToolbox::MDP
Definition: DoubleQLearning.hpp:10
Utils.hpp
AIToolbox::MDP::RLearning::getAlphaLearningRate
double getAlphaLearningRate() const
This function will return the current set alpha learning rate parameter.
AIToolbox::MDP::RLearning::getS
size_t getS() const
This function returns the number of states on which QLearning is working.
AIToolbox::MDP::RLearning::setAlphaLearningRate
void setAlphaLearningRate(double a)
This function sets the learning rate parameter for the QFunction.
Types.hpp
TypeTraits.hpp
AIToolbox::MDP::RLearning::setRhoLearningRate
void setRhoLearningRate(double r)
This function sets the learning rate parameter for the average reward.