MultiAgentDecisionProcess  Release 0.2.1
MADPComponentDiscreteObservations.h
Go to the documentation of this file.
1 
28 /* Only include this header file once. */
29 #ifndef _MADPCOMPONENTDISCRETEOBSERVATIONS_H_
30 #define _MADPCOMPONENTDISCRETEOBSERVATIONS_H_ 1
31 
32 /* the include directives */
33 #include <iostream>
34 #include <sstream>
35 #include "Globals.h"
38 #include "ObservationDiscrete.h"
39 #include "IndexTools.h"
40 #include <map>
41 
42 namespace {
43  typedef std::vector<ObservationDiscrete> ObservationDVec;
44 }
45 
53  virtual public MultiAgentDecisionProcessDiscreteInterface //which this implements partly
54 {
55  private:
56 
61 
64 
66 
67  std::vector<JointObservationDiscrete*> _m_jointObservationVec;
68 
72  std::map<Index, std::vector<Index> *> *_m_jointObservationIndices;
73 
77 
78  std::string SoftPrintObservationSets() const;
79  std::string SoftPrintJointObservationSet() const;
80 
81  protected:
83  std::vector<size_t> _m_nrObservations;
86  std::vector<std::vector<ObservationDiscrete> > _m_observationVecs;
87 
88  public:
89  // Constructor, destructor and copy assignment.
94 
95  //operators:
96 
97  //data manipulation (set) functions:
99  bool SetInitialized(bool b);
100 
102  void SetNrObservations(Index AI, size_t nrO);
103 
105  void AddObservation(Index AI, std::string name);
106 
109 
110  //get (data) functions:
111 
113  const std::vector<size_t>& GetNrObservations() const
114  {return _m_nrObservations;}
115 
117  size_t GetNrObservations(Index AgentI) const;
118 
120  size_t GetNrJointObservations() const;
121 
123  Index GetObservationIndexByName(std::string s, Index agentI) const;
124 
126  std::string GetObservationName(Index o, Index i) const {
127  return(_m_observationVecs.at(i).at(o).GetName()); }
128 
130  std::string GetJointObservationName(Index o) const {
131  return(_m_jointObservationVec.at(o)->SoftPrint()); }
132 
135  Index a) const;
136 
138  const Observation* GetObservation(Index agentI, Index a) const
139  {return( (Observation*) GetObservationDiscrete(agentI,a) );}
140 
143 
146  const;
147 
151  Index IndividualToJointObservationIndices(const std::vector<Index>&
152  indivObservationIndices)const;
153 
156  const std::vector<Index>&
158  {
160  {
161  throw(E("MADPComponentDiscreteActions::JointToIndividualActionIndices() joint indices are not available, overflow detected"));
162  }
164  return GetJointObservationDiscrete(joI)->
165  GetIndividualObservationDiscretesIndices();
166  else if(_m_jointObservationIndices->find(joI)!=
168  return(*_m_jointObservationIndices->find(joI)->second);
169  else // create new
170  {
171  std::vector<Index> *indices=new std::vector<Index>();
174  _m_jointObservationIndices->insert(make_pair(joI,indices));
175  return(*indices);
176  }
177  }
178 
179  std::string SoftPrint() const;
180  void Print() const
181  {std::cout << SoftPrint();}
182 };
183 
184 
185 #endif /* !_MADPCOMPONENTDISCRETEOBSERVATIONS_H_ */
186 
187 
188 // Local Variables: ***
189 // mode:c++ ***
190 // End: ***