aGrUM  0.16.0
treeOperatorStrategy_tpl.h
Go to the documentation of this file.
1 
31 // =========================================================================
32 #include <algorithm>
33 #include <queue>
34 #include <utility>
35 #include <vector>
36 // =========================================================================
37 #include <agrum/core/math/math.h>
39 // =========================================================================
43 // =========================================================================
44 
46 #define RECAST(x) reinterpret_cast< const MultiDimFunctionGraph< GUM_SCALAR >* >(x)
47 
48 namespace gum {
49 
50 
51  /* **************************************************************************************************
52  * **/
53  /* ** **/
54  /* ** Constructors / Destructors **/
55  /* ** **/
56  /* **************************************************************************************************
57  * **/
58 
59  // ===========================================================================
60  // Default constructor
61  // ===========================================================================
62  template < typename GUM_SCALAR >
64  GUM_CONSTRUCTOR(TreeOperatorStrategy);
65  }
66 
67  // ===========================================================================
68  // Default destructor
69  // ===========================================================================
70  template < typename GUM_SCALAR >
72  GUM_DESTRUCTOR(TreeOperatorStrategy);
73  }
74 
75 
76  /* **************************************************************************************************
77  * **/
78  /* ** **/
79  /* ** Graph Function Operations Methods **/
80  /* ** **/
81  /* **************************************************************************************************
82  * **/
83 
84 
85  // ==========================================================================
91  // ==========================================================================
92  template < typename GUM_SCALAR >
95  Idx actionId,
96  const FMDP< GUM_SCALAR >* fmdp,
97  const Set< const DiscreteVariable* >& elVarSeq) {
98  // ******************************************************************************
99  // Initialisation :
100  // Creating a copy of last Vfunction to deduce from the new Qaction
101  // And finding the first var to eleminate (the one at the end)
102  Bijection< const DiscreteVariable*,
104  pxi;
106  Vold->variablesSequence().beginSafe();
107  varIter != Vold->variablesSequence().endSafe();
108  ++varIter) {
109  pxi.insert(
110  *varIter,
111  RECAST(fmdp->transition(actionId, fmdp->mapMainPrime().first(*varIter))));
112  }
113 
115  Vold, pxi); //, Vold->variablesSequence(), (GUM_SCALAR) 0.0 );
116  return tr.compute();
117  }
118 
119  // ==========================================================================
121  // ==========================================================================
122  template < typename GUM_SCALAR >
127  Idx del) {
130  this->_deleteFunctionGraph(f1, f2, del);
131  return ret;
132  }
133 
134  // ==========================================================================
136  // ==========================================================================
137  template < typename GUM_SCALAR >
142  Idx del) {
145  this->_deleteFunctionGraph(f1, f2, del);
146  return ret;
147  }
148 
149  // ==========================================================================
150  // ==========================================================================
151  template < typename GUM_SCALAR >
156  Idx del) {
159  this->_deleteFunctionGraph(f1, f2, del);
160  return ret;
161  }
162 
163 
164  // ==========================================================================
167  // ==========================================================================
168  template < typename GUM_SCALAR >
172  SetTerminalNodePolicy >* f1,
174  SetTerminalNodePolicy >* f2,
175  Idx del) {
179  argmaxope(f1, f2);
181  ret = argmaxope.compute();
182  this->_deleteFunctionGraph(f1, f2, del);
183  return ret;
184  }
185 
186  // ==========================================================================
191  // ==========================================================================
192  template < typename GUM_SCALAR >
196  Idx del) {
199  this->_deleteFunctionGraph(f1, f2, del);
200  return ret;
201  }
202 
203  // ==========================================================================
208  // ==========================================================================
209  template < typename GUM_SCALAR >
214  Idx del) {
217  this->_deleteFunctionGraph(f1, f2, del);
218  return ret;
219  }
220 
221 
222 } // end of namespace gum
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual MultiDimFunctionGraph< GUM_SCALAR > * minimize(const MultiDimFunctionGraph< GUM_SCALAR > *f1, const MultiDimFunctionGraph< GUM_SCALAR > *f2, Idx del=3)
Safe iterators for Sequence.
Definition: sequence.h:1206
~TreeOperatorStrategy()
Default destructor.
virtual MultiDimFunctionGraph< GUM_SCALAR > * add(const MultiDimFunctionGraph< GUM_SCALAR > *f1, const MultiDimFunctionGraph< GUM_SCALAR > *f2, Idx del=1)
Adds reward to given function( whether a f2 or f1)
Class used to perform Decision Tree Regression in the FMDP Framework.
Definition: treeRegress.h:55
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
INLINE const Bijection< const DiscreteVariable *, const DiscreteVariable *> & mapMainPrime() const
Returns the map binding main variables and prime variables.
Definition: fmdp.h:117
This class is used to implement factored decision process.
Definition: fmdp.h:57
Base class for discrete random variable.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
Class used to perform Decision Tree Operation in the FMDP Framework.
Definition: treeOperator.h:53
Class to handle efficiently argMaxSet.
Definition: argMaxSet.h:57
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:165
MultiDimFunctionGraph< GUM_SCALAR > * regress(const MultiDimFunctionGraph< GUM_SCALAR > *Vold, Idx actionId, const FMDP< GUM_SCALAR > *fmdp, const Set< const DiscreteVariable * > &elVarSeq)
Computes Qaction for given actionid.
const MultiDimImplementation< GUM_SCALAR > * transition(Idx actionId, const DiscreteVariable *v) const
Returns transition associated to given in parameter variable and the given action.
Definition: fmdp_tpl.h:227
<agrum/FMDP/planning/treeOperatorStrategy.h>
MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * compute()
Computes and builds the Function Graph that is the result of the operation.
virtual MultiDimFunctionGraph< ArgMaxSet< GUM_SCALAR, Idx >, SetTerminalNodePolicy > * argmaximize(const MultiDimFunctionGraph< ArgMaxSet< GUM_SCALAR, Idx >, SetTerminalNodePolicy > *f1, const MultiDimFunctionGraph< ArgMaxSet< GUM_SCALAR, Idx >, SetTerminalNodePolicy > *f2, Idx del=3)
ArgMaximizes between f2 and f1.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual MultiDimFunctionGraph< GUM_SCALAR > * multiply(const MultiDimFunctionGraph< GUM_SCALAR > *f1, const MultiDimFunctionGraph< GUM_SCALAR > *f2, Idx del=3)
MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * compute()
Computes and builds the Function Graph that is the result of the operation.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Set of pairs of elements with fast search for both elements.
Definition: bijection.h:1805
Implementation of a Terminal Node Policy that maps nodeid to a set of value.
virtual const Sequence< const DiscreteVariable *> & variablesSequence() const override
Returns a const ref to the sequence of DiscreteVariable*.
TreeOperatorStrategy()
Default constructor.
virtual MultiDimFunctionGraph< GUM_SCALAR > * subtract(const MultiDimFunctionGraph< GUM_SCALAR > *f1, const MultiDimFunctionGraph< GUM_SCALAR > *f2, Idx del=0)
Subtract current f1 from old f1 to see if threshold is reached or not.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
#define RECAST(x)
For shorter line and hence more comprehensive code only.
virtual MultiDimFunctionGraph< GUM_SCALAR > * maximize(const MultiDimFunctionGraph< GUM_SCALAR > *f1, const MultiDimFunctionGraph< GUM_SCALAR > *f2, Idx del=3)
Size Idx
Type for indexes.
Definition: types.h:53
<agrum/FMDP/planning/actionSet.h>
Definition: actionSet.h:58