AIToolbox
A library that offers tools for AI problem solving.
Policy.hpp
Go to the documentation of this file.
1 #ifndef AI_TOOLBOX_POMDP_POLICY_HEADER_FILE
2 #define AI_TOOLBOX_POMDP_POLICY_HEADER_FILE
3 
4 #include <tuple>
5 
8 
9 namespace AIToolbox::POMDP {
26  class Policy : public PolicyInterface<size_t, Belief, size_t> {
27  public:
40  Policy(size_t s, size_t a, size_t o);
41 
55  Policy(size_t s, size_t a, size_t o, const ValueFunction & v);
56 
57  // This may be implemented, but probably not since it would be mostly impossible to convert
58  // from a POMDP policy format to another.
59  // Policy(const PolicyInterface<Belief> & p);
60 
71  virtual size_t sampleAction(const Belief & b) const override;
72 
95  std::tuple<size_t, size_t> sampleAction(const Belief & b, unsigned horizon) const;
96 
138  std::tuple<size_t, size_t> sampleAction(size_t id, size_t o, unsigned horizon) const;
139 
148  virtual double getActionProbability(const Belief & b, const size_t & a) const override;
149 
160  double getActionProbability(const Belief & b, size_t a, unsigned horizon) const;
161 
167  size_t getO() const;
168 
184  size_t getH() const;
185 
191  const ValueFunction & getValueFunction() const;
192 
193  private:
194  // H holds the available max horizon for this Policy.
195  size_t O, H;
196 
197  ValueFunction policy_;
198 
199  friend std::istream& operator>>(std::istream &is, Policy & p);
200  };
201 }
202 
203 #endif
AIToolbox::POMDP
Definition: AMDP.hpp:14
AIToolbox::POMDP::Policy::getO
size_t getO() const
This function returns the number of observations possible for the agent.
AIToolbox::POMDP::Policy::Policy
Policy(size_t s, size_t a, size_t o)
Basic constrctor.
AIToolbox::POMDP::Policy::getH
size_t getH() const
This function returns the highest horizon available within this Policy.
AIToolbox::POMDP::Policy::getActionProbability
virtual double getActionProbability(const Belief &b, const size_t &a) const override
This function returns the probability of taking the specified action in the specified belief.
AIToolbox::PolicyInterface
This class represents the base interface for policies.
Definition: PolicyInterface.hpp:31
AIToolbox::POMDP::Policy::sampleAction
virtual size_t sampleAction(const Belief &b) const override
This function chooses a random action for belief b, following the policy distribution.
PolicyInterface.hpp
AIToolbox::POMDP::ValueFunction
std::vector< VList > ValueFunction
Definition: Types.hpp:78
Types.hpp
AIToolbox::POMDP::Policy::operator>>
friend std::istream & operator>>(std::istream &is, Policy &p)
This function reads a policy from a file.
AIToolbox::POMDP::Policy
This class represents a POMDP Policy.
Definition: Policy.hpp:26
AIToolbox::POMDP::Belief
ProbabilityVector Belief
This represents a belief, which is a probability distribution over states.
Definition: Types.hpp:12
AIToolbox::POMDP::Policy::getValueFunction
const ValueFunction & getValueFunction() const
This function returns the internally stored ValueFunction.