aGrUM  0.21.0
a C++ library for (probabilistic) graphical models
treeRegress_tpl.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 Class used to compute the operation between two decision diagrams
25  *
26  * @author Pierre-Henri WUILLEMIN(@LIP6) and Jean-Christophe MAGNAN and Christophe
27  * GONZALES(@AMU)
28  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
29  */
30 
31 #include <agrum/tools/multidim/utils/FunctionGraphUtilities/internalNode.h>
32 #include <agrum/tools/multidim/utils/FunctionGraphUtilities/operators/treeOperator.h>
33 #include <agrum/tools/multidim/utils/FunctionGraphUtilities/operators/treeRegress.h>
34 
35 #define ALLOCATE(x) SmallObjectAllocator::instance().allocate(x)
36 #define DEALLOCATE(x, y) SmallObjectAllocator::instance().deallocate(x, y)
37 
38 namespace gum {
39 
40  template < typename GUM_SCALAR,
41  template < typename >
42  class COMBINEOPERATOR,
43  template < typename >
44  class PROJECTOPERATOR,
45  template < typename >
46  class TerminalNodePolicy >
47  TreeRegress< GUM_SCALAR, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::TreeRegress(
48  const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >* qAction,
49  const Bijection< const DiscreteVariable*,
50  const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >* > pxi) :
51  _vFunc_(qAction),
52  _pxi_(pxi) {
53  GUM_CONSTRUCTOR(TreeRegress);
54  }
55 
56  template < typename GUM_SCALAR,
57  template < typename >
58  class COMBINEOPERATOR,
59  template < typename >
60  class PROJECTOPERATOR,
61  template < typename >
62  class TerminalNodePolicy >
65  }
66 
67  // This function is the main function. To be call every time an operation
68  // between the two given Function Graphs is required
69  template < typename GUM_SCALAR,
70  template < typename >
71  class COMBINEOPERATOR,
72  template < typename >
73  class PROJECTOPERATOR,
74  template < typename >
75  class TerminalNodePolicy >
81  ret->copy(*_vFunc_);
82  } else
84  return ret;
85  }
86 
87 
88  template < typename GUM_SCALAR,
89  template < typename >
90  class COMBINEOPERATOR,
91  template < typename >
92  class PROJECTOPERATOR,
93  template < typename >
94  class TerminalNodePolicy >
99 
101 
102  for (Idx moda = 0; moda < currentNode->nodeVar()->domainSize(); ++moda) {
107  if (value) {
110  }
111  } else {
113  }
114 
115  if (vpxi != nullptr) {
118  _context_);
120  }
121  delete vpxi;
123  }
124 
125  if (varbucket.empty()) return nullptr;
126 
129  while (!varbucket.empty()) {
132  vp = projope.compute();
133  delete temp;
134  temp = varbucket.back();
136  delete temp;
137  }
138 
139  return vp;
140  }
141 
142 } // namespace gum
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643