![]() |
aGrUM
0.16.0
|
This abstract class is used as base class for all inference class on PRM<GUM_SCALAR>. More...
#include <agrum/PRM/PRMInference.h>
Public Member Functions | |
Constructor & destructor. | |
PRMInference (const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &system) | |
Default constructor. More... | |
PRMInference (const PRMInference &source) | |
Copy constructor. More... | |
virtual | ~PRMInference () |
Destructor. More... | |
PRMInference & | operator= (const PRMInference &source) |
Copy operator. More... | |
Getters & setters. | |
virtual std::string | name () const =0 |
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 std::pair< const PRMInstance< GUM_SCALAR > *, const PRMAttribute< GUM_SCALAR > *> | Chain |
Code alias. More... | |
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 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... | |
virtual void | _evidenceAdded (const Chain &chain)=0 |
This method is called whenever an evidence is added, but AFTER any processing made by PRMInference. More... | |
virtual void | _evidenceRemoved (const Chain &chain)=0 |
This method is called whenever an evidence is removed, but BEFORE any processing made by PRMInference. More... | |
virtual void | _marginal (const Chain &chain, Potential< GUM_SCALAR > &m)=0 |
Generic method to compute the marginal of given element. More... | |
virtual void | _joint (const std::vector< Chain > &queries, Potential< GUM_SCALAR > &j)=0 |
Generic method to compute the marginal of given element. More... | |
Private evidence handling methods and members. | |
typedef HashTable< const PRMInstance< GUM_SCALAR > *, EMap *>::iterator_safe | EvidenceIterator |
Code alias. More... | |
typedef HashTable< const PRMInstance< GUM_SCALAR > *, EMap *>::const_iterator_safe | EvidenceConstIterator |
Code alias. More... | |
HashTable< const PRMInstance< GUM_SCALAR > *, EMap *> | __evidences |
Mapping of evidence over PRMInstance<GUM_SCALAR>'s nodes. More... | |
EMap & | __EMap (const PRMInstance< GUM_SCALAR > *i) |
Private getter over __evidences, if necessary creates an EMap for i. More... | |
This abstract class is used as base class for all inference class on PRM<GUM_SCALAR>.
The main purpose of this class is to give a common interface between all inference algorithms and to handle evidences.
Definition at line 52 of file PRMInference.h.
typedef std::pair< const PRMInstance< GUM_SCALAR >*, const PRMAttribute< GUM_SCALAR >* > gum::prm::PRMInference< GUM_SCALAR >::Chain |
Code alias.
Definition at line 57 of file PRMInference.h.
typedef NodeProperty< const Potential< GUM_SCALAR >* > gum::prm::PRMInference< GUM_SCALAR >::EMap |
Code alias.
Definition at line 60 of file PRMInference.h.
typedef NodeProperty< const Potential< GUM_SCALAR >* >::const_iterator_safe gum::prm::PRMInference< GUM_SCALAR >::EMapConstIterator |
Code alias.
Definition at line 69 of file PRMInference.h.
typedef NodeProperty< const Potential< GUM_SCALAR >* >::iterator_safe gum::prm::PRMInference< GUM_SCALAR >::EMapIterator |
Code alias.
Definition at line 65 of file PRMInference.h.
|
private |
Code alias.
Definition at line 232 of file PRMInference.h.
|
private |
Code alias.
Definition at line 228 of file PRMInference.h.
INLINE gum::prm::PRMInference< GUM_SCALAR >::PRMInference | ( | const PRM< GUM_SCALAR > & | prm, |
const PRMSystem< GUM_SCALAR > & | system | ||
) |
Default constructor.
Definition at line 141 of file PRMInference_tpl.h.
gum::prm::PRMInference< GUM_SCALAR >::PRMInference | ( | const PRMInference< GUM_SCALAR > & | source | ) |
Copy constructor.
Definition at line 48 of file PRMInference_tpl.h.
|
virtual |
Destructor.
Definition at line 149 of file PRMInference_tpl.h.
|
private |
Private getter over __evidences, if necessary creates an EMap for i.
Definition at line 98 of file PRMInference_tpl.h.
|
protectedpure virtual |
This method is called whenever an evidence is added, but AFTER any processing made by PRMInference.
Implemented in gum::prm::SVE< GUM_SCALAR >, and gum::prm::SVED< GUM_SCALAR >.
|
protectedpure virtual |
This method is called whenever an evidence is removed, but BEFORE any processing made by PRMInference.
Implemented in gum::prm::SVE< GUM_SCALAR >, and gum::prm::SVED< GUM_SCALAR >.
|
protectedpure virtual |
Generic method to compute the marginal of given element.
queries | Set of pairs of PRMInstance<GUM_SCALAR> and PRMAttribute<GUM_SCALAR>. |
j | CPF filled with the joint probability of queries. It is initialized properly. |
Implemented in gum::prm::SVE< GUM_SCALAR >, and gum::prm::SVED< GUM_SCALAR >.
|
protectedpure virtual |
Generic method to compute the marginal of given element.
chain | |
m | CPF filled with the marginal of elt. It is initialized properly. |
Implemented in gum::prm::SVE< GUM_SCALAR >, and gum::prm::SVED< GUM_SCALAR >.
void gum::prm::PRMInference< GUM_SCALAR >::addEvidence | ( | const Chain & | chain, |
const Potential< GUM_SCALAR > & | p | ||
) |
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 109 of file PRMInference_tpl.h.
Referenced by gum::prm::o3prmr::O3prmrInterpreter::observe().
void gum::prm::PRMInference< GUM_SCALAR >::clearEvidence | ( | ) |
Remove all evidences.
Definition at line 36 of file PRMInference_tpl.h.
INLINE PRMInference< GUM_SCALAR >::EMap & gum::prm::PRMInference< GUM_SCALAR >::evidence | ( | const PRMInstance< GUM_SCALAR > & | i | ) |
Returns EMap of evidences over i.
NotFound | if i has no evidence. |
Definition at line 156 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().
INLINE PRMInference< GUM_SCALAR >::EMap & gum::prm::PRMInference< GUM_SCALAR >::evidence | ( | const PRMInstance< GUM_SCALAR > * | i | ) |
Returns EMap of evidences over i.
NotFound | if i has no evidence. |
Definition at line 177 of file PRMInference_tpl.h.
INLINE const PRMInference< GUM_SCALAR >::EMap & gum::prm::PRMInference< GUM_SCALAR >::evidence | ( | const PRMInstance< GUM_SCALAR > & | i | ) | const |
Returns EMap of evidences over i.
NotFound | if i has no evidence. |
Definition at line 166 of file PRMInference_tpl.h.
INLINE const PRMInference< GUM_SCALAR >::EMap & gum::prm::PRMInference< GUM_SCALAR >::evidence | ( | const PRMInstance< GUM_SCALAR > * | i | ) | const |
Returns EMap of evidences over i.
NotFound | if i has no evidence. |
Definition at line 187 of file PRMInference_tpl.h.
INLINE bool gum::prm::PRMInference< GUM_SCALAR >::hasEvidence | ( | const PRMInstance< GUM_SCALAR > & | i | ) | const |
Returns true if i has evidence.
Definition at line 197 of file PRMInference_tpl.h.
Referenced by gum::prm::o3prmr::O3prmrInterpreter::observe(), and gum::prm::o3prmr::O3prmrInterpreter::unobserve().
INLINE bool gum::prm::PRMInference< GUM_SCALAR >::hasEvidence | ( | const PRMInstance< GUM_SCALAR > * | i | ) | const |
Returns EMap of evidences over i.
Definition at line 203 of file PRMInference_tpl.h.
INLINE bool gum::prm::PRMInference< GUM_SCALAR >::hasEvidence | ( | const Chain & | chain | ) | const |
Returns true if i has evidence on PRMAttribute<GUM_SCALAR> a.
Definition at line 209 of file PRMInference_tpl.h.
INLINE bool gum::prm::PRMInference< GUM_SCALAR >::hasEvidence | ( | ) | const |
Returns true if i has evidence on PRMAttribute<GUM_SCALAR> a.
Definition at line 216 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().
INLINE void gum::prm::PRMInference< GUM_SCALAR >::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.
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 263 of file PRMInference_tpl.h.
INLINE void gum::prm::PRMInference< GUM_SCALAR >::marginal | ( | const Chain & | chain, |
Potential< GUM_SCALAR > & | m | ||
) |
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 234 of file PRMInference_tpl.h.
Referenced by gum::prm::o3prmr::O3prmrInterpreter::query().
|
pure virtual |
Returns the name of the current inference algorithm.
Implemented in gum::prm::StructuredInference< GUM_SCALAR >, gum::prm::GroundedInference< GUM_SCALAR >, gum::prm::SVE< GUM_SCALAR >, and gum::prm::SVED< GUM_SCALAR >.
Referenced by gum::prm::GroundedInference< GUM_SCALAR >::_evidenceAdded(), gum::prm::GroundedInference< GUM_SCALAR >::_evidenceRemoved(), and gum::prm::GroundedInference< GUM_SCALAR >::_marginal().
PRMInference< GUM_SCALAR > & gum::prm::PRMInference< GUM_SCALAR >::operator= | ( | const PRMInference< GUM_SCALAR > & | source | ) |
Copy operator.
Definition at line 72 of file PRMInference_tpl.h.
INLINE void gum::prm::PRMInference< GUM_SCALAR >::removeEvidence | ( | const Chain & | chain | ) |
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 221 of file PRMInference_tpl.h.
Referenced by gum::prm::o3prmr::O3prmrInterpreter::unobserve().
|
private |
Mapping of evidence over PRMInstance<GUM_SCALAR>'s nodes.
Definition at line 235 of file PRMInference.h.
Referenced by gum::prm::PRMInference< double >::operator=(), and gum::prm::PRMInference< double >::PRMInference().
|
protected |
The PRM<GUM_SCALAR> on which inference is done.
Definition at line 213 of file PRMInference.h.
Referenced by gum::prm::StructuredInference< GUM_SCALAR >::operator=(), gum::prm::PRMInference< double >::operator=(), and gum::prm::StructuredInference< GUM_SCALAR >::StructuredInference().
|
protected |
The Model on which inference is done.
Definition at line 216 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().