aGrUM 2.3.2
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 67 of file fusionContext_tpl.h.

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

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

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

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 75 of file fusionContext_tpl.h.

75 {
77
78 for (auto leafIter = _leaf2Pair_.beginSafe(); leafIter != _leaf2Pair_.endSafe(); ++leafIter)
79 delete leafIter.val();
80
81 delete _leaf_;
82 }
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 195 of file fusionContext_tpl.h.

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

References _leaf2Pair_.

Referenced by associatedPairs().

Here is the caller graph for this function:

◆ _associatedPairs_() [2/2]

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

Definition at line 243 of file fusionContext.h.

243{ return Set< LeafPair* >(); }

◆ _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 92 of file fusionContext_tpl.h.

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

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

Referenced by associateLeaf().

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

◆ _associateLeaf_() [2/2]

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

Definition at line 132 of file fusionContext.h.

132{ return false; }

◆ _containsAssociatedLeaf_() [1/2]

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

Definition at line 120 of file fusionContext.h.

120{ return false; }

◆ _containsAssociatedLeaf_() [2/2]

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

Definition at line 116 of file fusionContext.h.

116 {
117 return _leaf2Pair_.exists(l);
118 }

References _leaf2Pair_.

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 138 of file fusionContext_tpl.h.

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

References _leaf2Pair_, and _pairsHeap_.

Referenced by deassociateLeaf().

Here is the caller graph for this function:

◆ _deassociateLeaf_() [2/2]

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

Definition at line 170 of file fusionContext.h.

170{ return false; }

◆ _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 120 of file fusionContext_tpl.h.

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

References _leaf2Pair_, and _pairsHeap_.

Referenced by updateAllAssociatedLeaves().

Here is the caller graph for this function:

◆ _updateAllAssociatedLeaves_() [2/2]

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

Definition at line 156 of file fusionContext.h.

156{ return false; }

◆ _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 107 of file fusionContext_tpl.h.

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

References _leaf2Pair_, and _pairsHeap_.

Referenced by updateAssociatedLeaf().

Here is the caller graph for this function:

◆ _updateAssociatedLeaf_() [2/2]

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

Definition at line 146 of file fusionContext.h.

146{ return false; }

◆ addPair()

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

Definition at line 156 of file fusionContext_tpl.h.

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

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

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

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

◆ associatedPairs()

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

Definition at line 238 of file fusionContext.h.

Set< LeafPair * > _associatedPairs_(Int2Type< false >)

References _associatedPairs_().

Here is the call graph for this function:

◆ associateLeaf()

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

Definition at line 127 of file fusionContext.h.

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 = false>
pair_iterator gum::FusionContext< isInitial >::beginPairs ( )
inline

Definition at line 195 of file fusionContext.h.

195{ return _pairsHeap_.allValues().beginSafe(); }

References _pairsHeap_.

◆ containsAssociatedLeaf()

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

Definition at line 111 of file fusionContext.h.

111 {
113 }
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 = false>
bool gum::FusionContext< isInitial >::deassociateLeaf ( AbstractLeaf * l)
inline
Warning
: won't delete Associated Pair created (because subsequent fusioncontexts might be using it)

Definition at line 165 of file fusionContext.h.

bool _deassociateLeaf_(AbstractLeaf *, Int2Type< false >)

References _deassociateLeaf_().

Here is the call graph for this function:

◆ endPairs()

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

Definition at line 197 of file fusionContext.h.

197{ return _pairsHeap_.allValues().endSafe(); }

References _pairsHeap_.

◆ leaf()

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

Definition at line 226 of file fusionContext.h.

226{ return _leaf_; }

References _leaf_.

Referenced by FusionContext().

Here is the caller graph for this function:

◆ leafAssociatedPair()

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

Definition at line 231 of file fusionContext.h.

231{ return _leaf2Pair_.getWithDefault(l, nullptr); }

References _leaf2Pair_.

◆ operator delete()

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

Default constructor.

Definition at line 95 of file fusionContext.h.

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

References FusionContext(), gum::SmallObjectAllocator::deallocate(), and gum::SmallObjectAllocator::instance().

Here is the call graph for this function:

◆ operator new()

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

Allocators and Deallocators redefinition.

Definition at line 93 of file fusionContext.h.

void * allocate(const size_t &objectSize)
Allocates a block.

References gum::SmallObjectAllocator::allocate(), and gum::SmallObjectAllocator::instance().

Here is the call graph for this function:

◆ removePair()

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

Definition at line 178 of file fusionContext_tpl.h.

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

References _pairsHeap_.

◆ top()

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

Definition at line 209 of file fusionContext.h.

209{ return !_pairsHeap_.empty() ? _pairsHeap_.top() : nullptr; }

References _pairsHeap_.

◆ topLikelyhood()

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

Definition at line 214 of file fusionContext.h.

214{ return !_pairsHeap_.empty() ? _pairsHeap_.topPriority() : 1.0; }

References _pairsHeap_.

◆ toString()

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

Definition at line 204 of file fusionContext_tpl.h.

204 {
206 if (_leaf_)
207 ss << "Associated Leaf : " << _leaf_->toString() << std::endl
208 << "Leaves Heap : " << std::endl;
209
210 // for( HashTableConstIteratorSafe<LeafPair*, std::vector<Size>>
211 // leafIter = _pairsHeap_.allValues().cbeginSafe();
212 // leafIter != _pairsHeap_.allValues().cendSafe(); ++leafIter ){
213 // ss << leafIter.key()->toString() << std::endl;
214 // }
215 if (!_pairsHeap_.empty()) ss << "Top pair : " << _pairsHeap_.top()->toString() << std::endl;
216
217 return ss.str();
218 }

References _leaf_, and _pairsHeap_.

◆ updateAllAssociatedLeaves()

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

Definition at line 149 of file fusionContext.h.

149 {
151 }
bool _updateAllAssociatedLeaves_(Int2Type< false >)

References _updateAllAssociatedLeaves_().

Here is the call graph for this function:

◆ updateAssociatedLeaf()

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

Definition at line 139 of file fusionContext.h.

139 {
141 }
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 167 of file fusionContext_tpl.h.

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

Member Data Documentation

◆ _leaf2Pair_

◆ _leaf_

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

Definition at line 255 of file fusionContext.h.

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

◆ _pairsHeap_


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