![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
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 | posterior (const Chain &chain, Potential< GUM_SCALAR > &m) |
Compute the posterior 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 | posterior_ (const Chain &chain, Potential< GUM_SCALAR > &m)=0 |
Generic method to compute the posterior of given element. More... | |
virtual void | joint_ (const std::vector< Chain > &queries, Potential< GUM_SCALAR > &j)=0 |
Generic method to compute the posterior 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 51 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 55 of file PRMInference.h.
typedef NodeProperty< const Potential< GUM_SCALAR >* > gum::prm::PRMInference< GUM_SCALAR >::EMap |
Code alias.
Definition at line 58 of file PRMInference.h.
typedef NodeProperty< const Potential< GUM_SCALAR >* >::const_iterator_safe gum::prm::PRMInference< GUM_SCALAR >::EMapConstIterator |
Code alias.
Definition at line 65 of file PRMInference.h.
typedef NodeProperty< const Potential< GUM_SCALAR >* >::iterator_safe gum::prm::PRMInference< GUM_SCALAR >::EMapIterator |
Code alias.
Definition at line 61 of file PRMInference.h.
|
private |
Code alias.
Definition at line 225 of file PRMInference.h.
|
private |
Code alias.
Definition at line 222 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 136 of file PRMInference_tpl.h.
gum::prm::PRMInference< GUM_SCALAR >::PRMInference | ( | const PRMInference< GUM_SCALAR > & | source | ) |
Copy constructor.
Definition at line 47 of file PRMInference_tpl.h.
|
virtual |
Destructor.
Definition at line 144 of file PRMInference_tpl.h.
|
private |
Private getter over evidences, if necessary creates an EMap for i.
Definition at line 95 of file PRMInference_tpl.h.
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 105 of file PRMInference_tpl.h.
void gum::prm::PRMInference< GUM_SCALAR >::clearEvidence | ( | ) |
Remove all evidences.
Definition at line 35 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 151 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 167 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 159 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 175 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 >.
INLINE bool gum::prm::PRMInference< GUM_SCALAR >::hasEvidence | ( | const PRMInstance< GUM_SCALAR > & | i | ) | const |
Returns true if i has evidence.
Definition at line 182 of file PRMInference_tpl.h.
INLINE bool gum::prm::PRMInference< GUM_SCALAR >::hasEvidence | ( | const PRMInstance< GUM_SCALAR > * | i | ) | const |
Returns EMap of evidences over i.
Definition at line 187 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 192 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 197 of file PRMInference_tpl.h.
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 241 of file PRMInference_tpl.h.
|
protectedpure virtual |
Generic method to compute the posterior 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 >.
|
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 >.
PRMInference< GUM_SCALAR > & gum::prm::PRMInference< GUM_SCALAR >::operator= | ( | const PRMInference< GUM_SCALAR > & | source | ) |
Copy operator.
Definition at line 69 of file PRMInference_tpl.h.
INLINE void gum::prm::PRMInference< GUM_SCALAR >::posterior | ( | const Chain & | chain, |
Potential< GUM_SCALAR > & | m | ||
) |
Compute the posterior 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 posterior of chain. |
NotFound | Raised if chain is invalid. |
TypeError | Raised if chain does not point to an PRMAttribute<GUM_SCALAR>. |
OperationNotAllowed | Raise if m is not empty. |
Definition at line 215 of file PRMInference_tpl.h.
|
protectedpure virtual |
Generic method to compute the posterior of given element.
chain | |
m | CPF filled with the posterior of elt. It is initialized properly. |
Implemented in gum::prm::SVE< GUM_SCALAR >, and gum::prm::SVED< GUM_SCALAR >.
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. |
TypeError | Raised if the elt is not an PRMAttribute<GUM_SCALAR>. |
Definition at line 202 of file PRMInference_tpl.h.
|
private |
Mapping of evidence over PRMInstance<GUM_SCALAR>'s nodes.
Definition at line 228 of file PRMInference.h.
|
protected |
The PRM<GUM_SCALAR> on which inference is done.
Definition at line 207 of file PRMInference.h.
|
protected |
The Model on which inference is done.
Definition at line 210 of file PRMInference.h.