aGrUM  0.14.2
mddOperatorStrategy.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
27 // =========================================================================
28 #ifndef GUM_MDD_OPERATOR_STRATEGY_H
29 #define GUM_MDD_OPERATOR_STRATEGY_H
30 // =========================================================================
32 // =========================================================================
33 
34 namespace gum {
35 
46  template < typename GUM_SCALAR >
47  class MDDOperatorStrategy : public IOperatorStrategy< GUM_SCALAR > {
48  public:
49  // ###################################################################
51  // ###################################################################
53 
58 
63 
65 
66 
67  // ###################################################################
69  // ###################################################################
71 
75  }
78  return MultiDimFunctionGraph<
80  SetTerminalNodePolicy >::getReducedAndOrderedInstance();
81  }
86  }
87 
89 
90  // ###################################################################
92  // ###################################################################
94 
95  protected:
96  // ==========================================================================
100  // ==========================================================================
103  Idx actionId,
104  const FMDP< GUM_SCALAR >* fmdp,
105  const Set< const DiscreteVariable* >& elVarSeq);
106 
107  // ==========================================================================
109  // ==========================================================================
113  Idx del = 3);
114 
115  // ==========================================================================
117  // ==========================================================================
121  Idx del = 3);
122 
123  // ==========================================================================
125  // ==========================================================================
129  Idx del = 3);
130 
131  // ==========================================================================
133  // ==========================================================================
137  SetTerminalNodePolicy >* f1,
139  SetTerminalNodePolicy >* f2,
140  Idx del = 3);
141 
142  // ==========================================================================
144  // ==========================================================================
148  Idx del = 1);
149 
150  // ==========================================================================
152  // ==========================================================================
156  Idx del = 0);
157 
158 
160 
161  protected:
162  // ==========================================================================
165  // ==========================================================================
166  INLINE bool _shouldEleminateVar(const DiscreteVariable* v,
167  const FMDP< GUM_SCALAR >* fmdp) {
168  return v == nullptr ? false : fmdp->mapMainPrime().existsSecond(v);
169  }
170 
171  // ==========================================================================
174  // ==========================================================================
175  INLINE const DiscreteVariable*
177  return function->variablesSequence().size() == 0
178  ? nullptr
179  : function->variablesSequence().atPos(
180  function->variablesSequence().size() - 1);
181  }
182  };
183 } /* namespace gum */
184 
185 
187 
188 #endif // GUM_MDD_OPERATOR_STRATEGY_H
Template implementation of FMDP/planning/MDDOperatorStrategy.h classes.
virtual MultiDimFunctionGraph< GUM_SCALAR > * subtract(const MultiDimFunctionGraph< GUM_SCALAR > *f1, const MultiDimFunctionGraph< GUM_SCALAR > *f2, Idx del=0)
Subtract current VFunction from old VFunction to see if threshold is reached or not.
Headers of the Operator Strategy interface.
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.
INLINE bool _shouldEleminateVar(const DiscreteVariable *v, const FMDP< GUM_SCALAR > *fmdp)
Indicates if whether or not given var is to be eliminated. Called by the evalQaction.
<agrum/FMDP/SDyna/IOperatorStrategy.h>
MDDOperatorStrategy()
Default constructor.
INLINE const Bijection< const DiscreteVariable *, const DiscreteVariable *> & mapMainPrime() const
Returns the map binding main variables and prime variables.
Definition: fmdp.h:114
This class is used to implement factored decision process.
Definition: fmdp.h:54
Base class for discrete random variable.
~MDDOperatorStrategy()
Default destructor.
<agrum/FMDP/planning/mddOperatorStrategy.h>
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
MultiDimFunctionGraph< ActionSet, SetTerminalNodePolicy > * getAggregatorInstance()
Class to handle efficiently argMaxSet.
Definition: argMaxSet.h:55
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:162
virtual MultiDimFunctionGraph< GUM_SCALAR > * multiply(const MultiDimFunctionGraph< GUM_SCALAR > *f1, const MultiDimFunctionGraph< GUM_SCALAR > *f2, Idx del=3)
virtual MultiDimFunctionGraph< GUM_SCALAR > * maximize(const MultiDimFunctionGraph< GUM_SCALAR > *f1, const MultiDimFunctionGraph< GUM_SCALAR > *f2, Idx del=3)
MultiDimFunctionGraph< GUM_SCALAR, ExactTerminalNodePolicy > * getFunctionInstance()
INLINE const DiscreteVariable * _lastVar(const MultiDimFunctionGraph< GUM_SCALAR > *function)
Returns the last var in the var order for given graph function Called by the evalQaction.
Implementation of a Terminal Node Policy that maps nodeid to a set of value.
MultiDimFunctionGraph< ArgMaxSet< GUM_SCALAR, Idx >, SetTerminalNodePolicy > * getArgMaxFunctionInstance()
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 qAction or vFunction)
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)
Size Idx
Type for indexes.
Definition: types.h:50
virtual MultiDimFunctionGraph< GUM_SCALAR > * minimize(const MultiDimFunctionGraph< GUM_SCALAR > *f1, const MultiDimFunctionGraph< GUM_SCALAR > *f2, Idx del=3)
static MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * getReducedAndOrderedInstance()
Returns a reduced and ordered instance.