![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
<agrum/PRM/structuredBayesBall.h> More...
#include <structuredBayesBall.h>
Public Member Functions | |
| void | compute (const PRMInstance< GUM_SCALAR > *i, NodeId n) |
| Compute the set or requisite nodes for each required instance given the current set of observations. Discard previous computations. | |
| void | compute (const PRMInstance< GUM_SCALAR > &i, NodeId n) |
| Compute the set or requisite nodes for each required instance given the current set of observations. Discard previous computations. | |
| bool | _isHardEvidence_ (const PRMInstance< GUM_SCALAR > *i, NodeId n) |
| Returns true if there is a hard evidence on i->get(n). | |
Constructors & destructor. | |
| StructuredBayesBall (const PRMInference< GUM_SCALAR > &inference) | |
| Default Constructor. | |
| ~StructuredBayesBall () | |
| Destructor. | |
Getters and Setters. | |
| const std::string & | key (const PRMInstance< GUM_SCALAR > *i) const |
| Returns a unique key w.r.t. d-separation for i. | |
| const std::string & | key (const PRMInstance< GUM_SCALAR > &i) const |
| Returns a unique key w.r.t. d-separation for i. | |
| const Set< NodeId > & | requisiteNodes (const PRMInstance< GUM_SCALAR > *i) const |
| Returns the set of requisite nodes w.r.t. d-separation for i. | |
| const Set< NodeId > & | requisiteNodes (const PRMInstance< GUM_SCALAR > &i) const |
| Returns the set of requisite nodes w.r.t. d-separation for i. | |
| Size | occurrence (const std::string &key) const |
| Returns the number of occurrence of the given key, which is the number of PRMInstance<GUM_SCALAR> sharing the same set of requisite nodes. | |
| float | liftRatio () const |
| Returns the ratio between the total number of instances and the number of instances with the same configuration. | |
| bool | exists (const PRMInstance< GUM_SCALAR > *i) const |
| Returns true if i has requisite nodes. | |
| bool | exists (const PRMInstance< GUM_SCALAR > &i) const |
| Returns true if i has requisite nodes. | |
Private Types | |
| using | MarkMap = HashTable< NodeId, std::pair< bool, bool > > |
| Code alias. | |
| using | InstanceMap = HashTable< const PRMInstance< GUM_SCALAR >*, MarkMap* > |
Private Member Functions | |
| StructuredBayesBall (const StructuredBayesBall &source) | |
| Copy constructor. | |
| StructuredBayesBall & | operator= (const StructuredBayesBall &source) |
| Copy operator. | |
| std::pair< bool, bool > & | _getMark_ (InstanceMap &marks, const PRMInstance< GUM_SCALAR > *i, NodeId n) |
| Code alias. | |
| const PRMSlotChain< GUM_SCALAR > & | _getSC_ (const PRMInstance< GUM_SCALAR > *i, NodeId n) |
| Code alias. | |
| void | _clean_ () |
| Cleans this before a new computation. | |
| void | _compute_ (const PRMInstance< GUM_SCALAR > *i, NodeId n) |
| The real compute method. | |
| void | _fromChild_ (const PRMInstance< GUM_SCALAR > *i, NodeId n, InstanceMap &marks) |
| When the ball is received on i->get(n) from a child. | |
| void | _fromParent_ (const PRMInstance< GUM_SCALAR > *i, NodeId n, InstanceMap &marks) |
| When the ball is receive on i->get(n) from a parent. | |
| void | _fillMaps_ (InstanceMap &marks) |
| Fill keyMap and reqMap. | |
| std::string | _buildHashKey_ (const PRMInstance< GUM_SCALAR > *i, Set< NodeId > &req_nodes) |
| Builds the HashKey for the given instance and requisite nodes set. | |
Private Attributes | |
| const PRMInference< GUM_SCALAR > * | _inf_ |
| The PRM at which model belongs. | |
| HashTable< const PRMInstance< GUM_SCALAR > *, std::pair< std::string, Set< NodeId > * > > | _keyMap_ |
| Associate an PRMInstance<GUM_SCALAR> with a unique key w.r.t. d-separation and the set of requisite nodes deduced from d-separation analysis. | |
| HashTable< std::string, std::pair< Set< NodeId > *, Size > > | _reqMap_ |
| Associate a Key with the set of requisite nodes associated with it. The Size value is the number of instance with the same key. | |
<agrum/PRM/structuredBayesBall.h>
This class represent the BayesBall algorithm applied on PRMs.
Definition at line 67 of file structuredBayesBall.h.
|
private |
Definition at line 136 of file structuredBayesBall.h.
|
private |
Code alias.
Definition at line 135 of file structuredBayesBall.h.
| INLINE gum::prm::StructuredBayesBall< GUM_SCALAR >::StructuredBayesBall | ( | const PRMInference< GUM_SCALAR > & | inference | ) |
Default Constructor.
Definition at line 265 of file structuredBayesBall_tpl.h.
References StructuredBayesBall(), and _inf_.
Referenced by StructuredBayesBall(), StructuredBayesBall(), and ~StructuredBayesBall().
| gum::prm::StructuredBayesBall< GUM_SCALAR >::~StructuredBayesBall | ( | ) |
Destructor.
Definition at line 56 of file structuredBayesBall_tpl.h.
References StructuredBayesBall(), and _reqMap_.
|
private |
|
private |
Builds the HashKey for the given instance and requisite nodes set.
Definition at line 253 of file structuredBayesBall_tpl.h.
References gum::Set< Key >::exists(), and gum::prm::PRMInstance< GUM_SCALAR >::type().
Referenced by _fillMaps_().
|
private |
Cleans this before a new computation.
Definition at line 64 of file structuredBayesBall_tpl.h.
References _keyMap_, and _reqMap_.
Referenced by _compute_().
|
private |
The real compute method.
Definition at line 96 of file structuredBayesBall_tpl.h.
References _clean_(), _fillMaps_(), and _fromChild_().
Referenced by compute(), and compute().
|
private |
Fill keyMap and reqMap.
Definition at line 210 of file structuredBayesBall_tpl.h.
References _buildHashKey_(), _keyMap_, _reqMap_, gum::HashTable< Key, Val >::erase(), gum::HashTable< Key, Val >::insert(), gum::Set< Key >::insert(), and key().
Referenced by _compute_().
|
private |
When the ball is received on i->get(n) from a child.
Definition at line 110 of file structuredBayesBall_tpl.h.
References _fromChild_(), _fromParent_(), _getMark_(), _getSC_(), _isHardEvidence_(), gum::HashTable< Key, Val >::exists(), exists(), gum::prm::PRMInstance< GUM_SCALAR >::getInstances(), gum::prm::PRMInstance< GUM_SCALAR >::getRefAttr(), GUM_ERROR, gum::HashTable< Key, Val >::insert(), gum::prm::PRMClassElement< GUM_SCALAR >::prm_aggregate, gum::prm::PRMClassElement< GUM_SCALAR >::prm_attribute, gum::prm::PRMClassElement< GUM_SCALAR >::prm_slotchain, and gum::prm::PRMInstance< GUM_SCALAR >::type().
Referenced by _compute_(), _fromChild_(), and _fromParent_().
|
private |
When the ball is receive on i->get(n) from a parent.
Definition at line 179 of file structuredBayesBall_tpl.h.
References _fromChild_(), _fromParent_(), _getMark_(), _isHardEvidence_(), gum::HashTable< Key, Val >::exists(), exists(), gum::prm::PRMInstance< GUM_SCALAR >::getRefAttr(), gum::HashTable< Key, Val >::insert(), and gum::prm::PRMInstance< GUM_SCALAR >::type().
Referenced by _fromChild_(), and _fromParent_().
|
private |
Code alias.
Definition at line 349 of file structuredBayesBall_tpl.h.
Referenced by _fromChild_(), and _fromParent_().
|
private |
Code alias.
Definition at line 343 of file structuredBayesBall_tpl.h.
References gum::prm::PRMInstance< GUM_SCALAR >::type().
Referenced by _fromChild_().
| bool gum::prm::StructuredBayesBall< GUM_SCALAR >::_isHardEvidence_ | ( | const PRMInstance< GUM_SCALAR > * | i, |
| NodeId | n ) |
Returns true if there is a hard evidence on i->get(n).
Definition at line 73 of file structuredBayesBall_tpl.h.
References _inf_, gum::Instantiation::end(), gum::prm::PRMInstance< GUM_SCALAR >::get(), gum::Instantiation::inc(), and gum::Instantiation::setFirst().
Referenced by _fromChild_(), and _fromParent_().
| INLINE void gum::prm::StructuredBayesBall< GUM_SCALAR >::compute | ( | const PRMInstance< GUM_SCALAR > & | i, |
| NodeId | n ) |
Compute the set or requisite nodes for each required instance given the current set of observations. Discard previous computations.
Definition at line 336 of file structuredBayesBall_tpl.h.
References _compute_().
| INLINE void gum::prm::StructuredBayesBall< GUM_SCALAR >::compute | ( | const PRMInstance< GUM_SCALAR > * | i, |
| NodeId | n ) |
Compute the set or requisite nodes for each required instance given the current set of observations. Discard previous computations.
Definition at line 330 of file structuredBayesBall_tpl.h.
References _compute_().
| INLINE bool gum::prm::StructuredBayesBall< GUM_SCALAR >::exists | ( | const PRMInstance< GUM_SCALAR > & | i | ) | const |
Returns true if i has requisite nodes.
Definition at line 325 of file structuredBayesBall_tpl.h.
References _keyMap_.
| INLINE bool gum::prm::StructuredBayesBall< GUM_SCALAR >::exists | ( | const PRMInstance< GUM_SCALAR > * | i | ) | const |
Returns true if i has requisite nodes.
Definition at line 319 of file structuredBayesBall_tpl.h.
References _keyMap_.
Referenced by _fromChild_(), and _fromParent_().
| INLINE const std::string & gum::prm::StructuredBayesBall< GUM_SCALAR >::key | ( | const PRMInstance< GUM_SCALAR > & | i | ) | const |
Returns a unique key w.r.t. d-separation for i.
Definition at line 291 of file structuredBayesBall_tpl.h.
References _keyMap_.
| INLINE const std::string & gum::prm::StructuredBayesBall< GUM_SCALAR >::key | ( | const PRMInstance< GUM_SCALAR > * | i | ) | const |
Returns a unique key w.r.t. d-separation for i.
Definition at line 285 of file structuredBayesBall_tpl.h.
References _keyMap_.
Referenced by _fillMaps_(), and occurrence().
| INLINE float gum::prm::StructuredBayesBall< GUM_SCALAR >::liftRatio | ( | ) | const |
| INLINE Size gum::prm::StructuredBayesBall< GUM_SCALAR >::occurrence | ( | const std::string & | key | ) | const |
Returns the number of occurrence of the given key, which is the number of PRMInstance<GUM_SCALAR> sharing the same set of requisite nodes.
Definition at line 308 of file structuredBayesBall_tpl.h.
References _reqMap_, and key().
|
private |
| INLINE const Set< NodeId > & gum::prm::StructuredBayesBall< GUM_SCALAR >::requisiteNodes | ( | const PRMInstance< GUM_SCALAR > & | i | ) | const |
Returns the set of requisite nodes w.r.t. d-separation for i.
Definition at line 302 of file structuredBayesBall_tpl.h.
References _keyMap_.
| INLINE const Set< NodeId > & gum::prm::StructuredBayesBall< GUM_SCALAR >::requisiteNodes | ( | const PRMInstance< GUM_SCALAR > * | i | ) | const |
Returns the set of requisite nodes w.r.t. d-separation for i.
Definition at line 296 of file structuredBayesBall_tpl.h.
References _keyMap_.
|
private |
The PRM at which model belongs.
Definition at line 163 of file structuredBayesBall.h.
Referenced by StructuredBayesBall(), and _isHardEvidence_().
|
private |
Associate an PRMInstance<GUM_SCALAR> with a unique key w.r.t. d-separation and the set of requisite nodes deduced from d-separation analysis.
Definition at line 170 of file structuredBayesBall.h.
Referenced by _clean_(), _fillMaps_(), exists(), exists(), key(), key(), liftRatio(), requisiteNodes(), and requisiteNodes().
|
private |
Associate a Key with the set of requisite nodes associated with it. The Size value is the number of instance with the same key.
Definition at line 174 of file structuredBayesBall.h.
Referenced by ~StructuredBayesBall(), _clean_(), _fillMaps_(), liftRatio(), and occurrence().