Scheduler
stateSpaceDimension.h
Go to the documentation of this file.
1 
10 #ifndef MDPSTATESPACEDIMENSION_H
11 #define MDPSTATESPACEDIMENSION_H
12 
13 #include <memory>
14 #include <string>
15 #include <stdexcept>
16 
17 namespace Mdp
18 {
19 typedef int statePosition_t; //TODO: make this unsigned
20 
21 class DomainModel;
22 class StateSpaceBuilder;
23 class StateSpace;
24 
30 {
31 friend StateSpace; /*TODO: is this line necessary?*/
32 friend StateSpaceBuilder;
33 public:
34  virtual ~StateSpaceDimension(){};
37  virtual std::string getName()=0;
41  virtual statePosition_t getPosition()=0;
44  virtual size_t getNumberOfPositions()=0;
45  void setIndex(int i);
46  int getIndex();
47 protected:
48  template<typename T>
49  std::shared_ptr<T> getModel()
50  {
51  std::shared_ptr<T> model = std::dynamic_pointer_cast<T>(domainModel);
52  if (model == nullptr)
53  throw std::runtime_error("inconsistent domain model type");
54  return model;
55  }
56  int index;
57  std::shared_ptr<DomainModel> domainModel{nullptr};
58 };
59 
60 
61 
62 
63 
64 
66 {
67 public:
68  static constexpr const char *configKey = "FOR TEST PURPOSE ONLY";
69 public:
71  std::string getName(){return TestOnlyDimension::configKey;};
72  statePosition_t getPosition(){return -1;};
73  size_t getNumberOfPositions(){return nbPos;};
74  void setNumberOfPositions(int n){nbPos = n;};
75 private:
76  size_t nbPos{1};
77 };
78 
79 
80 
81 
82 }
83 #endif
std::shared_ptr< DomainModel > domainModel
virtual statePosition_t getPosition()=0
gets the position of the state along that dimension
virtual std::string getName()=0
returns the name of that dimension
std::string getName()
returns the name of that dimension
static constexpr const char * configKey
std::shared_ptr< T > getModel()
virtual size_t getNumberOfPositions()=0
returns the number of possible positions along that dimension
size_t getNumberOfPositions()
returns the number of possible positions along that dimension
Definition: action.h:18
int statePosition_t
statePosition_t getPosition()
gets the position of the state along that dimension
this models a dimension in the state space.
builds a domain specific state space