MultiAgentDecisionProcess
Release 0.2.1
Main Page
Namespaces
Classes
Files
File List
File Members
JointObservationHistory.cpp
Go to the documentation of this file.
1
28
#include "
JointObservationHistory.h
"
29
#include "
JointObservation.h
"
30
//Necessary as header file contains a forward declaration:
31
#include "
PlanningUnitMADPDiscrete.h
"
32
#include "
ObservationHistoryTree.h
"
33
34
using namespace
std;
35
36
#define DEBUG_JOH 0
37
38
//Default constructor
39
JointObservationHistory::JointObservationHistory
(
PlanningUnitMADPDiscrete
& pu) :
40
Referrer
<
PlanningUnitMADPDiscrete
>(pu)
41
{
42
SetLength
(0);
43
_m_jointObservationI
= 0;
44
_m_containsEmptyJOI
=
true
;
45
_m_pred
= 0;
46
size_t
nrAgents = pu.
GetNrAgents
();
47
_m_individualObservationHistories
= vector<Index>(nrAgents,0);
48
}
49
50
51
/*Creates a observation history specifying jObsI for the last joint
52
* observation and pred as the preceeding JointObservationHistory.*/
53
JointObservationHistory::JointObservationHistory
(
Index
joI,
54
JointObservationHistory
* pred) :
55
Referrer
<
PlanningUnitMADPDiscrete
>( pred->GetReferred() )
56
{
57
SetLength
(pred->
GetLength
() + 1);
58
_m_jointObservationI
= joI;
59
_m_containsEmptyJOI
=
false
;
60
_m_pred
= pred;
61
size_t
nrAgents = pred->
_m_individualObservationHistories
.size();
62
63
const
vector<Index>& indivOIndices =
GetReferred
()->
64
JointToIndividualObservationIndices(joI);
65
66
//we also maintain the indices of the individual observation histories
67
//represented by this joint observation history
68
for
(
Index
aI=0; aI < nrAgents; aI++)
69
{
70
//get the individual observation history for the predecessor
71
Index
predOHindex_ai = pred->
_m_individualObservationHistories
[aI];
72
ObservationHistoryTree
* oht_ai =
GetReferred
()->
73
GetObservationHistoryTree(aI, predOHindex_ai);
74
Index
ai_last_observation = indivOIndices[aI];
75
Index
sucOHindex_ai =
76
oht_ai->
GetSuccessor
(ai_last_observation)->
77
GetIndex();
78
_m_individualObservationHistories
.push_back(sucOHindex_ai);
79
}
80
}
81
82
//Copy assignment constructor.
83
JointObservationHistory::JointObservationHistory
(
const
JointObservationHistory
& o)
84
{
85
if
(
DEBUG_JOH
){ cout <<
"Cloning JointObservationHistory: "
;
86
Print
(); cout <<endl;}
87
}
88
//Destructor
89
JointObservationHistory::~JointObservationHistory
()
90
{
91
if
(
DEBUG_JOH
){ cout <<
"Deleting JointObservationHistory: "
;
92
Print
(); cout <<endl;}
93
94
_m_individualObservationHistories
.clear();
95
}
96
const
vector<Index>&
JointObservationHistory::GetIndividualObservationHistoryIndices
()
const
97
{
98
return
(
_m_individualObservationHistories
);
99
}
100
101
string
JointObservationHistory::SoftPrint
()
const
102
{
103
stringstream ss;
104
if
(
_m_pred
!= 0)
105
{
106
if
(
_m_length
>= 1)
107
ss <<
_m_pred
->
SoftPrint
();
108
else
109
{
110
ss <<
"JointObservationHistory:Print() - Warning:_m_pred != "
<<
111
"null, but lenght <= 1 !"
<<endl;
112
throw
E
(ss);
113
}
114
}
115
116
if
(!
_m_containsEmptyJOI
)
// don't print the empty observation
117
{
118
ss <<
GetReferred
()->
GetJointObservation
(
119
_m_jointObservationI
)->
SoftPrintBrief
() <<
", "
;
120
}
121
else
122
ss <<
"JOnull, "
;
123
124
return
(ss.str());
125
}
src
support
JointObservationHistory.cpp
Generated on Mon Sep 23 2013 14:50:06 for MultiAgentDecisionProcess by
1.8.1.2