![]() |
aGrUM 3.0.0
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 (std::string_view 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 69 of file structuredBayesBall.h.
|
private |
Definition at line 138 of file structuredBayesBall.h.
|
private |
Code alias.
Definition at line 137 of file structuredBayesBall.h.
| gum::prm::StructuredBayesBall< GUM_SCALAR >::StructuredBayesBall | ( | const PRMInference< GUM_SCALAR > & | inference | ) |
Default Constructor.
Definition at line 267 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 57 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 256 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 65 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 214 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::prm::PRMInstance< GUM_SCALAR >::getInstances(), gum::prm::PRMInstance< GUM_SCALAR >::getRefAttr(), GUM_ERROR, gum::prm::PRMInstance< GUM_SCALAR >::hasRefAttr(), 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, gum::HashTable< Key, Val >::tryGet(), 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 181 of file structuredBayesBall_tpl.h.
References _fromChild_(), _fromParent_(), _getMark_(), _isHardEvidence_(), gum::prm::PRMInstance< GUM_SCALAR >::getRefAttr(), gum::prm::PRMInstance< GUM_SCALAR >::hasRefAttr(), gum::HashTable< Key, Val >::insert(), gum::HashTable< Key, Val >::tryGet(), and gum::prm::PRMInstance< GUM_SCALAR >::type().
Referenced by _fromChild_(), and _fromParent_().
|
private |
Code alias.
Definition at line 347 of file structuredBayesBall_tpl.h.
Referenced by _fromChild_(), and _fromParent_().
|
private |
Code alias.
Definition at line 341 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 74 of file structuredBayesBall_tpl.h.
References _inf_, gum::Instantiation::end(), gum::prm::PRMInstance< GUM_SCALAR >::exists(), gum::prm::PRMInstance< GUM_SCALAR >::get(), gum::Instantiation::inc(), and gum::Instantiation::setFirst().
Referenced by _fromChild_(), and _fromParent_().
| 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 335 of file structuredBayesBall_tpl.h.
References _compute_().
| 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_().
| 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_.
| bool gum::prm::StructuredBayesBall< GUM_SCALAR >::exists | ( | const PRMInstance< GUM_SCALAR > * | i | ) | const |
Returns true if i has requisite nodes.
Definition at line 320 of file structuredBayesBall_tpl.h.
References _keyMap_.
| 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 293 of file structuredBayesBall_tpl.h.
References _keyMap_.
| 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 287 of file structuredBayesBall_tpl.h.
References _keyMap_.
Referenced by _fillMaps_(), and occurrence().
| float gum::prm::StructuredBayesBall< GUM_SCALAR >::liftRatio | ( | ) | const |
| Size gum::prm::StructuredBayesBall< GUM_SCALAR >::occurrence | ( | std::string_view | 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 310 of file structuredBayesBall_tpl.h.
References _reqMap_, and key().
|
private |
| 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 304 of file structuredBayesBall_tpl.h.
References _keyMap_.
| 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 298 of file structuredBayesBall_tpl.h.
References _keyMap_.
|
private |
The PRM at which model belongs.
Definition at line 165 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 172 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 176 of file structuredBayesBall.h.
Referenced by ~StructuredBayesBall(), _clean_(), _fillMaps_(), liftRatio(), and occurrence().