MultiAgentDecisionProcess
Release 0.2.1
Main Page
Namespaces
Classes
Files
File List
File Members
ActionObservationHistory.cpp
Go to the documentation of this file.
1
28
#include "
ActionObservationHistory.h
"
29
#include "
Action.h
"
30
#include "
Observation.h
"
31
#include "
PlanningUnitMADPDiscrete.h
"
32
#include "
ActionHistory.h
"
33
#include "
ObservationHistoryTree.h
"
34
35
using namespace
std;
36
37
#define DEBUG_AOH 0
38
39
//Default constructor
40
ActionObservationHistory::ActionObservationHistory
(
PlanningUnitMADPDiscrete
& pu,
Index
agentI) :
41
Referrer
<
PlanningUnitMADPDiscrete
>(pu),
42
IndividualHistory
(agentI)
43
{
44
SetLength
(0);
45
_m_pred
= 0;
46
_m_ahI
= 0;
//HARDCODED
47
_m_ohI
= 0;
//HARDCODED
48
}
49
ActionObservationHistory::ActionObservationHistory
(
Index
aI,
Index
oI,
50
ActionObservationHistory
* pred) :
51
Referrer
<
PlanningUnitMADPDiscrete
>(pred->
GetReferred
()),
52
IndividualHistory
(pred->
_m_agentI
)
53
{
54
SetLength
(pred->
GetLength
() + 1);
55
_m_pred
= pred;
56
_m_ahI
=
57
GetReferred
()->
GetActionHistoryTree
(
_m_agentI
, pred->
_m_ahI
)
//=aht
58
->GetSuccessor(aI)
//=aht'
59
->GetIndex();
//=ahI'
60
_m_ohI
=
61
GetReferred
()->
GetObservationHistoryTree
(
_m_agentI
, pred->
_m_ohI
)
//=oht
62
->
GetSuccessor
(oI)
//=oht'
63
->
GetIndex
();
//=ohI'
64
}
65
66
string
ActionObservationHistory::SoftPrint
()
const
67
{
68
stringstream ss;
69
if
(
_m_pred
!= 0)
70
{
71
if
(
_m_length
>= 1)
72
ss <<
_m_pred
->
SoftPrint
();
73
else
74
{
75
ss <<
"ObservationHistory:Print() - Warning:_m_pred != "
<<
76
"null, but lenght < 1 !"
<<endl;
77
throw
E
(ss);
78
}
79
}
80
81
ActionHistory
* ah =
GetReferred
()->
GetActionHistoryTree
(
82
_m_agentI
,
_m_ahI
)
//=aht
83
->GetContainedElement();
//=ah
84
if
(!ah->
IsEmpty
())
// don't print the empty observation
85
{
86
ss <<
", "
;
87
Index
aI = ah->
GetLastActionIndex
();
// aI
88
ss <<
GetReferred
()->
GetAction
(
_m_agentI
, aI)->
SoftPrintBrief
();
89
}
90
else
91
ss <<
"EMPTY_AH"
;
92
93
ss <<
", "
;
94
95
ObservationHistory
* oh =
GetReferred
()->
GetObservationHistoryTree
(
96
_m_agentI
,
_m_ohI
)
//=oht
97
->
GetContainedElement
();
//=oh
98
if
(!oh->
ContainsEmptyOI
())
// don't print the empty observation
99
{
100
ss <<
", "
;
101
Index
oI = oh->
GetLastObservationIndex
();
// oI
102
ss <<
GetReferred
()->
GetObservation
(
_m_agentI
, oI)->
SoftPrintBrief
();
103
}
104
else
105
ss <<
"Oempty"
;
106
107
return
(ss.str());
108
}
src
support
ActionObservationHistory.cpp
Generated on Mon Sep 23 2013 14:50:06 for MultiAgentDecisionProcess by
1.8.1.2