MultiAgentDecisionProcess  Release 0.2.1
BruteForceSearchPlanner.cpp
Go to the documentation of this file.
1 
29 #include <float.h>
30 
31 using namespace std;
32 
33 #define DEBUG_BFS 0
34 
35 //Default constructor
38  PlanningUnitDecPOMDPDiscrete(horizon, p),
39  _m_foundPolicy(*this)
40 {
41  SetReferred(p);
42 }
43 
46  size_t horizon, DecPOMDPDiscreteInterface* p) :
47  PlanningUnitDecPOMDPDiscrete(params, horizon, p),
48  _m_foundPolicy(*this)
49 {
50  SetReferred(p);
51 }
52 
54 {
55  bool round = false;
57  JointPolicyPureVector best(*this);
58  double v_best = -DBL_MAX;
59  double v = 0.0;
60 
61  int i = 0;
62  if(DEBUG_BFS)
63  cout << "Starting Bruteforce search - v_best is init to "
64  << v_best << endl;
65  LIndex nrJPols = GetNrJointPolicies();
66 
67  while(!round)
68  {
69  if(DEBUG_BFS){ cout << "Jpol#"<< i << " - ";}
70  PrintProgress("Jpol #",i,nrJPols,1000);
71  i++;
72 
73  ValueFunctionDecPOMDPDiscrete vf(this, jpol);
74  v = vf.CalculateV(true);//set caching to true!
75  if(DEBUG_BFS) cout << "Expected value = "<< v;
76  if(v > v_best)
77  {
78  if(DEBUG_BFS) cout << " -> new best policy!!!";
79  v_best = v;
80  best = *jpol;
81  }
82  if(DEBUG_BFS) cout << endl << "Incrementing joint policy..." <<endl;
83  round = ++(*jpol);
84  }
85 
86  _m_foundPolicy=best;
88 }