aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
mddOperatorStrategy.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright 2005-2020 Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /**
23  * @file
24  * @brief Headers of the MDDOperatorStrategy planer class.
25  *
26  * @author Pierre-Henri WUILLEMIN(@LIP6) and Jean-Christophe MAGNAN and Christophe
27  * GONZALES(@AMU)
28  */
29 
30 // =========================================================================
31 #ifndef GUM_MDD_OPERATOR_STRATEGY_H
32 #define GUM_MDD_OPERATOR_STRATEGY_H
33 // =========================================================================
34 #include <agrum/FMDP/planning/IOperatorStrategy.h>
35 // =========================================================================
36 
37 namespace gum {
38 
39  /**
40  * @class MDDOperatorStrategy mddOperatorStrategy.h
41  * <agrum/FMDP/planning/mddOperatorStrategy.h>
42  * @brief A class to find optimal policy for a given FMDP.
43  * @ingroup fmdp_group
44  *
45  * Perform a SPUDD planning on given in parameter factored markov decision
46  * process
47  *
48  */
49  template < typename GUM_SCALAR >
51  public:
52  // ###################################################################
53  /// @name Constructor & destructor.
54  // ###################################################################
55  /// @{
56 
57  /**
58  * Default constructor
59  */
61 
62  /**
63  * Default destructor
64  */
66 
67  /// @}
68 
69 
70  // ###################################################################
71  /// @name
72  // ###################################################################
73  /// @{
74 
77  return MultiDimFunctionGraph< GUM_SCALAR >::getReducedAndOrderedInstance();
78  }
81  return MultiDimFunctionGraph<
84  }
89  }
90 
91  /// @}
92 
93  // ###################################################################
94  /// @name Graph Function Operations Methods
95  // ###################################################################
96  /// @{
97 
98  protected:
99  // ==========================================================================
100  /**
101  * Computes Qaction for given actionid
102  */
103  // ==========================================================================
106  Idx actionId,
107  const FMDP< GUM_SCALAR >* fmdp,
108  const Set< const DiscreteVariable* >& elVarSeq);
109 
110  // ==========================================================================
111  /// @warning given vFunction and qAction are deleted, returns the new one
112  // ==========================================================================
116  Idx del = 3);
117 
118  // ==========================================================================
119  /// @warning Minimze the two given functions
120  // ==========================================================================
124  Idx del = 3);
125 
126  // ==========================================================================
127  /// @warning given f1 and f2 are deleted, returns the new one
128  // ==========================================================================
132  Idx del = 3);
133 
134  // ==========================================================================
135  /// @warning given vFunction and qAction are deleted, returns the new one
136  // ==========================================================================
143  Idx del = 3);
144 
145  // ==========================================================================
146  /// @warning given function is deleted, returns the new one
147  // ==========================================================================
151  Idx del = 1);
152 
153  // ==========================================================================
154  /// @warning this time, nothing is deleted
155  // ==========================================================================
159  Idx del = 0);
160 
161 
162  /// @}
163 
164  protected:
165  // ==========================================================================
166  /// Indicates if whether or not given var is to be eliminated.
167  /// Called by the evalQaction.
168  // ==========================================================================
170  const FMDP< GUM_SCALAR >* fmdp) {
171  return v == nullptr ? false : fmdp->mapMainPrime().existsSecond(v);
172  }
173 
174  // ==========================================================================
175  /// Returns the last var in the var order for given graph function
176  /// Called by the evalQaction.
177  // ==========================================================================
178  INLINE const DiscreteVariable*
180  return function->variablesSequence().size() == 0
181  ? nullptr
183  function->variablesSequence().size() - 1);
184  }
185  };
186 } /* namespace gum */
187 
188 
189 #include <agrum/FMDP/planning/mddOperatorStrategy_tpl.h>
190 
191 #endif // GUM_MDD_OPERATOR_STRATEGY_H
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.
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:669
MDDOperatorStrategy()
Default constructor.
~MDDOperatorStrategy()
Default destructor.
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.
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< GUM_SCALAR > * minimize(const MultiDimFunctionGraph< GUM_SCALAR > *f1, const MultiDimFunctionGraph< GUM_SCALAR > *f2, Idx del=3)