![]() |
aGrUM
0.16.0
|
<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 | 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 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 | _marginal (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 | _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... | |
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 47 of file groundedInference.h.
|
inherited |
Code alias.
Definition at line 57 of file PRMInference.h.
|
inherited |
Code alias.
Definition at line 60 of file PRMInference.h.
|
inherited |
Code alias.
Definition at line 69 of file PRMInference.h.
|
inherited |
Code alias.
Definition at line 65 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 89 of file groundedInference_tpl.h.
|
virtual |
Destructor.
Definition at line 36 of file groundedInference_tpl.h.
|
private |
Copy constructor.
Definition at line 97 of file groundedInference_tpl.h.
References GUM_ERROR, and gum::prm::GroundedInference< GUM_SCALAR >::operator=().
|
protectedvirtual |
This method is called whenever an evidence is added, but AFTER any processing made by PRMInference.
Definition at line 50 of file groundedInference_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::add(), gum::MultiDimDecorator< GUM_SCALAR >::get(), gum::Instantiation::inc(), gum::prm::PRMInference< GUM_SCALAR >::name(), gum::MultiDimDecorator< GUM_SCALAR >::set(), and gum::Instantiation::setFirst().
|
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 70 of file groundedInference_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::erase(), and gum::prm::PRMInference< GUM_SCALAR >::name().
|
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 >.
|
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 152 of file groundedInference_tpl.h.
References GUM_ERROR.
|
protectedpure virtualinherited |
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 >.
|
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 130 of file groundedInference_tpl.h.
References gum::prm::GroundedInference< GUM_SCALAR >::__inf, gum::prm::GroundedInference< GUM_SCALAR >::__obs, GUM_ERROR, and gum::prm::PRMInference< GUM_SCALAR >::name().
|
protectedpure virtualinherited |
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 >.
|
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 109 of file PRMInference_tpl.h.
Referenced by gum::prm::o3prmr::O3prmrInterpreter::observe().
|
inherited |
Remove all evidences.
Definition at line 36 of file PRMInference_tpl.h.
|
inherited |
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().
|
inherited |
Returns EMap of evidences over i.
NotFound | if i has no evidence. |
Definition at line 177 of file PRMInference_tpl.h.
|
inherited |
Returns EMap of evidences over i.
NotFound | if i has no evidence. |
Definition at line 166 of file PRMInference_tpl.h.
|
inherited |
Returns EMap of evidences over i.
NotFound | if i has no evidence. |
Definition at line 187 of file PRMInference_tpl.h.
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 113 of file groundedInference_tpl.h.
References gum::prm::GroundedInference< GUM_SCALAR >::__inf, and GUM_ERROR.
|
inherited |
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().
|
inherited |
Returns EMap of evidences over i.
Definition at line 203 of file PRMInference_tpl.h.
|
inherited |
Returns true if i has evidence on PRMAttribute<GUM_SCALAR> a.
Definition at line 209 of file PRMInference_tpl.h.
|
inherited |
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().
|
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 263 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 234 of file PRMInference_tpl.h.
Referenced by gum::prm::o3prmr::O3prmrInterpreter::query().
|
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 159 of file groundedInference_tpl.h.
|
private |
Copy operator.
Definition at line 107 of file groundedInference_tpl.h.
References GUM_ERROR.
Referenced by gum::prm::GroundedInference< GUM_SCALAR >::GroundedInference().
|
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 221 of file PRMInference_tpl.h.
Referenced by gum::prm::o3prmr::O3prmrInterpreter::unobserve().
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 122 of file groundedInference_tpl.h.
References gum::prm::GroundedInference< GUM_SCALAR >::__inf.
|
private |
The bayesnet inference engine used by this class.
Definition at line 132 of file groundedInference.h.
Referenced by gum::prm::GroundedInference< GUM_SCALAR >::_marginal(), gum::prm::GroundedInference< GUM_SCALAR >::getBNInference(), and gum::prm::GroundedInference< GUM_SCALAR >::setBNInference().
|
private |
Definition at line 134 of file groundedInference.h.
Referenced by gum::prm::GroundedInference< GUM_SCALAR >::_marginal().
|
protectedinherited |
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().
|
protectedinherited |
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().