MultiAgentDecisionProcess  Release 0.2.1
ObservationHistory.cpp
Go to the documentation of this file.
1 
28 #include "Observation.h"
29 #include "ObservationHistory.h"
30 //Necessary as header file contains a forward declaration:
32 
33 using namespace std;
34 
35 #define DEBUG_OH 0
36 
37 //Default constructor
39  Index agentI) :
41  IndividualHistory(agentI)
42 {
43  SetLength(0);
44  _m_observationI = 0;
45  _m_containsEmptyOI = true;
46  _m_pred = 0;
47 }
48 
50  IndividualHistory(agentI)
51 {
52  throw E("ObservationHistory::ObservationHistory(Index obsI) not yet implemented - non-empty initial observations not yet supported.");
53 }
54 
56  Referrer<PlanningUnitMADPDiscrete>( pred->GetReferred() ),
57  IndividualHistory(pred->_m_agentI)
58 {
59  SetLength(pred->GetLength() + 1);
60  _m_observationI = obsI;
61  _m_containsEmptyOI = false;
62  _m_pred = pred;
63 }
64 
65 //Destructor
67 {
68 if(DEBUG_OH){ cout << "Deleting observation history: ";
69  Print(); cout << endl;}
70 }
71 
73 {
74  stringstream ss;
75  if(_m_pred != 0)
76  {
77  if(_m_length >= 1)
78  ss << _m_pred->SoftPrint();
79  else
80  throw E("ObservationHistory:SoftPrint() - Warning:_m_pred != null,\
81  but lenght <= 1 !");
82  }
83  if (!_m_containsEmptyOI) // don't print the empty observation
84  {
85 // ss << GetReferred()->GetObservationDiscrete(_m_agentI,
86 // let's see if this works...
88  _m_observationI)->SoftPrintBrief() << ", ";
89  }
90  else
91  ss << "Oempty, ";
92 
93  return(ss.str());
94 }