AIToolbox
A library that offers tools for AI problem solving.
QL.hpp
Go to the documentation of this file.
1 #ifndef AI_TOOLBOX_MDP_QL_HEADER_FILE
2 #define AI_TOOLBOX_MDP_QL_HEADER_FILE
3 
5 
6 namespace AIToolbox::MDP {
16  class QL : public OffPolicyControl<QL> {
17  public:
19 
31  QL(const size_t s, const size_t a, const double discount = 1.0, const double alpha = 0.1,
32  const double lambda = 0.1, const double tolerance = 0.001, const double epsilon = 0.1) :
33  Parent(s, a, discount, alpha, tolerance, epsilon)
34  {
35  setLambda(lambda);
36  }
37 
46  void setLambda(double l) {
47  if ( l < 0.0 || l > 1.0 ) throw std::invalid_argument("Lambda parameter must be in [0,1]");
48  lambda_ = l;
49  }
50 
54  double getLambda() const { return lambda_; }
55 
56  private:
57  friend Parent;
61  double getTraceDiscount(const size_t, const size_t, const size_t, const double, const size_t) const {
62  return lambda_;
63  }
64 
65  double lambda_;
66  };
67 
83  class QLEvaluation : public OffPolicyEvaluation<QLEvaluation> {
84  public:
86 
96  QLEvaluation(const PolicyInterface & target, const double discount,
97  const double alpha, const double lambda, const double tolerance) :
98  Parent(target, discount, alpha, tolerance)
99  {
100  setLambda(lambda);
101  }
102 
111  void setLambda(double l) {
112  if ( l < 0.0 || l > 1.0 ) throw std::invalid_argument("Lambda parameter must be in [0,1]");
113  lambda_ = l;
114  }
115 
119  double getLambda() const { return lambda_; }
120 
121  private:
122  friend Parent;
126  double getTraceDiscount(const size_t, const size_t, const size_t, const double) const {
127  return lambda_;
128  }
129 
130  double lambda_;
131  };
132 }
133 
134 #endif
AIToolbox::MDP::OffPolicyControl
This class is a general version of off-policy control.
Definition: OffPolicyTemplate.hpp:294
AIToolbox::MDP::QLEvaluation
This class implements off-policy evaluation via Q(lambda).
Definition: QL.hpp:83
OffPolicyTemplate.hpp
AIToolbox::MDP::QL::Parent
OffPolicyControl< QL > Parent
Definition: QL.hpp:18
AIToolbox::MDP
Definition: DoubleQLearning.hpp:10
AIToolbox::MDP::QL
This class implements off-policy control via Q(lambda).
Definition: QL.hpp:16
AIToolbox::MDP::OffPolicyEvaluation
This class is a general version of off-policy evaluation.
Definition: OffPolicyTemplate.hpp:215
AIToolbox::MDP::QLEvaluation::QLEvaluation
QLEvaluation(const PolicyInterface &target, const double discount, const double alpha, const double lambda, const double tolerance)
Basic constructor.
Definition: QL.hpp:96
AIToolbox::MDP::QL::QL
QL(const size_t s, const size_t a, const double discount=1.0, const double alpha=0.1, const double lambda=0.1, const double tolerance=0.001, const double epsilon=0.1)
Basic constructor.
Definition: QL.hpp:31
AIToolbox::MDP::QL::setLambda
void setLambda(double l)
This function sets the new lambda parameter.
Definition: QL.hpp:46
AIToolbox::MDP::QLEvaluation::getLambda
double getLambda() const
This function returns the currently set lambda parameter.
Definition: QL.hpp:119
AIToolbox::MDP::QL::getLambda
double getLambda() const
This function returns the currently set lambda parameter.
Definition: QL.hpp:54
AIToolbox::MDP::PolicyInterface
Simple typedef for most of MDP's policy needs.
Definition: PolicyInterface.hpp:11
AIToolbox::MDP::QLEvaluation::setLambda
void setLambda(double l)
This function sets the new lambda parameter.
Definition: QL.hpp:111
AIToolbox::MDP::QLEvaluation::Parent
OffPolicyEvaluation< QLEvaluation > Parent
Definition: QL.hpp:85