aGrUM 3.0.0
a C++ library for (probabilistic) graphical models
gum::FusionContext< isInitial > Class Template Reference

<agrum/FMDP/learning/datastructure/leaves/fusionContext.h> More...

#include <fusionContext.h>

Collaboration diagram for gum::FusionContext< isInitial >:

Public Member Functions

std::string toString ()
Constructor & destructor.
 FusionContext (AbstractLeaf *)
 Default constructor.
 ~FusionContext ()
 Default destructor.
void * operator new (size_t s)
 Allocators and Deallocators redefinition.
void operator delete (void *p)
 Default constructor.
Pair handling methods
bool addPair (LeafPair *p)
bool updatePair (LeafPair *p)
bool removePair (LeafPair *p)
pair_iterator beginPairs ()
pair_iterator endPairs ()
Best Pair access methods
LeafPairtop ()
double topLikelyhood ()

Private Attributes

MultiPriorityQueue< LeafPair *, double, std::less< double > > _pairsHeap_
HashTable< AbstractLeaf *, LeafPair * > _leaf2Pair_
AbstractLeaf_leaf_

Associated Leaves Handling methods

bool containsAssociatedLeaf (AbstractLeaf *l)
bool associateLeaf (AbstractLeaf *l)
bool updateAssociatedLeaf (AbstractLeaf *l)
bool updateAllAssociatedLeaves ()
bool deassociateLeaf (AbstractLeaf *l)
bool _containsAssociatedLeaf_ (AbstractLeaf *l, Int2Type< false >)
bool _containsAssociatedLeaf_ (AbstractLeaf *, Int2Type< true >)
bool _associateLeaf_ (AbstractLeaf *, Int2Type< false >)
bool _associateLeaf_ (AbstractLeaf *, Int2Type< true >)
bool _updateAssociatedLeaf_ (AbstractLeaf *, Int2Type< false >)
bool _updateAssociatedLeaf_ (AbstractLeaf *, Int2Type< true >)
bool _updateAllAssociatedLeaves_ (Int2Type< false >)
bool _updateAllAssociatedLeaves_ (Int2Type< true >)
bool _deassociateLeaf_ (AbstractLeaf *, Int2Type< false >)
bool _deassociateLeaf_ (AbstractLeaf *, Int2Type< true >)

FusionContext Leaf and associated pairs handling methods

AbstractLeafleaf ()
LeafPairleafAssociatedPair (AbstractLeaf *l)
Set< LeafPair * > associatedPairs ()
Set< LeafPair * > _associatedPairs_ (Int2Type< false >)
Set< LeafPair * > _associatedPairs_ (Int2Type< true >)

Detailed Description

template<bool isInitial = false>
class gum::FusionContext< isInitial >

<agrum/FMDP/learning/datastructure/leaves/fusionContext.h>

Contains leaves situation after a merging have been made

Definition at line 73 of file fusionContext.h.

Constructor & Destructor Documentation

◆ FusionContext()

template<bool isInitial>
gum::FusionContext< isInitial >::FusionContext ( AbstractLeaf * leaf)

Default constructor.

Definition at line 68 of file fusionContext_tpl.h.

68 : _leaf_(leaf) {
70 }
<agrum/FMDP/learning/datastructure/leaves/fusionContext.h>
FusionContext(AbstractLeaf *)
Default constructor.
AbstractLeaf * leaf()
AbstractLeaf * _leaf_

References FusionContext(), _leaf_, and leaf().

Referenced by FusionContext(), and ~FusionContext().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~FusionContext()

template<bool isInitial>
gum::FusionContext< isInitial >::~FusionContext ( )

Default destructor.

Definition at line 76 of file fusionContext_tpl.h.

76 {
78
79 for (auto leafIter = _leaf2Pair_.beginSafe(); leafIter != _leaf2Pair_.endSafe(); ++leafIter)
80 delete leafIter.val();
81
82 delete _leaf_;
83 }
HashTable< AbstractLeaf *, LeafPair * > _leaf2Pair_

References FusionContext(), _leaf2Pair_, and _leaf_.

Here is the call graph for this function:

Member Function Documentation

◆ _associatedPairs_() [1/2]

template<bool isInitial>
Set< LeafPair * > gum::FusionContext< isInitial >::_associatedPairs_ ( Int2Type< false > )
private

Definition at line 196 of file fusionContext_tpl.h.

196 {
198 for (auto pairIter = _leaf2Pair_.beginSafe(); pairIter != _leaf2Pair_.endSafe(); ++pairIter)
199 retBag << pairIter.val();
200
201 return retBag;
202 }

References _leaf2Pair_.

Referenced by associatedPairs().

Here is the caller graph for this function:

◆ _associatedPairs_() [2/2]

template<bool isInitial>
Set< LeafPair * > gum::FusionContext< isInitial >::_associatedPairs_ ( Int2Type< true > )
private

