AIToolbox
A library that offers tools for AI problem solving.
QMDP.hpp
Go to the documentation of this file.
1 #ifndef AI_TOOLBOX_POMDP_QMDP_HEADER_FILE
2 #define AI_TOOLBOX_POMDP_QMDP_HEADER_FILE
3 
7 
9 
10 namespace AIToolbox::POMDP {
40  class QMDP {
41  public:
52  QMDP(unsigned horizon, double tolerance = 0.001);
53 
73  template <IsModel M>
74  std::tuple<double, ValueFunction, MDP::QFunction> operator()(const M & m);
75 
91  static VList fromQFunction(size_t O, const MDP::QFunction & qfun);
92 
106  void setTolerance(double t);
107 
113  void setHorizon(unsigned h);
114 
120  double getTolerance() const;
121 
127  unsigned getHorizon() const;
128 
129  private:
130  MDP::ValueIteration solver_;
131  };
132 
133  template <IsModel M>
134  std::tuple<double, ValueFunction, MDP::QFunction> QMDP::operator()(const M & m) {
135  auto solution = solver_(m);
136 
137  const size_t S = m.getS();
138 
139  auto v = makeValueFunction(S);
140  v.emplace_back(fromQFunction(m.getO(), std::get<2>(solution)));
141 
142  return std::make_tuple(std::get<0>(solution), v, std::move(std::get<2>(solution)));
143  }
144 }
145 
146 #endif
AIToolbox::POMDP
Definition: AMDP.hpp:14
AIToolbox::MDP::QFunction
Matrix2D QFunction
Definition: Types.hpp:52
TypeTraits.hpp
AIToolbox::POMDP::VList
std::vector< VEntry > VList
Definition: Types.hpp:77
AIToolbox::POMDP::QMDP::getHorizon
unsigned getHorizon() const
This function returns the current horizon parameter.
ValueIteration.hpp
AIToolbox::POMDP::makeValueFunction
ValueFunction makeValueFunction(size_t S)
This function creates a default ValueFunction.
AIToolbox::POMDP::QMDP::operator()
std::tuple< double, ValueFunction, MDP::QFunction > operator()(const M &m)
This function applies the QMDP algorithm on the input POMDP.
Definition: QMDP.hpp:134
AIToolbox::POMDP::QMDP::QMDP
QMDP(unsigned horizon, double tolerance=0.001)
Basic constructor.
AIToolbox::POMDP::QMDP::getTolerance
double getTolerance() const
This function returns the currently set tolerance parameter.
Types.hpp
AIToolbox::MDP::ValueIteration
This class applies the value iteration algorithm on a Model.
Definition: ValueIteration.hpp:27
AIToolbox::POMDP::QMDP::setHorizon
void setHorizon(unsigned h)
This function sets the horizon parameter.
AIToolbox::POMDP::QMDP::setTolerance
void setTolerance(double t)
This function sets the tolerance parameter.
AIToolbox::POMDP::QMDP
This class implements the QMDP algorithm.
Definition: QMDP.hpp:40
Utils.hpp
AIToolbox::POMDP::QMDP::fromQFunction
static VList fromQFunction(size_t O, const MDP::QFunction &qfun)
This function converts an MDP::QFunction into the equivalent POMDP VList.