aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
mddOperatorStrategy.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2025 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2025 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41
49
50// =========================================================================
51#ifndef GUM_MDD_OPERATOR_STRATEGY_H
52#define GUM_MDD_OPERATOR_STRATEGY_H
53// =========================================================================
55
56// =========================================================================
57
58namespace gum {
59
70 template < typename GUM_SCALAR >
71 class MDDOperatorStrategy: public IOperatorStrategy< GUM_SCALAR > {
72 public:
73 // ###################################################################
75 // ###################################################################
77
82
87
89
90
91 // ###################################################################
93 // ###################################################################
95
99
105
110
112
113 // ###################################################################
115 // ###################################################################
117
118 protected:
119 // ==========================================================================
123 // ==========================================================================
125 Idx actionId,
126 const FMDP< GUM_SCALAR >* fmdp,
127 const gum::VariableSet& elVarSeq);
128
129 // ==========================================================================
131 // ==========================================================================
135 Idx del = 3);
136
137 // ==========================================================================
139 // ==========================================================================
143 Idx del = 3);
144
145 // ==========================================================================
147 // ==========================================================================
151 Idx del = 3);
152
153 // ==========================================================================
155 // ==========================================================================
160 Idx del = 3);
161
162 // ==========================================================================
164 // ==========================================================================
167 Idx del = 1);
168
169 // ==========================================================================
171 // ==========================================================================
175 Idx del = 0);
176
177
179
180 protected:
181 // ==========================================================================
184 // ==========================================================================
185 INLINE bool shouldEleminateVar_(const DiscreteVariable* v, const FMDP< GUM_SCALAR >* fmdp) {
186 return v == nullptr ? false : fmdp->mapMainPrime().existsSecond(v);
187 }
188
189 // ==========================================================================
192 // ==========================================================================
194 return function->variablesSequence().size() == 0
195 ? nullptr
196 : function->variablesSequence().atPos(function->variablesSequence().size() - 1);
197 }
198 };
199} /* namespace gum */
200
202
203#endif // GUM_MDD_OPERATOR_STRATEGY_H
Headers of the Operator Strategy interface.
A class to store the optimal actions.
Definition actionSet.h:105
Class to handle efficiently argMaxSet.
Definition argMaxSet.h:78
Base class for discrete random variable.
This class is used to implement factored decision process.
Definition fmdp.h:73
INLINE const Bijection< const DiscreteVariable *, const DiscreteVariable * > & mapMainPrime() const
Returns the map binding main variables and prime variables.
Definition fmdp.h:131
<agrum/FMDP/SDyna/IOperatorStrategy.h>
MultiDimFunctionGraph< ArgMaxSet< GUM_SCALAR, Idx >, SetTerminalNodePolicy > * getArgMaxFunctionInstance()
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< 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)
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.
MultiDimFunctionGraph< ActionSet, SetTerminalNodePolicy > * getAggregatorInstance()
MDDOperatorStrategy()
Default constructor.
MultiDimFunctionGraph< GUM_SCALAR > * regress(const MultiDimFunctionGraph< GUM_SCALAR > *Vold, Idx actionId, const FMDP< GUM_SCALAR > *fmdp, const gum::VariableSet &elVarSeq)
Computes Qaction for given actionid.
MultiDimFunctionGraph< GUM_SCALAR, ExactTerminalNodePolicy > * getFunctionInstance()
virtual MultiDimFunctionGraph< GUM_SCALAR > * maximize(const MultiDimFunctionGraph< GUM_SCALAR > *f1, const MultiDimFunctionGraph< GUM_SCALAR > *f2, Idx del=3)
~MDDOperatorStrategy()
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 qAction or vFunction).
virtual MultiDimFunctionGraph< GUM_SCALAR > * multiply(const MultiDimFunctionGraph< GUM_SCALAR > *f1, const MultiDimFunctionGraph< GUM_SCALAR > *f2, Idx del=3)
virtual MultiDimFunctionGraph< GUM_SCALAR > * minimize(const MultiDimFunctionGraph< GUM_SCALAR > *f1, const MultiDimFunctionGraph< GUM_SCALAR > *f2, Idx del=3)
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.
static MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * getReducedAndOrderedInstance()
Returns a reduced and ordered instance.
virtual const Sequence< const DiscreteVariable * > & variablesSequence() const override
Returns a const ref to the sequence of DiscreteVariable*.
Implementation of a Terminal Node Policy that maps nodeid to a set of value.
Size Idx
Type for indexes.
Definition types.h:79
Template implementation of FMDP/planning/MDDOperatorStrategy.h classes.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
Set< const DiscreteVariable * > VariableSet