Definition at line 316 of file fusionContext_tpl.h.

316 {
317 return Set< LeafPair* >();
318 }

◆ _associateLeaf_() [1/2]

template<bool isInitial>
bool gum::FusionContext< isInitial >::_associateLeaf_ ( AbstractLeaf * l,
Int2Type< false >  )
private
Warning
: won't delete Associated Pair created (because subsequent fusioncontexts might be using it)

Definition at line 93 of file fusionContext_tpl.h.

93 {
94 LeafPair* ptop = _pairsHeap_.empty() ? nullptr : _pairsHeap_.top();
95 ;
96 LeafPair* p = new LeafPair(l, _leaf_);
97 _leaf2Pair_.insert(l, p);
98 _leaf2Pair_[l]->updateLikelyhood();
99 _pairsHeap_.insert(p, p->likelyhood());
100
101 return ptop != _pairsHeap_.top();
102 }
MultiPriorityQueue< LeafPair *, double, std::less< double > > _pairsHeap_

References _pairsHeap_.

Referenced by associateLeaf().

Here is the caller graph for this function:

◆ _associateLeaf_() [2/2]

template<bool isInitial>
bool gum::FusionContext< isInitial >::_associateLeaf_ ( AbstractLeaf * ,
Int2Type< true >  )
private
Warning
: won't delete Associated Pair created (because subsequent fusioncontexts might be using it)

Definition at line 246 of file fusionContext_tpl.h.

246 {
247 return false;
248 }

◆ _containsAssociatedLeaf_() [1/2]

template<bool isInitial>
bool gum::FusionContext< isInitial >::_containsAssociatedLeaf_ ( AbstractLeaf * ,
Int2Type< true >  )
private
Warning
: won't delete Associated Pair created (because subsequent fusioncontexts might be using it)

Definition at line 236 of file fusionContext_tpl.h.

236 {
237 return false;
238 }

◆ _containsAssociatedLeaf_() [2/2]

template<bool isInitial>
bool gum::FusionContext< isInitial >::_containsAssociatedLeaf_ ( AbstractLeaf * l,
Int2Type< false >  )
private
Warning
: won't delete Associated Pair created (because subsequent fusioncontexts might be using it)

Definition at line 231 of file fusionContext_tpl.h.

231 {
232 return _leaf2Pair_.exists(l);
233 }

Referenced by containsAssociatedLeaf().

Here is the caller graph for this function:

◆ _deassociateLeaf_() [1/2]

template<bool isInitial>
bool gum::FusionContext< isInitial >::_deassociateLeaf_ ( AbstractLeaf * l,
Int2Type< false >  )
private
Warning
: won't delete Associated Pair created (because subsequent fusioncontexts might be using it)

Definition at line 139 of file fusionContext_tpl.h.

139 {
140 LeafPair* ptop = _pairsHeap_.empty() ? nullptr : _pairsHeap_.top();
141 _pairsHeap_.erase(_leaf2Pair_[l]);
142 _leaf2Pair_.erase(l);
143
144 LeafPair* ctop = _pairsHeap_.empty() ? nullptr : _pairsHeap_.top();
145
146 return ptop != ctop;
147 }

References _pairsHeap_.

Referenced by deassociateLeaf().

Here is the caller graph for this function:

◆ _deassociateLeaf_() [2/2]

template<bool isInitial>
bool gum::FusionContext< isInitial >::_deassociateLeaf_ ( AbstractLeaf * ,
Int2Type< true >  )
private
Warning
: won't delete Associated Pair created (because subsequent fusioncontexts might be using it)

Definition at line 276 of file fusionContext_tpl.h.

276 {
277 return false;
278 }

◆ _updateAllAssociatedLeaves_() [1/2]

template<bool isInitial>
bool gum::FusionContext< isInitial >::_updateAllAssociatedLeaves_ ( Int2Type< false > )
private
Warning
: won't delete Associated Pair created (because subsequent fusioncontexts might be using it)

Definition at line 121 of file fusionContext_tpl.h.

121 {
122 LeafPair* ptop = _pairsHeap_.empty() ? nullptr : _pairsHeap_.top();
123 ;
125 pairIter != _leaf2Pair_.cendSafe();
126 ++pairIter) {
127 pairIter.val()->updateLikelyhood();
128 _pairsHeap_.setPriority(pairIter.val(), pairIter.val()->likelyhood());
129 }
130 LeafPair* ctop = _pairsHeap_.empty() ? nullptr : _pairsHeap_.top();
131
132 return ptop != ctop;
133 }

References _pairsHeap_.

Referenced by updateAllAssociatedLeaves().

Here is the caller graph for this function:

◆ _updateAllAssociatedLeaves_() [2/2]

