MultiAgentDecisionProcess
Release 0.2.1
Main Page
Namespaces
Classes
Files
File List
File Members
AgentPOMDP.cpp
Go to the documentation of this file.
1
28
#include "
AgentPOMDP.h
"
29
#include <float.h>
30
#include "
PlanningUnitDecPOMDPDiscrete.h
"
31
#include "
JointBeliefInterface.h
"
32
33
using namespace
std;
34
35
#define DEBUG_AgentPOMDP 0
36
37
AgentPOMDP::AgentPOMDP
(
const
PlanningUnitDecPOMDPDiscrete
&pu,
Index
id
,
38
QAV<PerseusPOMDPPlanner>
*
QPOMDP
) :
39
AgentSharedObservations
(pu,id),
40
_m_QPOMDP(QPOMDP),
41
_m_t(0)
42
{
43
_m_jb
=
GetPU
()->
GetNewJointBeliefInterface
();
44
}
45
46
AgentPOMDP::AgentPOMDP
(
const
AgentPOMDP
& a) :
47
AgentSharedObservations
(a),
48
_m_QPOMDP(a._m_QPOMDP),
49
_m_t(a._m_t),
50
_m_prevJaI(a._m_prevJaI)
51
{
52
_m_jb
=
GetPU
()->
GetNewJointBeliefInterface
();
53
*
_m_jb
=*a.
_m_jb
;
54
}
55
56
//Destructor
57
AgentPOMDP::~AgentPOMDP
()
58
{
59
delete
_m_jb
;
60
}
61
62
Index
AgentPOMDP::Act
(
Index
joI)
63
{
64
if
(
_m_t
>0)
65
_m_jb
->
Update
(*
GetPU
()->GetReferred(),
_m_prevJaI
,joI);
66
67
Index
jaInew=INT_MAX;
68
double
q,v=-DBL_MAX;
69
for
(
size_t
a=0;a!=
GetPU
()->
GetNrJointActions
();++a)
70
{
71
q=
_m_QPOMDP
->
GetQ
(*
_m_jb
,a);
72
if
(q>v)
73
{
74
v=q;
75
jaInew=a;
76
}
77
}
78
79
#if DEBUG_AgentPOMDP
80
cout <<
GetIndex
() <<
": "
;
81
_m_jb
.
Print
();
82
cout <<
" v "
<< v << endl;
83
#endif
84
85
vector<Index> aIs=
GetPU
()->
JointToIndividualActionIndices
(jaInew);
86
87
_m_prevJaI
=jaInew;
88
_m_t
++;
89
90
return
(aIs[
GetIndex
()]);
91
}
92
93
void
AgentPOMDP::ResetEpisode
()
94
{
95
_m_t
=0;
96
*
_m_jb
=*
GetPU
()->
GetNewJointBeliefFromISD
();
// isa JointBeliefInterface*
97
_m_prevJaI
=INT_MAX;
98
}
src
planning
AgentPOMDP.cpp
Generated on Mon Sep 23 2013 14:50:05 for MultiAgentDecisionProcess by
1.8.1.2