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