aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
fusionContext_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 Templates for fusion context class
25  *
26  * @author Pierre-Henri WUILLEMIN(@LIP6) and Jean-Christophe MAGNAN and Christophe
27  * GONZALES(@AMU)
28  */
29 // =======================================================
30 #include <agrum/tools/core/math/math_utils.h>
31 #include <agrum/FMDP/learning/datastructure/leaves/fusionContext.h>
32 // =======================================================
33 
34 namespace gum {
35 
36  // ############################################################################
37  // Constructors / Destructors
38  // ############################################################################
39 
40  // ============================================================================
41  // Default constructor.
42  // ============================================================================
43  template < bool isInitial >
44  FusionContext< isInitial >::FusionContext(AbstractLeaf* leaf) : _leaf_(leaf) {
45  GUM_CONSTRUCTOR(FusionContext);
46  }
47 
48  // ============================================================================
49  // Default constructor.
50  // ============================================================================
51  template < bool isInitial >
54 
56  delete leafIter.val();
57 
58  delete _leaf_;
59  }
60 
61  // ############################################################################
62  //
63  // ############################################################################
64 
65  // ============================================================================
66  //
67  // ============================================================================
68  template < bool isInitial >
70  LeafPair* ptop = _pairsHeap_.empty() ? nullptr : _pairsHeap_.top();
71  ;
72  LeafPair* p = new LeafPair(l, _leaf_);
76 
77  return ptop != _pairsHeap_.top();
78  }
79 
80  // ============================================================================
81  //
82  // ============================================================================
83  template < bool isInitial >
85  LeafPair* ptop = _pairsHeap_.empty() ? nullptr : _pairsHeap_.top();
86  ;
89 
90  return ptop != _pairsHeap_.top();
91  }
92 
93  // ============================================================================
94  //
95  // ============================================================================
96  template < bool isInitial >
98  LeafPair* ptop = _pairsHeap_.empty() ? nullptr : _pairsHeap_.top();
99  ;
102  ++pairIter) {
105  }
106  LeafPair* ctop = _pairsHeap_.empty() ? nullptr : _pairsHeap_.top();
107 
108  return ptop != ctop;
109  }
110 
111  // ============================================================================
112  //
113  // ============================================================================
114  template < bool isInitial >
116  LeafPair* ptop = _pairsHeap_.empty() ? nullptr : _pairsHeap_.top();
119 
120  LeafPair* ctop = _pairsHeap_.empty() ? nullptr : _pairsHeap_.top();
121 
122  return ptop != ctop;
123  }
124 
125 
126  // ############################################################################
127  //
128  // ############################################################################
129 
130  // ============================================================================
131  //
132  // ============================================================================
133  template < bool isInitial >
135  LeafPair* ptop = _pairsHeap_.empty() ? nullptr : _pairsHeap_.top();
137 
138  return ptop != _pairsHeap_.top();
139  }
140 
141  // ============================================================================
142  //
143  // ============================================================================
144  template < bool isInitial >
146  LeafPair* ptop = _pairsHeap_.empty() ? nullptr : _pairsHeap_.top();
148 
149  return ptop != _pairsHeap_.top();
150  }
151 
152  // ============================================================================
153  //
154  // ============================================================================
155  template < bool isInitial >
157  LeafPair* ptop = _pairsHeap_.empty() ? nullptr : _pairsHeap_.top();
159 
160  LeafPair* ctop = _pairsHeap_.empty() ? nullptr : _pairsHeap_.top();
161 
162  return ptop != ctop;
163  }
164 
165 
166  // ############################################################################
167  //
168  // ############################################################################
169 
170  // ============================================================================
171  //
172  // ============================================================================
173  template < bool isInitial >
175  Set< LeafPair* > retBag;
177  retBag << pairIter.val();
178 
179  return retBag;
180  }
181 
182 
183  template < bool isInitial >
186  if (_leaf_)
187  ss << "Associated Leaf : " << _leaf_->toString() << std::endl
188  << "Leaves Heap : " << std::endl;
189 
190  // for( HashTableConstIteratorSafe<LeafPair*, std::vector<Size>>
191  // leafIter = _pairsHeap_.allValues().cbeginSafe();
192  // leafIter != _pairsHeap_.allValues().cendSafe(); ++leafIter ){
193  // ss << leafIter.key()->toString() << std::endl;
194  // }
195  if (!_pairsHeap_.empty()) ss << "Top pair : " << _pairsHeap_.top()->toString() << std::endl;
196 
197  return ss.str();
198  }
199 
200 } // namespace gum
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643