aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
fusionContext.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
48
49// =========================================================================
50#ifndef GUM_FUSION_CONTEXT_H
51#define GUM_FUSION_CONTEXT_H
52// =========================================================================
53// =========================================================================
54// =========================================================================
57
58// =========================================================================
59
60namespace gum {
61
69
71
72 template < bool isInitial = false >
74 public:
75 // ==========================================================================
77 // ==========================================================================
79
80 // ###################################################################
82 // ###################################################################
84
85 // ###################################################################
87 // ###################################################################
89
90 // ============================================================================
92 // ============================================================================
93 void* operator new(size_t s) { return SmallObjectAllocator::instance().allocate(s); }
94
95 void operator delete(void* p) {
97 }
98
100
101 // ==========================================================================
103 // ==========================================================================
105
106 // ###################################################################
108 // ###################################################################
109
110 public:
114
115 private:
119
121
122 // ###################################################################
124 // ###################################################################
125
126 public:
128
129 private:
131
133
134 // ###################################################################
136 // ###################################################################
137
138 public:
142
143 private:
145
147
148 public:
152
153 private:
155
157
158 // ###################################################################
162 // ###################################################################
163
164 public:
166
167 private:
169
171
173
174 public:
175 // ==========================================================================
177 // ==========================================================================
179
180 // ###################################################################
182 // ###################################################################
183 bool addPair(LeafPair* p);
184
185 // ###################################################################
187 // ###################################################################
188 bool updatePair(LeafPair* p);
189
190 // ###################################################################
192 // ###################################################################
193 bool removePair(LeafPair* p);
194
195 pair_iterator beginPairs() { return _pairsHeap_.allValues().beginSafe(); }
196
197 pair_iterator endPairs() { return _pairsHeap_.allValues().endSafe(); }
198
200
201 // ==========================================================================
203 // ==========================================================================
205
206 // ###################################################################
208 // ###################################################################
209 LeafPair* top() { return !_pairsHeap_.empty() ? _pairsHeap_.top() : nullptr; }
210
211 // ###################################################################
213 // ###################################################################
214 double topLikelyhood() { return !_pairsHeap_.empty() ? _pairsHeap_.topPriority() : 1.0; }
215
217
218 // ==========================================================================
220 // ==========================================================================
222
223 // ###################################################################
225 // ###################################################################
226 AbstractLeaf* leaf() { return _leaf_; }
227
228 // ###################################################################
230 // ###################################################################
231 LeafPair* leafAssociatedPair(AbstractLeaf* l) { return _leaf2Pair_.getWithDefault(l, nullptr); }
232
233 // ###################################################################
235 // ###################################################################
236
237 public:
239
240 private:
242
244
246
247 public:
248 std::string toString();
249
250 private:
252
254
256 };
257
258
259} /* namespace gum */
260
262
263#endif // GUM_FUSION_CONTEXT_H
<agrum/FMDP/learning/datastructure/leaves/abstractLeaf.h>
bool _containsAssociatedLeaf_(AbstractLeaf *l, Int2Type< false >)
pair_iterator endPairs()
bool addPair(LeafPair *p)
bool removePair(LeafPair *p)
Set< LeafPair * > _associatedPairs_(Int2Type< false >)
FusionContext(AbstractLeaf *)
Default constructor.
bool _containsAssociatedLeaf_(AbstractLeaf *, Int2Type< true >)
bool _updateAssociatedLeaf_(AbstractLeaf *, Int2Type< true >)
MultiPriorityQueue< LeafPair *, double, std::less< double > > _pairsHeap_
bool updatePair(LeafPair *p)
bool updateAllAssociatedLeaves()
AbstractLeaf * leaf()
bool updateAssociatedLeaf(AbstractLeaf *l)
bool _deassociateLeaf_(AbstractLeaf *, Int2Type< true >)
bool _associateLeaf_(AbstractLeaf *, Int2Type< true >)
bool _deassociateLeaf_(AbstractLeaf *, Int2Type< false >)
LeafPair * leafAssociatedPair(AbstractLeaf *l)
bool _updateAllAssociatedLeaves_(Int2Type< false >)
bool containsAssociatedLeaf(AbstractLeaf *l)
~FusionContext()
Default destructor.
bool _updateAllAssociatedLeaves_(Int2Type< true >)
AbstractLeaf * _leaf_
bool deassociateLeaf(AbstractLeaf *l)
Set< LeafPair * > _associatedPairs_(Int2Type< true >)
pair_iterator beginPairs()
Set< LeafPair * > associatedPairs()
bool _updateAssociatedLeaf_(AbstractLeaf *, Int2Type< false >)
bool associateLeaf(AbstractLeaf *l)
bool _associateLeaf_(AbstractLeaf *, Int2Type< false >)
HashTable< AbstractLeaf *, LeafPair * > _leaf2Pair_
Safe Const Iterators for hashtables.
Definition hashTable.h:1602
The class for generic Hash Tables.
Definition hashTable.h:637
<agrum/FMDP/learning/datastructure/leaves/leafPair.h>
Definition leafPair.h:69
A MultiPriorityQueue is a heap in which each element has a mutable priority and duplicates are allowe...
Representation of a set.
Definition set.h:131
static SmallObjectAllocator & instance()
void * allocate(const size_t &objectSize)
Allocates a block.
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
Templates for fusion context class.
Headers of the leaf pair class.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
HashTableConstIteratorSafe< LeafPair *, std::vector< Size > > pair_iterator
Template trick for efficient development.