![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
<agrum/PRM/groundedInference.h> More...
#include <groundedInference.h>
Public Member Functions | |
Constructor & destructor. | |
GroundedInference (const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &system) | |
Default constructor. More... | |
virtual | ~GroundedInference () |
Destructor. More... | |
Getters & setters. | |
MarginalTargetedInference< GUM_SCALAR > & | getBNInference () |
Returns the bayesnet inference engine used by this class. More... | |
void | setBNInference (MarginalTargetedInference< GUM_SCALAR > *bn_inf) |
Defines the bayesnet inference engine used by this class. More... | |
virtual std::string | name () const |
Returns the bayesnet inference engine used by this class. 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 Member Functions | |
Private evidence handling methods and members. | |
virtual void | evidenceAdded_ (const typename PRMInference< GUM_SCALAR >::Chain &chain) |
This method is called whenever an evidence is added, but AFTER any processing made by PRMInference. More... | |
virtual void | evidenceRemoved_ (const typename PRMInference< GUM_SCALAR >::Chain &chain) |
This method is called whenever an evidence is removed, but BEFORE any processing made by PRMInference. More... | |
virtual void | posterior_ (const typename PRMInference< GUM_SCALAR >::Chain &chain, Potential< GUM_SCALAR > &m) |
Generic method to compute the marginal of given element. More... | |
virtual void | joint_ (const std::vector< typename PRMInference< GUM_SCALAR >::Chain > &queries, Potential< GUM_SCALAR > &j) |
Generic method to compute the marginal of given element. More... | |
Protected members. | |
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... | |
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... | |
<agrum/PRM/groundedInference.h>
This class is used to realise grounded inference in a PRM<GUM_SCALAR>.
The best way to build this class is to use the static creation methods.
Definition at line 46 of file groundedInference.h.
|
inherited |
Code alias.
Definition at line 55 of file PRMInference.h.
|
inherited |
Code alias.
Definition at line 58 of file PRMInference.h.
|
inherited |
Code alias.
Definition at line 65 of file PRMInference.h.
|
inherited |
Code alias.
Definition at line 61 of file PRMInference.h.
INLINE gum::prm::GroundedInference< GUM_SCALAR >::GroundedInference | ( | const PRM< GUM_SCALAR > & | prm, |
const PRMSystem< GUM_SCALAR > & | system | ||
) |
Default constructor.
Definition at line 88 of file groundedInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
virtual |
Destructor.
Definition at line 35 of file groundedInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
Copy constructor.
Definition at line 96 of file groundedInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
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 105 of file PRMInference_tpl.h.
|
inherited |
Remove all evidences.
Definition at line 35 of file PRMInference_tpl.h.
|
inherited |
Returns EMap of evidences over i.
NotFound | if i has no evidence. |
Definition at line 151 of file PRMInference_tpl.h.
|
inherited |
Returns EMap of evidences over i.
NotFound | if i has no evidence. |
Definition at line 167 of file PRMInference_tpl.h.
|
inherited |
Returns EMap of evidences over i.
NotFound | if i has no evidence. |
Definition at line 159 of file PRMInference_tpl.h.
|
inherited |
Returns EMap of evidences over i.
NotFound | if i has no evidence. |
Definition at line 175 of file PRMInference_tpl.h.
|
protectedvirtual |
This method is called whenever an evidence is added, but AFTER any processing made by PRMInference.
Definition at line 49 of file groundedInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
protectedpure virtualinherited |
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 >.
|
protectedvirtual |
This method is called whenever an evidence is removed, but BEFORE any processing made by PRMInference.
Definition at line 68 of file groundedInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
protectedpure virtualinherited |
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 MarginalTargetedInference< GUM_SCALAR > & gum::prm::GroundedInference< GUM_SCALAR >::getBNInference | ( | ) |
Returns the bayesnet inference engine used by this class.
NotFound | Raised if no inference engine have been defined for this class. |
Definition at line 112 of file groundedInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
inherited |
Returns true if i has evidence.
Definition at line 182 of file PRMInference_tpl.h.
|
inherited |
Returns EMap of evidences over i.
Definition at line 187 of file PRMInference_tpl.h.
|
inherited |
Returns true if i has evidence on PRMAttribute<GUM_SCALAR> a.
Definition at line 192 of file PRMInference_tpl.h.
|
inherited |
Returns true if i has evidence on PRMAttribute<GUM_SCALAR> a.
Definition at line 197 of file PRMInference_tpl.h.
|
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 241 of file PRMInference_tpl.h.
|
protectedvirtual |
Generic method to compute the marginal of given element.
queries | Set of pairs of PRMInstance and PRMAttribute. |
j | CPF filled with the joint probability of queries. It is initialized properly. |
Definition at line 149 of file groundedInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
protectedpure virtualinherited |
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 >.
|
virtual |
Returns the bayesnet inference engine used by this class.
NotFound | Raised if no inference engine have been defined for this class. |
Implements gum::prm::PRMInference< GUM_SCALAR >.
Definition at line 156 of file groundedInference_tpl.h.
|
private |
Copy operator.
Definition at line 106 of file groundedInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
inherited |
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.
|
protectedvirtual |
Generic method to compute the marginal of given element.
chain | |
m | CPF filled with the marginal of elt. It is initialized properly. |
Definition at line 129 of file groundedInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
protectedpure virtualinherited |
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 >.
|
inherited |
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.
INLINE void gum::prm::GroundedInference< GUM_SCALAR >::setBNInference | ( | MarginalTargetedInference< GUM_SCALAR > * | bn_inf | ) |
Defines the bayesnet inference engine used by this class.
The inference engine is given to this class, it will be deleted when ~GroundedInference() is called.
bn_inf | The bayesnet inference engine used by this class. |
OperationNotAllowed | If bn_inf does not inference over the SystemBayesNet of this class. |
Definition at line 121 of file groundedInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
The bayesnet inference engine used by this class.
Definition at line 126 of file groundedInference.h.
|
private |
Definition at line 128 of file groundedInference.h.
|
protectedinherited |
The PRM<GUM_SCALAR> on which inference is done.
Definition at line 207 of file PRMInference.h.
|
protectedinherited |
The Model on which inference is done.
Definition at line 210 of file PRMInference.h.