template<bool isInitial>
bool gum::FusionContext< isInitial >::_updateAllAssociatedLeaves_ ( Int2Type< true > )
private
Warning
: won't delete Associated Pair created (because subsequent fusioncontexts might be using it)

Definition at line 266 of file fusionContext_tpl.h.

266 {
267 return false;
268 }

◆ _updateAssociatedLeaf_() [1/2]

template<bool isInitial>
bool gum::FusionContext< isInitial >::_updateAssociatedLeaf_ ( AbstractLeaf * l,
Int2Type< false >  )
private
Warning
: won't delete Associated Pair created (because subsequent fusioncontexts might be using it)

Definition at line 108 of file fusionContext_tpl.h.

108 {
109 LeafPair* ptop = _pairsHeap_.empty() ? nullptr : _pairsHeap_.top();
110 ;
111 _leaf2Pair_[l]->updateLikelyhood();
112 _pairsHeap_.setPriority(_leaf2Pair_[l], _leaf2Pair_[l]->likelyhood());
113
114 return ptop != _pairsHeap_.top();
115 }

Referenced by updateAssociatedLeaf().

Here is the caller graph for this function:

◆ _updateAssociatedLeaf_() [2/2]

template<bool isInitial>
bool gum::FusionContext< isInitial >::_updateAssociatedLeaf_ ( AbstractLeaf * ,
Int2Type< true >  )
private
Warning
: won't delete Associated Pair created (because subsequent fusioncontexts might be using it)

Definition at line 256 of file fusionContext_tpl.h.

256 {
257 return false;
258 }

◆ addPair()

template<bool isInitial>
bool gum::FusionContext< isInitial >::addPair ( LeafPair * p)

Definition at line 157 of file fusionContext_tpl.h.

157 {
158 LeafPair* ptop = _pairsHeap_.empty() ? nullptr : _pairsHeap_.top();
159 _pairsHeap_.insert(p, p->likelyhood());
160
161 return ptop != _pairsHeap_.top();
162 }

Referenced by gum::LeafAggregator::update().

Here is the caller graph for this function:

◆ associatedPairs()

template<bool isInitial>
Set< LeafPair * > gum::FusionContext< isInitial >::associatedPairs ( )

Definition at line 311 of file fusionContext_tpl.h.

311 {
313 }
Set< LeafPair * > _associatedPairs_(Int2Type< false >)

References _associatedPairs_().

Here is the call graph for this function:

◆ associateLeaf()

template<bool isInitial>
bool gum::FusionContext< isInitial >::associateLeaf ( AbstractLeaf * l)
Warning
: won't delete Associated Pair created (because subsequent fusioncontexts might be using it)

Definition at line 241 of file fusionContext_tpl.h.

241 {
243 }
bool _associateLeaf_(AbstractLeaf *, Int2Type< false >)

References _associateLeaf_().

Referenced by gum::LeafAggregator::update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ beginPairs()

template<bool isInitial>
pair_iterator gum::FusionContext< isInitial >::beginPairs ( )

Definition at line 281 of file fusionContext_tpl.h.

281 {
282 return _pairsHeap_.allValues().beginSafe();
283 }

References _pairsHeap_.

◆ containsAssociatedLeaf()

template<bool isInitial>
bool gum::FusionContext< isInitial >::containsAssociatedLeaf ( AbstractLeaf * l)
Warning
: won't delete Associated Pair created (because subsequent fusioncontexts might be using it)

Definition at line 226 of file fusionContext_tpl.h.

226 {
228 }
bool _containsAssociatedLeaf_(AbstractLeaf *l, Int2Type< false >)

References _containsAssociatedLeaf_().

Referenced by gum::LeafAggregator::update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ deassociateLeaf()

template<bool isInitial>
bool gum::FusionContext< isInitial >::deassociateLeaf ( AbstractLeaf * l)
Warning
: won't delete Associated Pair created (because subsequent fusioncontexts might be using it)

Definition at line 271 of file fusionContext_tpl.h.

271 {
273 }
bool _deassociateLeaf_(AbstractLeaf *, Int2Type< false >)

References _deassociateLeaf_().

Here is the call graph for this function:

◆ endPairs()

template<bool isInitial>
pair_iterator gum::FusionContext< isInitial >::endPairs ( )

Definition at line 286 of file fusionContext_tpl.h.

286 {
287 return _pairsHeap_.allValues().endSafe();
288 }

References _pairsHeap_.

◆ leaf()

template<bool isInitial>
AbstractLeaf * gum::FusionContext< isInitial >::leaf ( )

Definition at line 301 of file fusionContext_tpl.h.

301 {
302 return _leaf_;
303 }

References _leaf_.

Referenced by FusionContext().

Here is the caller graph for this function:

◆ leafAssociatedPair()

template<bool isInitial>
LeafPair * gum::FusionContext< isInitial >::leafAssociatedPair ( AbstractLeaf * l)

