aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
mddOperatorStrategy.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by 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 
76  return MultiDimFunctionGraph< GUM_SCALAR >::getReducedAndOrderedInstance();
77  }
82  }
86  }
87 
88  /// @}
89 
90  // ###################################################################
91  /// @name Graph Function Operations Methods
92  // ###################################################################
93  /// @{
94 
95  protected:
96  // ==========================================================================
97  /**
98  * Computes Qaction for given actionid
99  */
100  // ==========================================================================
102  Idx actionId,
103  const FMDP< GUM_SCALAR >* fmdp,
104  const Set< const DiscreteVariable* >& elVarSeq);
105 
106  // ==========================================================================
107  /// @warning given vFunction and qAction are deleted, returns the new one
108  // ==========================================================================
112  Idx del = 3);
113 
114  // ==========================================================================
115  /// @warning Minimze the two given functions
116  // ==========================================================================
120  Idx del = 3);
121 
122  // ==========================================================================
123  /// @warning given f1 and f2 are deleted, returns the new one
124  // ==========================================================================
128  Idx del = 3);
129 
130  // ==========================================================================
131  /// @warning given vFunction and qAction are deleted, returns the new one
132  // ==========================================================================
134  argmaximize(
137  Idx del = 3);
138 
139  // ==========================================================================
140  /// @warning given function is deleted, returns the new one
141  // ==========================================================================
144  Idx del = 1);
145 
146  // ==========================================================================
147  /// @warning this time, nothing is deleted
148  // ==========================================================================
152  Idx del = 0);
153 
154 
155  /// @}
156 
157  protected:
158  // ==========================================================================
159  /// Indicates if whether or not given var is to be eliminated.
160  /// Called by the evalQaction.
161  // ==========================================================================
163  return v == nullptr ? false : fmdp->mapMainPrime().existsSecond(v);
164  }
165 
166  // ==========================================================================
167  /// Returns the last var in the var order for given graph function
168  /// Called by the evalQaction.
169  // ==========================================================================
171  return function->variablesSequence().size() == 0
172  ? nullptr
174  }
175  };
176 } /* namespace gum */
177 
178 
179 #include <agrum/FMDP/planning/mddOperatorStrategy_tpl.h>
180 
181 #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:643
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)