aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
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-2026 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-2026 *
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
// =========================================================================
55
#include <
agrum/FMDP/learning/core/templateStrategy.h
>
56
#include <
agrum/FMDP/learning/datastructure/leaves/leafPair.h
>
57
58
// =========================================================================
59
60
namespace
gum
{
61
69
70
using
pair_iterator
=
HashTableConstIteratorSafe< LeafPair*, std::vector< Size >
>;
71
72
template
<
bool
isInitial = false >
73
class
FusionContext
{
74
public
:
75
// ==========================================================================
77
// ==========================================================================
79
80
// ###################################################################
82
// ###################################################################
83
FusionContext
(
AbstractLeaf
*);
84
85
// ###################################################################
87
// ###################################################################
88
~FusionContext
();
89
90
// ============================================================================
92
// ============================================================================
93
void
*
operator
new
(
size_t
s);
94
95
void
operator
delete
(
void
* p);
96
98
99
// ==========================================================================
101
// ==========================================================================
103
104
// ###################################################################
106
// ###################################################################
107
108
public
:
109
bool
containsAssociatedLeaf
(
AbstractLeaf
* l);
110
111
private
:
112
bool
_containsAssociatedLeaf_
(
AbstractLeaf
* l,
Int2Type< false >
);
113
114
bool
_containsAssociatedLeaf_
(
AbstractLeaf
*,
Int2Type< true >
);
115
116
// ###################################################################
118
// ###################################################################
119
120
public
:
121
bool
associateLeaf
(
AbstractLeaf
* l);
122
123
private
:
124
bool
_associateLeaf_
(
AbstractLeaf
*,
Int2Type< false >
);
125
126
bool
_associateLeaf_
(
AbstractLeaf
*,
Int2Type< true >
);
127
128
// ###################################################################
130
// ###################################################################
131
132
public
:
133
bool
updateAssociatedLeaf
(
AbstractLeaf
* l);
134
135
private
:
136
bool
_updateAssociatedLeaf_
(
AbstractLeaf
*,
Int2Type< false >
);
137
138
bool
_updateAssociatedLeaf_
(
AbstractLeaf
*,
Int2Type< true >
);
139
140
public
:
141
bool
updateAllAssociatedLeaves
();
142
143
private
:
144
bool
_updateAllAssociatedLeaves_
(
Int2Type< false >
);
145
146
bool
_updateAllAssociatedLeaves_
(
Int2Type< true >
);
147
148
// ###################################################################
152
// ###################################################################
153
154
public
:
155
bool
deassociateLeaf
(
AbstractLeaf
* l);
156
157
private
:
158
bool
_deassociateLeaf_
(
AbstractLeaf
*,
Int2Type< false >
);
159
160
bool
_deassociateLeaf_
(
AbstractLeaf
*,
Int2Type< true >
);
161
163
164
public
:
165
// ==========================================================================
167
// ==========================================================================
169
170
// ###################################################################
172
// ###################################################################
173
bool
addPair
(
LeafPair
* p);
174
175
// ###################################################################
177
// ###################################################################
178
bool
updatePair
(
LeafPair
* p);
179
180
// ###################################################################
182
// ###################################################################
183
bool
removePair
(
LeafPair
* p);
184
185
pair_iterator
beginPairs
();
186
187
pair_iterator
endPairs
();
188
190
191
// ==========================================================================
193
// ==========================================================================
195
196
// ###################################################################
198
// ###################################################################
199
LeafPair
*
top
();
200
201
// ###################################################################
203
// ###################################################################
204
double
topLikelyhood
();
205
207
208
// ==========================================================================
210
// ==========================================================================
212
213
// ###################################################################
215
// ###################################################################
216
AbstractLeaf
*
leaf
();
217
218
// ###################################################################
220
// ###################################################################
221
LeafPair
*
leafAssociatedPair
(
AbstractLeaf
* l);
222
223
// ###################################################################
225
// ###################################################################
226
227
public
:
228
Set< LeafPair* >
associatedPairs
();
229
230
private
:
231
Set< LeafPair* >
_associatedPairs_
(
Int2Type< false >
);
232
233
Set< LeafPair* >
_associatedPairs_
(
Int2Type< true >
);
234
236
237
public
:
238
std::string
toString
();
239
240
private
:
241
MultiPriorityQueue< LeafPair*, double, std::less< double >
>
_pairsHeap_
;
242
243
HashTable< AbstractLeaf*, LeafPair* >
_leaf2Pair_
;
244
245
AbstractLeaf
*
_leaf_
;
246
};
247
248
249
}
/* namespace gum */
250
251
#include <
agrum/FMDP/learning/datastructure/leaves/fusionContext_tpl.h
>
252
253
#endif
// GUM_FUSION_CONTEXT_H
gum::AbstractLeaf
<agrum/FMDP/learning/datastructure/leaves/abstractLeaf.h>
Definition
abstractLeaf.h:72
gum::FusionContext::_containsAssociatedLeaf_
bool _containsAssociatedLeaf_(AbstractLeaf *l, Int2Type< false >)
Definition
fusionContext_tpl.h:231
gum::FusionContext::endPairs
pair_iterator endPairs()
Definition
fusionContext_tpl.h:286
gum::FusionContext::addPair
bool addPair(LeafPair *p)
Definition
fusionContext_tpl.h:157
gum::FusionContext::removePair
bool removePair(LeafPair *p)
Definition
fusionContext_tpl.h:179
gum::FusionContext::_associatedPairs_
Set< LeafPair * > _associatedPairs_(Int2Type< false >)
Definition
fusionContext_tpl.h:196
gum::FusionContext::FusionContext
FusionContext(AbstractLeaf *)
Default constructor.
Definition
fusionContext_tpl.h:68
gum::FusionContext::_pairsHeap_
MultiPriorityQueue< LeafPair *, double, std::less< double > > _pairsHeap_
Definition
fusionContext.h:241
gum::FusionContext::updatePair
bool updatePair(LeafPair *p)
Definition
fusionContext_tpl.h:168
gum::FusionContext::updateAllAssociatedLeaves
bool updateAllAssociatedLeaves()
Definition
fusionContext_tpl.h:261
gum::FusionContext::leaf
AbstractLeaf * leaf()
Definition
fusionContext_tpl.h:301
gum::FusionContext::updateAssociatedLeaf
bool updateAssociatedLeaf(AbstractLeaf *l)
Definition
fusionContext_tpl.h:251
gum::FusionContext::topLikelyhood
double topLikelyhood()
Definition
fusionContext_tpl.h:296
gum::FusionContext::_deassociateLeaf_
bool _deassociateLeaf_(AbstractLeaf *, Int2Type< false >)
Definition
fusionContext_tpl.h:139
gum::FusionContext::leafAssociatedPair
LeafPair * leafAssociatedPair(AbstractLeaf *l)
Definition
fusionContext_tpl.h:306
gum::FusionContext::_updateAllAssociatedLeaves_
bool _updateAllAssociatedLeaves_(Int2Type< false >)
Definition
fusionContext_tpl.h:121
gum::FusionContext::containsAssociatedLeaf
bool containsAssociatedLeaf(AbstractLeaf *l)
Definition
fusionContext_tpl.h:226
gum::FusionContext::top
LeafPair * top()
Definition
fusionContext_tpl.h:291
gum::FusionContext::_leaf_
AbstractLeaf * _leaf_
Definition
fusionContext.h:245
gum::FusionContext::deassociateLeaf
bool deassociateLeaf(AbstractLeaf *l)
Definition
fusionContext_tpl.h:271
gum::FusionContext::beginPairs
pair_iterator beginPairs()
Definition
fusionContext_tpl.h:281
gum::FusionContext::associatedPairs
Set< LeafPair * > associatedPairs()
Definition
fusionContext_tpl.h:311
gum::FusionContext::_updateAssociatedLeaf_
bool _updateAssociatedLeaf_(AbstractLeaf *, Int2Type< false >)
Definition
fusionContext_tpl.h:108
gum::FusionContext::associateLeaf
bool associateLeaf(AbstractLeaf *l)
Definition
fusionContext_tpl.h:241
gum::FusionContext::toString
std::string toString()
Definition
fusionContext_tpl.h:205
gum::FusionContext::_associateLeaf_
bool _associateLeaf_(AbstractLeaf *, Int2Type< false >)
Definition
fusionContext_tpl.h:93
gum::FusionContext::_leaf2Pair_
HashTable< AbstractLeaf *, LeafPair * > _leaf2Pair_
Definition
fusionContext.h:243
gum::HashTableConstIteratorSafe
Safe Const Iterators for hashtables.
Definition
hashTable.h:1662
gum::HashTable
The class for generic Hash Tables.
Definition
hashTable.h:640
gum::LeafPair
<agrum/FMDP/learning/datastructure/leaves/leafPair.h>
Definition
leafPair.h:69
gum::MultiPriorityQueue
A MultiPriorityQueue is a heap in which each element has a mutable priority and duplicates are allowe...
Definition
multiPriorityQueue.h:143
gum::Set
Representation of a set.
Definition
set.h:129
fusionContext_tpl.h
Templates for fusion context class.
leafPair.h
Headers of the leaf pair class.
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
gum::pair_iterator
HashTableConstIteratorSafe< LeafPair *, std::vector< Size > > pair_iterator
Definition
fusionContext.h:70
gum::Int2Type
Definition
templateStrategy.h:56
templateStrategy.h
Template trick for efficient development.
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0