![]() |
aGrUM
0.14.2
|
This class is an implementation of the Structured Value Elimination algorithm on PRM<GUM_SCALAR>. More...
#include <agrum/PRM/SVED.h>
Public Member Functions | |
Constructors & destructor. | |
SVED (const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &model) | |
Default Constructor. More... | |
~SVED () | |
Destructor. More... | |
Getters & setters. | |
virtual std::string | name () const |
Returns the name of the current inference algorithm. More... | |
Query methods. | |
void | marginal (const Chain &chain, Potential< GUM_SCALAR > &m) |
Compute the marginal of the formal attribute pointed by chain and stores it in m. More... | |
void | joint (const std::vector< Chain > &chains, Potential< GUM_SCALAR > &j) |
Compute the joint probability of the formals attributes pointed by chains and stores it in m. More... | |
Evidence handling. | |
EMap & | evidence (const PRMInstance< GUM_SCALAR > &i) |
Returns EMap of evidences over i. More... | |
EMap & | evidence (const PRMInstance< GUM_SCALAR > *i) |
Returns EMap of evidences over i. More... | |
const EMap & | evidence (const PRMInstance< GUM_SCALAR > &i) const |
Returns EMap of evidences over i. More... | |
const EMap & | evidence (const PRMInstance< GUM_SCALAR > *i) const |
Returns EMap of evidences over i. More... | |
bool | hasEvidence (const PRMInstance< GUM_SCALAR > &i) const |
Returns true if i has evidence. More... | |
bool | hasEvidence (const PRMInstance< GUM_SCALAR > *i) const |
Returns EMap of evidences over i. More... | |
bool | hasEvidence (const Chain &chain) const |
Returns true if i has evidence on PRMAttribute<GUM_SCALAR> a. More... | |
bool | hasEvidence () const |
Returns true if i has evidence on PRMAttribute<GUM_SCALAR> a. More... | |
void | addEvidence (const Chain &chain, const Potential< GUM_SCALAR > &p) |
Add an evidence to the given instance's elt. More... | |
void | removeEvidence (const Chain &chain) |
Remove evidence on the given instance's elt. More... | |
void | clearEvidence () |
Remove all evidences. More... | |
Public Types | |
typedef NodeProperty< const Potential< GUM_SCALAR > *> | EMap |
Code alias. More... | |
typedef NodeProperty< const Potential< GUM_SCALAR > *>::iterator_safe | EMapIterator |
Code alias. More... | |
typedef NodeProperty< const Potential< GUM_SCALAR > *>::const_iterator_safe | EMapConstIterator |
Code alias. More... | |
Protected Attributes | |
Protected members. | |
PRM< GUM_SCALAR > const * | _prm |
The PRM<GUM_SCALAR> on which inference is done. More... | |
PRMSystem< GUM_SCALAR > const * | _sys |
The Model on which inference is done. More... | |
Query methods. | |
typedef PRMInference< GUM_SCALAR >::Chain | Chain |
Code alias. More... | |
virtual void | _evidenceAdded (const Chain &chain) |
See PRMInference::_evidenceAdded(). More... | |
virtual void | _evidenceRemoved (const Chain &chain) |
See PRMInference::_evidenceRemoved(). More... | |
virtual void | _marginal (const Chain &chain, Potential< GUM_SCALAR > &m) |
See PRMInference::_marginal(). More... | |
virtual void | _joint (const std::vector< Chain > &queries, Potential< GUM_SCALAR > &j) |
See PRMInference::_joint(). More... | |
This class is an implementation of the Structured Value Elimination algorithm on PRM<GUM_SCALAR>.
|
private |
|
private |
|
private |
|
protected |
|
inherited |
Code alias.
Definition at line 57 of file PRMInference.h.
|
inherited |
Code alias.
Definition at line 66 of file PRMInference.h.
|
inherited |
Code alias.
Definition at line 62 of file PRMInference.h.
INLINE gum::prm::SVED< GUM_SCALAR >::SVED | ( | const PRM< GUM_SCALAR > & | prm, |
const PRMSystem< GUM_SCALAR > & | model | ||
) |
Default Constructor.
Definition at line 494 of file SVED_tpl.h.
gum::prm::SVED< GUM_SCALAR >::~SVED | ( | ) |
Destructor.
Definition at line 32 of file SVED_tpl.h.
|
private |
Returns true if second can be eliminated before first.
Definition at line 524 of file SVED_tpl.h.
References gum::prm::SVED< GUM_SCALAR >::__class_elim_order, gum::prm::SVED< GUM_SCALAR >::__initElimOrder(), gum::prm::SVED< GUM_SCALAR >::__trim(), gum::SequenceImplementation< Key, Alloc, Gen >::pos(), and gum::prm::PRMInstance< GUM_SCALAR >::type().
Referenced by gum::prm::SVED< GUM_SCALAR >::__reduceElimList().
|
private |
Returns true if second can be eliminated before first.
Definition at line 43 of file SVED_tpl.h.
References gum::prm::eliminateNodes(), gum::StaticTriangulation::eliminationOrder(), gum::List< Val, Alloc >::empty(), gum::Set< Key, Alloc >::exists(), gum::List< Val, Alloc >::front(), gum::prm::PRMInstance< GUM_SCALAR >::get(), gum::prm::PRMInstance< GUM_SCALAR >::getInstances(), gum::prm::PRMInstance< GUM_SCALAR >::getRefAttr(), gum::Set< Key, Alloc >::insert(), gum::List< Val, Alloc >::insert(), gum::prm::InstanceBayesNet< GUM_SCALAR >::modalities(), gum::DAGmodel::moralGraph(), gum::List< Val, Alloc >::popFront(), and gum::prm::InstanceBayesNet< GUM_SCALAR >::variable().
|
private |
Returns true if second can be eliminated before first.
Definition at line 113 of file SVED_tpl.h.
References gum::prm::eliminateNodes(), gum::List< Val, Alloc >::empty(), gum::List< Val, Alloc >::front(), gum::prm::PRMInstance< GUM_SCALAR >::getInstances(), gum::prm::PRMInstance< GUM_SCALAR >::getRefAttr(), gum::Set< Key, Alloc >::insert(), gum::List< Val, Alloc >::popFront(), gum::prm::PRMInstance< GUM_SCALAR >::type(), and gum::prm::InstanceBayesNet< GUM_SCALAR >::variable().
Referenced by gum::prm::SVED< GUM_SCALAR >::__reduceElimList().
|
private |
Returns true if second can be eliminated before first.
Definition at line 186 of file SVED_tpl.h.
References gum::prm::eliminateNodes(), gum::prm::PRMInstance< GUM_SCALAR >::getInstances(), gum::prm::PRMInstance< GUM_SCALAR >::getRefAttr(), gum::Set< Key, Alloc >::insert(), gum::List< Val, Alloc >::insert(), gum::prm::PRMInstance< GUM_SCALAR >::type(), and gum::prm::InstanceBayesNet< GUM_SCALAR >::variable().
|
private |
Returns true if second can be eliminated before first.
Definition at line 259 of file SVED_tpl.h.
References gum::prm::eliminateNode(), gum::StaticTriangulation::eliminationOrder(), gum::Set< Key, Alloc >::insert(), gum::prm::InstanceBayesNet< GUM_SCALAR >::modalities(), and gum::DAGmodel::moralGraph().
|
private |
Returns true if second can be eliminated before first.
Definition at line 536 of file SVED_tpl.h.
References gum::prm::PRMInstance< GUM_SCALAR >::get(), and gum::prm::PRMClassElement< GUM_SCALAR >::safeName().
|
private |
Returns true if second can be eliminated before first.
Definition at line 556 of file SVED_tpl.h.
References gum::prm::SVED< GUM_SCALAR >::__bb, gum::prm::SVED< GUM_SCALAR >::__initReqSets(), and gum::prm::SVED< GUM_SCALAR >::__req_set.
|
private |
Returns true if second can be eliminated before first.
Definition at line 512 of file SVED_tpl.h.
References gum::prm::SVED< GUM_SCALAR >::__elim_orders.
|
private |
Returns true if second can be eliminated before first.
Definition at line 567 of file SVED_tpl.h.
References gum::prm::SVED< GUM_SCALAR >::__bb, gum::prm::SVED< GUM_SCALAR >::__initReqSets(), and gum::prm::SVED< GUM_SCALAR >::__req_set.
|
private |
Returns true if second can be eliminated before first.
Definition at line 368 of file SVED_tpl.h.
References gum::Set< Key, Alloc >::contains(), gum::prm::ClassDependencyGraph< GUM_SCALAR >::dag(), gum::SequenceImplementation< Key, Alloc, std::is_scalar< Key >::value >::exists(), gum::prm::ClassDependencyGraph< GUM_SCALAR >::get(), gum::Set< Key, Alloc >::insert(), gum::SequenceImplementation< Key, Alloc, Gen >::insert(), and gum::SequenceImplementation< Key, Alloc, std::is_scalar< Key >::value >::insert().
Referenced by gum::prm::SVED< GUM_SCALAR >::__checkElimOrder().
|
private |
Returns true if second can be eliminated before first.
Definition at line 299 of file SVED_tpl.h.
References gum::prm::PRMClassElementContainer< GUM_SCALAR >::containerDag(), gum::prm::eliminateNode(), gum::Set< Key, Alloc >::erase(), gum::Set< Key, Alloc >::exists(), gum::prm::PRMClass< GUM_SCALAR >::get(), gum::Set< Key, Alloc >::insert(), gum::prm::PRMClass< GUM_SCALAR >::isOutputNode(), gum::prm::ClassBayesNet< GUM_SCALAR >::modalities(), gum::DAGmodel::moralGraph(), gum::List< Val, Alloc >::pushBack(), gum::Set< Key, Alloc >::size(), gum::prm::PRMInstance< GUM_SCALAR >::type(), and gum::prm::PRMClassElement< GUM_SCALAR >::type().
|
private |
Returns true if second can be eliminated before first.
Definition at line 463 of file SVED_tpl.h.
References GUM_ERROR, gum::Set< Key, Alloc >::insert(), and gum::prm::PRMInstance< GUM_SCALAR >::type().
Referenced by gum::prm::SVED< GUM_SCALAR >::__getAttrSet(), and gum::prm::SVED< GUM_SCALAR >::__getSCSet().
|
private |
Returns true if second can be eliminated before first.
Definition at line 504 of file SVED_tpl.h.
References gum::prm::PRMInference< GUM_SCALAR >::evidence(), and gum::Set< Key, Alloc >::insert().
|
private |
Returns true if second can be eliminated before first.
Definition at line 280 of file SVED_tpl.h.
References gum::prm::PRMInstance< GUM_SCALAR >::bijection(), gum::prm::copyPotential(), and gum::Set< Key, Alloc >::insert().
|
private |
Returns true if second can be eliminated before first.
Definition at line 577 of file SVED_tpl.h.
References gum::prm::SVED< GUM_SCALAR >::__bb, gum::prm::SVED< GUM_SCALAR >::__checkElimOrder(), and gum::prm::SVED< GUM_SCALAR >::__eliminateNodesDownward().
|
private |
Returns true if second can be eliminated before first.
Definition at line 517 of file SVED_tpl.h.
Referenced by gum::prm::SVED< GUM_SCALAR >::__checkElimOrder().
|
protectedvirtual |
See PRMInference::_evidenceAdded().
Implements gum::prm::PRMInference< GUM_SCALAR >.
Definition at line 543 of file SVED_tpl.h.
|
protectedvirtual |
See PRMInference::_evidenceRemoved().
Implements gum::prm::PRMInference< GUM_SCALAR >.
Definition at line 549 of file SVED_tpl.h.
|
protectedvirtual |
Implements gum::prm::PRMInference< GUM_SCALAR >.
Definition at line 457 of file SVED_tpl.h.
References GUM_ERROR.
|
protectedvirtual |
See PRMInference::_marginal().
Implements gum::prm::PRMInference< GUM_SCALAR >.
Definition at line 405 of file SVED_tpl.h.
References gum::prm::PRMClassElement< GUM_SCALAR >::id(), gum::Set< Key, Alloc >::insert(), gum::MultiDimDecorator< GUM_SCALAR >::nbrDim(), gum::Potential< GUM_SCALAR >::normalize(), and gum::MultiDimDecorator< GUM_SCALAR >::variablesSequence().
|
inherited |
Add an evidence to the given instance's elt.
chain | The variable being observed. |
p | The Potential added (by copy) as evidence. |
NotFound | Raised if elt does not belong to i. |
OperationNotAllowed | Raised if p is inconsistent with elt. |
Definition at line 106 of file PRMInference_tpl.h.
Referenced by gum::prm::o3prmr::O3prmrInterpreter::observe().
|
inherited |
Remove all evidences.
Definition at line 33 of file PRMInference_tpl.h.
|
inherited |
Returns EMap of evidences over i.
NotFound | if i has no evidence. |
Definition at line 153 of file PRMInference_tpl.h.
Referenced by gum::prm::SVED< GUM_SCALAR >::__insertEvidence(), gum::prm::SVE< GUM_SCALAR >::__insertEvidence(), gum::prm::StructuredInference< GUM_SCALAR >::__reduceAloneInstances(), and gum::prm::StructuredInference< GUM_SCALAR >::_marginal().
|
inherited |
Returns EMap of evidences over i.
NotFound | if i has no evidence. |
Definition at line 174 of file PRMInference_tpl.h.
|
inherited |
Returns EMap of evidences over i.
NotFound | if i has no evidence. |
Definition at line 163 of file PRMInference_tpl.h.
|
inherited |
Returns EMap of evidences over i.
NotFound | if i has no evidence. |
Definition at line 184 of file PRMInference_tpl.h.
|
inherited |
Returns true if i has evidence.
Definition at line 194 of file PRMInference_tpl.h.
Referenced by gum::prm::o3prmr::O3prmrInterpreter::observe(), and gum::prm::o3prmr::O3prmrInterpreter::unobserve().
|
inherited |
Returns EMap of evidences over i.
Definition at line 200 of file PRMInference_tpl.h.
|
inherited |
Returns true if i has evidence on PRMAttribute<GUM_SCALAR> a.
Definition at line 206 of file PRMInference_tpl.h.
|
inherited |
Returns true if i has evidence on PRMAttribute<GUM_SCALAR> a.
Definition at line 213 of file PRMInference_tpl.h.
Referenced by gum::prm::StructuredInference< GUM_SCALAR >::__insertNodeInElimLists(), gum::prm::StructuredInference< GUM_SCALAR >::__reduceAloneInstances(), and gum::prm::StructuredInference< GUM_SCALAR >::_marginal().
|
inherited |
Compute the joint probability of the formals attributes pointed by chains and stores it in m.
chains | A Set of strings of the form instance.attribute. |
j | An empty CPF which will be filed by the joint probability over chains. |
NotFound | Raised if some chain in chains does not point to a formal attribute. |
OperationNotAllowed | Raise if m is not empty. |
Definition at line 260 of file PRMInference_tpl.h.
|
inherited |
Compute the marginal of the formal attribute pointed by chain and stores it in m.
chain | A string of the form instance.attribute. |
m | An empty CPF which will be filed by the marginal of chain. |
NotFound | Raised if chain is invalid. |
WrongType | Raised if chain does not point to an PRMAttribute<GUM_SCALAR>. |
OperationNotAllowed | Raise if m is not empty. |
Definition at line 231 of file PRMInference_tpl.h.
Referenced by gum::prm::o3prmr::O3prmrInterpreter::query().
|
virtual |
Returns the name of the current inference algorithm.
Implements gum::prm::PRMInference< GUM_SCALAR >.
Definition at line 600 of file SVED_tpl.h.
|
inherited |
Remove evidence on the given instance's elt.
chain | The variable being observed. |
NotFound | Raised if the given names are not found. |
WrongType | Raised if the elt is not an PRMAttribute<GUM_SCALAR>. |
Definition at line 218 of file PRMInference_tpl.h.
Referenced by gum::prm::o3prmr::O3prmrInterpreter::unobserve().
|
private |
Definition at line 129 of file SVED.h.
Referenced by gum::prm::SVED< GUM_SCALAR >::__getAttrSet(), gum::prm::SVED< GUM_SCALAR >::__getSCSet(), and gum::prm::SVED< GUM_SCALAR >::__reduceElimList().
|
private |
Definition at line 127 of file SVED.h.
Referenced by gum::prm::SVED< GUM_SCALAR >::__checkElimOrder().
|
private |
Definition at line 118 of file SVED.h.
Referenced by gum::prm::SVED< GUM_SCALAR >::__getElimOrder().
|
private |
The Set<NodeId> returned by StructuredBayesBall<GUM_SCALAR> is unique for each family of instances with the same requisite set (thus the same lifted potentials).
|
private |
First pair -> requisite Attributes Second pair -> requisite SlotChains.
Definition at line 135 of file SVED.h.
Referenced by gum::prm::SVED< GUM_SCALAR >::__getAttrSet(), and gum::prm::SVED< GUM_SCALAR >::__getSCSet().
|
protectedinherited |
The PRM<GUM_SCALAR> on which inference is done.
Definition at line 210 of file PRMInference.h.
Referenced by gum::prm::StructuredInference< GUM_SCALAR >::operator=(), gum::prm::PRMInference< double >::operator=(), and gum::prm::StructuredInference< GUM_SCALAR >::StructuredInference().
|
protectedinherited |
The Model on which inference is done.
Definition at line 213 of file PRMInference.h.
Referenced by gum::prm::StructuredInference< GUM_SCALAR >::__reduceAloneInstances(), gum::prm::StructuredInference< GUM_SCALAR >::operator=(), gum::prm::PRMInference< double >::operator=(), gum::prm::StructuredInference< GUM_SCALAR >::searchPatterns(), and gum::prm::StructuredInference< GUM_SCALAR >::StructuredInference().