AIToolbox
A library that offers tools for AI problem solving.
GenerativeModelPython.hpp
Go to the documentation of this file.
1 #ifndef AI_TOOLBOX_MDP_GENERATIVE_MODEL_PYTHON_HEADER_FILE
2 #define AI_TOOLBOX_MDP_GENERATIVE_MODEL_PYTHON_HEADER_FILE
3 
4 #include <boost/python.hpp>
5 #include <boost/python/object.hpp>
6 
7 namespace AIToolbox::MDP {
16  public:
33  GenerativeModelPython(boost::python::object instance) :
34  instance_(instance) {}
35 
39  size_t getS() const { return boost::python::extract<size_t>(instance_.attr("getS")()); }
40 
44  size_t getA() const { return boost::python::extract<size_t>(instance_.attr("getA")()); }
45 
49  double getDiscount() const { return boost::python::extract<double>(instance_.attr("getDiscount")()); }
50 
54  bool isTerminal(const size_t s) const { return boost::python::extract<bool>(instance_.attr("isTerminal")(s)); }
55 
59  std::tuple<size_t, double> sampleSR(const size_t s, const size_t a) const {
60  return boost::python::extract<std::tuple<size_t, double>>(instance_.attr("sampleSR")(s, a));
61  }
62 
63  private:
64  boost::python::object instance_;
65  };
66 }
67 
68 #endif
AIToolbox::MDP::GenerativeModelPython::getDiscount
double getDiscount() const
This function returns the discount of the environment.
Definition: GenerativeModelPython.hpp:49
AIToolbox::MDP::GenerativeModelPython::sampleSR
std::tuple< size_t, double > sampleSR(const size_t s, const size_t a) const
This function returns a tuple containing a new state and reward, from the input state and action.
Definition: GenerativeModelPython.hpp:59
AIToolbox::MDP::GenerativeModelPython::getS
size_t getS() const
This function returns the number of states of the environment.
Definition: GenerativeModelPython.hpp:39
AIToolbox::MDP::GenerativeModelPython::isTerminal
bool isTerminal(const size_t s) const
This function returns whether a given state is a terminal state.
Definition: GenerativeModelPython.hpp:54
AIToolbox::MDP
Definition: DoubleQLearning.hpp:10
AIToolbox::MDP::GenerativeModelPython
This class allows to import generative models from Python.
Definition: GenerativeModelPython.hpp:15
AIToolbox::MDP::GenerativeModelPython::GenerativeModelPython
GenerativeModelPython(boost::python::object instance)
Basic constructor.
Definition: GenerativeModelPython.hpp:33
AIToolbox::MDP::GenerativeModelPython::getA
size_t getA() const
This function returns the number of actions of the environment.
Definition: GenerativeModelPython.hpp:44