AIToolbox
A library that offers tools for AI problem solving.
WoLFPolicy.hpp
Go to the documentation of this file.
1 #ifndef AI_TOOLBOX_MDP_WOLF_POLICY_HEADER_FILE
2 #define AI_TOOLBOX_MDP_WOLF_POLICY_HEADER_FILE
3 
4 #include <vector>
5 
8 
9 namespace AIToolbox::MDP {
25  class WoLFPolicy : public QPolicyInterface {
26  public:
37  WoLFPolicy(const QFunction & q, double deltaw = 0.0125, double deltal = 0.05, double scaling = 5000.0);
38 
47  void stepUpdateP(size_t s);
48 
59  virtual size_t sampleAction(const size_t & s) const override;
60 
69  virtual double getActionProbability(const size_t & s, const size_t & a) const override;
70 
78  virtual Matrix2D getPolicy() const override;
79 
88  void setDeltaW(double deltaW);
89 
95  double getDeltaW() const;
96 
105  void setDeltaL(double deltaL);
106 
112  double getDeltaL() const;
113 
129  void setScaling(double scaling);
130 
136  double getScaling() const;
137 
138  private:
139  double deltaW_, deltaL_, scaling_;
140 
141  std::vector<unsigned> c_;
142  PolicyWrapper::PolicyMatrix avgPolicyMatrix_, actualPolicyMatrix_;
143  PolicyWrapper avgPolicy_, actualPolicy_;
144  };
145 }
146 
147 #endif
AIToolbox::MDP::WoLFPolicy::getDeltaW
double getDeltaW() const
This function returns the current learning rate during winning.
QPolicyInterface.hpp
AIToolbox::MDP::QPolicyInterface
This class is an interface to specify a policy through a QFunction.
Definition: QPolicyInterface.hpp:20
AIToolbox::MDP::WoLFPolicy::getScaling
double getScaling() const
This function returns the current scaling parameter.
AIToolbox::MDP::WoLFPolicy
This class implements the WoLF learning algorithm.
Definition: WoLFPolicy.hpp:25
AIToolbox::MDP::QFunction
Matrix2D QFunction
Definition: Types.hpp:52
AIToolbox::MDP::WoLFPolicy::stepUpdateP
void stepUpdateP(size_t s)
This function updates the WoLF policy based on changes in the QFunction.
AIToolbox::MDP::WoLFPolicy::setScaling
void setScaling(double scaling)
This function modifies the scaling parameter.
AIToolbox::Matrix2D
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor|Eigen::AutoAlign > Matrix2D
Definition: Types.hpp:18
AIToolbox::MDP::WoLFPolicy::getPolicy
virtual Matrix2D getPolicy() const override
This function returns a matrix containing all probabilities of the policy.
AIToolbox::MDP::PolicyWrapper::PolicyMatrix
Matrix2D PolicyMatrix
Definition: PolicyWrapper.hpp:31
AIToolbox::MDP
Definition: DoubleQLearning.hpp:10
AIToolbox::MDP::PolicyWrapper
This class provides an MDP Policy interface around a Matrix2D.
Definition: PolicyWrapper.hpp:29
AIToolbox::MDP::WoLFPolicy::sampleAction
virtual size_t sampleAction(const size_t &s) const override
This function chooses an action for state s, following the policy distribution.
AIToolbox::MDP::WoLFPolicy::setDeltaW
void setDeltaW(double deltaW)
This function sets the new learning rate if winning.
PolicyWrapper.hpp
AIToolbox::MDP::WoLFPolicy::WoLFPolicy
WoLFPolicy(const QFunction &q, double deltaw=0.0125, double deltal=0.05, double scaling=5000.0)
Basic constructor.
AIToolbox::MDP::WoLFPolicy::setDeltaL
void setDeltaL(double deltaL)
This function sets the new learning rate if losing.
AIToolbox::MDP::WoLFPolicy::getDeltaL
double getDeltaL() const
This function returns the current learning rate during loss.
AIToolbox::MDP::WoLFPolicy::getActionProbability
virtual double getActionProbability(const size_t &s, const size_t &a) const override
This function returns the probability of taking the specified action in the specified state.