Definition at line 306 of file fusionContext_tpl.h.

306 {
307 return _leaf2Pair_.getWithDefault(l, nullptr);
308 }

References _leaf2Pair_.

◆ operator delete()

template<bool isInitial>
void gum::FusionContext< isInitial >::operator delete ( void * p)

Default constructor.

Definition at line 221 of file fusionContext_tpl.h.

221 {
223 }
static SmallObjectAllocator & instance()
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.

◆ operator new()

template<bool isInitial>
void * gum::FusionContext< isInitial >::operator new ( size_t s)

Allocators and Deallocators redefinition.

Definition at line 216 of file fusionContext_tpl.h.

216 {
218 }
void * allocate(const size_t &objectSize)
Allocates a block.

◆ removePair()

template<bool isInitial>
bool gum::FusionContext< isInitial >::removePair ( LeafPair * p)

Definition at line 179 of file fusionContext_tpl.h.

179 {
180 LeafPair* ptop = _pairsHeap_.empty() ? nullptr : _pairsHeap_.top();
181 _pairsHeap_.erase(p);
182
183 LeafPair* ctop = _pairsHeap_.empty() ? nullptr : _pairsHeap_.top();
184
185 return ptop != ctop;
186 }

References _pairsHeap_.

◆ top()

template<bool isInitial>
LeafPair * gum::FusionContext< isInitial >::top ( )

Definition at line 291 of file fusionContext_tpl.h.

291 {
292 return !_pairsHeap_.empty() ? _pairsHeap_.top() : nullptr;
293 }

References _pairsHeap_.

◆ topLikelyhood()

template<bool isInitial>
double gum::FusionContext< isInitial >::topLikelyhood ( )

Definition at line 296 of file fusionContext_tpl.h.

296 {
297 return !_pairsHeap_.empty() ? _pairsHeap_.topPriority() : 1.0;
298 }

References _pairsHeap_.

◆ toString()

template<bool isInitial>
std::string gum::FusionContext< isInitial >::toString ( )

Definition at line 205 of file fusionContext_tpl.h.

205 {
207 if (_leaf_) ss = std::format("Associated Leaf : {}\nLeaves Heap : \n", _leaf_->toString());
208
209 // ss += std::format("{}\n", leafIter.key()->toString());
210 if (!_pairsHeap_.empty()) ss += std::format("Top pair : {}\n", _pairsHeap_.top()->toString());
211
212 return ss;
213 }

References _leaf_, and _pairsHeap_.

◆ updateAllAssociatedLeaves()

template<bool isInitial>
bool gum::FusionContext< isInitial >::updateAllAssociatedLeaves ( )
Warning
: won't delete Associated Pair created (because subsequent fusioncontexts might be using it)

Definition at line 261 of file fusionContext_tpl.h.

261 {
263 }
bool _updateAllAssociatedLeaves_(Int2Type< false >)

References _updateAllAssociatedLeaves_().

Here is the call graph for this function:

◆ updateAssociatedLeaf()

template<bool isInitial>
bool gum::FusionContext< isInitial >::updateAssociatedLeaf ( AbstractLeaf * l)
Warning
: won't delete Associated Pair created (because subsequent fusioncontexts might be using it)

Definition at line 251 of file fusionContext_tpl.h.

251 {
253 }
bool _updateAssociatedLeaf_(AbstractLeaf *, Int2Type< false >)

References _updateAssociatedLeaf_().

Here is the call graph for this function:

◆ updatePair()

template<bool isInitial>
bool gum::FusionContext< isInitial >::updatePair ( LeafPair * p)

Definition at line 168 of file fusionContext_tpl.h.

168 {
169 LeafPair* ptop = _pairsHeap_.empty() ? nullptr : _pairsHeap_.top();
170 _pairsHeap_.setPriority(p, p->likelyhood());
171
172 return ptop != _pairsHeap_.top();
173 }

References _pairsHeap_, and gum::LeafPair::likelyhood().

Here is the call graph for this function:

Member Data Documentation

◆ _leaf2Pair_

template<bool isInitial = false>
HashTable< AbstractLeaf*, LeafPair* > gum::FusionContext< isInitial >::_leaf2Pair_
private

Definition at line 243 of file fusionContext.h.

Referenced by ~FusionContext(), _associatedPairs_(), and leafAssociatedPair().

◆ _leaf_

template<bool isInitial = false>
AbstractLeaf* gum::FusionContext< isInitial >::_leaf_
private

Definition at line 245 of file fusionContext.h.

Referenced by FusionContext(), ~FusionContext(), leaf(), and toString().

◆ _pairsHeap_

template<bool isInitial = false>
MultiPriorityQueue< LeafPair*, double, std::less< double > > gum::FusionContext< isInitial >::_pairsHeap_
private

The documentation for this class was generated from the following files: