aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
regress.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 Class used to compute the operation between two decision diagrams
25  *
26  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
27  * @author Pierre-Henri WUILLEMIN(@LIP6) and Jean-Christophe MAGNAN and Christophe
28  * GONZALES(@AMU)
29  */
30 
31 #ifndef GUM_REGRESS_H
32 #define GUM_REGRESS_H
33 
34 #include <agrum/tools/multidim/implementations/multiDimFunctionGraph.h>
35 #include <agrum/tools/multidim/utils/FunctionGraphUtilities/operators/o4DGContext.h>
36 #include <agrum/tools/multidim/utils/FunctionGraphUtilities/terminalNodePolicies/ExactTerminalNodePolicy.h>
37 
38 namespace gum {
39 
40  /**
41  * @class Regress
42  * @headerfile regress.h <agrum/tools/multidim/patterns/regress.h>
43  * @brief Class used to perform Function Graph Operations in the FMDP
44  * Framework
45  * @ingroup multidim_group
46  */
47  template < typename GUM_SCALAR,
48  template < typename >
49  class COMBINEOPERATOR,
50  template < typename >
51  class PROJECTOPERATOR,
52  template < typename > class TerminalNodePolicy
54  class Regress {
55  public:
56  // ============================================================================
57  /// @name Constructors / Destructors
58  // ============================================================================
59  /// @{
60 
61  /// Default constructor.
62  Regress(
63  const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >* vfunction,
64  const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >* probDist,
65  const Set< const DiscreteVariable* >* primedVars,
66  const DiscreteVariable* targetVar,
67  const GUM_SCALAR neutral);
68 
69  /// Default destructor.
70  ~Regress();
71 
72  /// @}
73 
74  // ============================================================================
75  /// @name Main Method
76  // ============================================================================
77  /// @{
78 
79  /// Computes and builds the Function Graph that is the result of the
80  /// operation
82 
83  /// @}
84 
85  private:
86  /// Computes an order for the final Decision graph that will minimize the
87  /// number
88  /// of re exploration
89  void establishVarOrder__();
90 
91  /// Establish for each node in both function graph if it has retrograde
92  /// variables
93  /// beneath it
95  const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >* dg,
96  HashTable< NodeId, short int* >& dgInstNeed);
97 
98  /// The main recursion function
100 
101  /// One of the two function graphs used for the operation
103 
104  /// The other one
106 
107  /// The resulting function graph
109 
110  /// The set of variables we want to keep at the end
112 
113  /// The variable we work on to eleminate
115 
116  /// The function to be performed on the leaves
117  const GUM_SCALAR neutral__;
118 
119  /// The total number of variable implied in the operation
121 
122  /// The functions to be performed on the leaves
123  const COMBINEOPERATOR< GUM_SCALAR > combine__;
124  const PROJECTOPERATOR< GUM_SCALAR > project__;
125 
126  /// The hashtable used to know if two pair of nodes have already been
127  /// visited
129 
130  /// Table uses to know if a given node of given function graph has
131  /// retrograde variables
134 
135  /// Just a computationnal trick
136  short int* default__;
137  };
138 
139 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
140  extern template class Regress< double, std::multiplies, std::plus >;
141 #endif
142 
143 } // namespace gum
144 
145 #include <agrum/tools/multidim/utils/FunctionGraphUtilities/operators/regress_tpl.h>
146 
147 #endif // GUM_REGRESS_H
Idx nbVar__
The total number of variable implied in the operation.
Definition: regress.h:120
MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * rd__
The resulting function graph.
Definition: regress.h:108
NodeId compute__(O4DGContext &currentSituation, Idx lastInstVarPos)
The main recursion function.
Definition: regress_tpl.h:327
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:669
MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * compute()
Computes and builds the Function Graph that is the result of the operation.
Definition: regress_tpl.h:103
HashTable< NodeId, short int *> DG2InstantiationNeeded__
Definition: regress.h:133
const Set< const DiscreteVariable *> * primedVars__
The set of variables we want to keep at the end.
Definition: regress.h:111
HashTable< double, NodeId > explorationTable__
The hashtable used to know if two pair of nodes have already been visited.
Definition: regress.h:128
Regress(const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > *vfunction, const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > *probDist, const Set< const DiscreteVariable * > *primedVars, const DiscreteVariable *targetVar, const GUM_SCALAR neutral)
Default constructor.
Definition: regress_tpl.h:48
const DiscreteVariable * targetVar__
The variable we work on to eleminate.
Definition: regress.h:114
void establishVarOrder__()
Computes an order for the final Decision graph that will minimize the number of re exploration...
Definition: regress_tpl.h:141
const PROJECTOPERATOR< GUM_SCALAR > project__
Definition: regress.h:124
const GUM_SCALAR neutral__
The function to be performed on the leaves.
Definition: regress.h:117
const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * DG1__
One of the two function graphs used for the operation.
Definition: regress.h:102
Class used to perform Function Graph Operations in the FMDP Framework.
Definition: regress.h:54
short int * default__
Just a computationnal trick.
Definition: regress.h:136
void findRetrogradeVariables__(const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > *dg, HashTable< NodeId, short int * > &dgInstNeed)
Establish for each node in both function graph if it has retrograde variables beneath it...
Definition: regress_tpl.h:229
const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * DG2__
The other one.
Definition: regress.h:105
HashTable< NodeId, short int *> DG1InstantiationNeeded__
Table uses to know if a given node of given function graph has retrograde variables.
Definition: regress.h:132
const COMBINEOPERATOR< GUM_SCALAR > combine__
The functions to be performed on the leaves.
Definition: regress.h:123
~Regress()
Default destructor.
Definition: regress_tpl.h:75