MultiAgentDecisionProcess
Release 0.2.1
Main Page
Namespaces
Classes
Files
File List
File Members
ActionHistory.cpp
Go to the documentation of this file.
1
28
#include "
ActionHistory.h
"
29
#include "
Action.h
"
30
//Necessary as header file contains a forward declaration:
31
#include "
PlanningUnitMADPDiscrete.h
"
32
33
using namespace
std;
34
35
#define DEBUG_AH 0
36
37
//Default constructor
38
ActionHistory::ActionHistory
(
PlanningUnitMADPDiscrete
& pu,
39
Index
agentI) :
40
Referrer
<
PlanningUnitMADPDiscrete
>(pu),
41
IndividualHistory
(agentI)
42
{
43
SetLength
(0);
44
_m_actionI
= 0;
45
_m_isEmpty
=
true
;
46
_m_pred
= 0;
47
}
48
49
ActionHistory::ActionHistory
(
Index
aI,
ActionHistory
* pred):
50
Referrer
<
PlanningUnitMADPDiscrete
>( pred->GetReferred() ),
51
IndividualHistory
(pred->_m_agentI)
52
{
53
SetLength
(pred->
GetLength
() + 1);
54
_m_actionI
= aI;
55
_m_isEmpty
=
false
;
56
_m_pred
= pred;
57
}
58
59
//Destructor
60
ActionHistory::~ActionHistory
()
61
{
62
if
(
DEBUG_AH
){ cout <<
"Deleting action history: "
;
63
Print
(); cout << endl;}
64
}
65
66
string
ActionHistory::SoftPrint
()
const
67
{
68
stringstream ss;
69
if
(
_m_pred
!= 0)
70
{
71
//if the predec. is the empty action sequence (with length 0)
72
//we don't want to print this. (and this is the case when
73
//this action history has length 1)
74
if
(
_m_length
>= 1)
75
ss <<
_m_pred
->
SoftPrint
();
76
else
if
(
_m_length
< 1)
77
{
78
ss <<
"ActionHistory:Print() - Warning:_m_pred != "
<<
79
"null, but lenght < 1 !"
<<endl;
80
throw
E
(ss);
81
}
82
//else length == 1 and we simply skip
83
}
84
85
if
(!
_m_isEmpty
)
// don't print the empty action
86
{
87
ss << (
GetReferred
()->
GetAction
(
_m_agentI
,
88
_m_actionI
))->SoftPrintBrief();
89
ss <<
", "
;
90
}
91
else
92
ss <<
"EMPTY_AH"
;
93
94
return
(ss.str());
95
96
}
src
support
ActionHistory.cpp
Generated on Mon Sep 23 2013 14:50:06 for MultiAgentDecisionProcess by
1.8.1.2