MultiAgentDecisionProcess
Release 0.2.1
Main Page
Namespaces
Classes
Files
File List
File Members
PerseusStationary.cpp
Go to the documentation of this file.
1
28
#include "
PerseusStationary.h
"
29
#include "
argumentHandlers.h
"
30
31
using namespace
std;
32
33
//Default constructor
34
PerseusStationary::PerseusStationary
(
const
PlanningUnitDecPOMDPDiscrete
& pu) :
35
AlphaVectorPlanning
(pu),
36
Perseus
(pu)
37
{
38
}
39
40
//Destructor
41
PerseusStationary::~PerseusStationary
()
42
{
43
if
(
_m_beliefsInitialized
)
44
delete
(
_m_beliefs
);
45
}
46
47
double
PerseusStationary::GetQ
(
const
JointBeliefInterface
&b,
Index
jaI)
const
48
{
49
return
(
BeliefValue::GetValue
(b,
_m_qFunction
[jaI]));
50
}
51
52
double
PerseusStationary::GetQ
(
const
JointBeliefInterface
&b,
Index
jaI,
53
int
&betaMaxI)
const
54
{
55
Index
maxI=
BeliefValue::
56
GetMaximizingVectorIndex
(b,
_m_qFunction
[jaI]);
57
betaMaxI=
_m_qFunction
[jaI][maxI].GetBetaI();
58
return
(b.
InnerProduct
(
_m_qFunction
[jaI][maxI].GetValues()));
59
}
60
61
double
PerseusStationary::GetQ
(
const
JointBeliefInterface
&b,
Index
t,
62
Index
jaI)
const
63
{
64
throw
(
E
(
"PerseusStationary::GetQ not implemented for non-stationary case"
));
65
return
(42);
66
}
67
68
double
PerseusStationary::GetQ
(
const
JointBeliefInterface
&b,
Index
t,
69
Index
jaI,
int
&betaMaxI)
const
70
{
71
throw
(
E
(
"PerseusStationary::GetQ not implemented for non-stationary case"
));
72
return
(42);
73
}
74
77
void
PerseusStationary::SetBeliefSet
(
const
BeliefSet
&S)
78
{
79
if
(
_m_beliefsInitialized
)
80
delete
(
_m_beliefs
);
81
_m_beliefs
=
new
BeliefSet
(S);
82
_m_beliefsInitialized
=
true
;
83
}
84
85
void
PerseusStationary::ExportBeliefSet
(
const
string
&filename)
const
86
{
87
if
(!
_m_beliefsInitialized
)
88
{
89
cout <<
"PerseusStationary::ExportBeliefSet: belief set not set"
90
<< endl;
91
}
92
else
93
AlphaVectorPlanning::ExportBeliefSet
(*
_m_beliefs
,filename);
94
}
95
97
void
PerseusStationary::ExportValueFunction
(
const
string
&filename)
const
98
{
99
AlphaVectorPlanning::ExportValueFunction
(filename,
_m_valueFunction
);
100
}
101
102
std::vector<double>
PerseusStationary::GetImmediateRewardBeliefSet
()
const
103
{
104
return
(
BeliefValue::GetValues
(*
_m_beliefs
,
105
AlphaVectorPlanning
::
106
GetImmediateRewardValueFunction
(
GetPU
())));
107
}
108
110
void
PerseusStationary::SetValueFunction
(
const
string
&filename)
111
{
112
_m_valueFunction
=
ImportValueFunction
(filename);
113
_m_qFunction
=
AlphaVectorPlanning::
114
ValueFunctionToQ
(
_m_valueFunction
,
115
GetPU
()->GetNrJointActions(),
116
GetPU
()->GetNrStates());
117
}
118
119
void
PerseusStationary::InitializeBeliefs
(
int
nrB,
bool
uniquify)
120
{
121
ArgumentHandlers::Arguments
args;
122
args.
nrBeliefs
=nrB;
123
args.
uniqueBeliefs
=uniquify;
124
SetBeliefSet
(
SampleBeliefs
(args));
125
}
126
127
void
PerseusStationary::StoreValueFunction
(
const
ValueFunctionPOMDPDiscrete
&V)
128
{
129
// store the resulting value function
130
_m_valueFunction
=V;
131
// compute the Q functions from the value function
132
_m_qFunction
=
ValueFunctionToQ
(
_m_valueFunction
);
133
}
134
135
void
PerseusStationary::StoreValueFunction
(
const
QFunctionsDiscrete
&Q)
136
{
137
// store the resulting Q function and the value function
138
_m_qFunction
=Q;
139
_m_valueFunction
.clear();
140
for
(
QFDcit
i=Q.begin();i!=Q.end();++i)
141
for
(
VFPDcit
j=i->begin();j!=i->end();++j)
142
if
(j->GetAction()!=INT_MAX)
143
_m_valueFunction
.push_back(*j);
144
}
src
planning
PerseusStationary.cpp
Generated on Mon Sep 23 2013 14:50:05 for MultiAgentDecisionProcess by
1.8.1.2