![]() |
aGrUM
0.20.2
a C++ library for (probabilistic) graphical models
|
<agrum/PRM/structuredInference.h> More...
#include <structuredInference.h>
Public Attributes | |
Timer | timer |
Timer | plopTimer |
double | triang_time |
double | mining_time |
double | pattern_time |
double | inner_time |
double | obs_time |
double | full_time |
Public Member Functions | |
std::string | info () const |
Constructor & destructor. | |
StructuredInference (const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &system, gspan::SearchStrategy< GUM_SCALAR > *strategy=0) | |
Default constructor. More... | |
StructuredInference (const StructuredInference &source) | |
Copy constructor. More... | |
virtual | ~StructuredInference () |
Destructor. More... | |
StructuredInference & | operator= (const StructuredInference &source) |
Copy operator. More... | |
Getters and setters. | |
void | setPatternMining (bool b) |
Tells this algorithm to use pattern mining or not. More... | |
virtual std::string | name () const |
Tells this algorithm to use pattern mining or not. More... | |
GSpan< GUM_SCALAR > & | gspan () |
Returns the instance of gspan used to search patterns. More... | |
const GSpan< GUM_SCALAR > & | gspan () const |
Returns the instance of gspan used to search patterns. More... | |
void | searchPatterns () |
Search for patterns without doing any computations. 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 | |
Protected members. | |
virtual void | evidenceAdded_ (const typename PRMInference< GUM_SCALAR >::Chain &chain) |
See PRMInference::evidenceAdded_(). More... | |
virtual void | evidenceRemoved_ (const typename PRMInference< GUM_SCALAR >::Chain &chain) |
See PRMInference::evidenceRemoved_(). More... | |
virtual void | posterior_ (const typename PRMInference< GUM_SCALAR >::Chain &chain, Potential< GUM_SCALAR > &m) |
See PRMInference::posterior_(). More... | |
virtual void | joint_ (const std::vector< typename PRMInference< GUM_SCALAR >::Chain > &queries, Potential< GUM_SCALAR > &j) |
See PRMInference::joint_(). More... | |
Classes | |
struct | CData |
Private structure to represent data about a Class<GUM_SCALAR>. More... | |
struct | PData |
Private structure to represent data about a pattern. More... | |
struct | RGData |
Private structure to represent data about a reduced graph. 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/structuredInference.h>
This PRM<GUM_SCALAR> inference algorithm exploits the GSpan<GUM_SCALAR> algorithm to discover new patters and exploit them in a structured way.
Definition at line 63 of file structuredInference.h.
|
inherited |
Code alias.
Definition at line 56 of file PRMInference.h.
|
inherited |
Code alias.
Definition at line 59 of file PRMInference.h.
|
inherited |
Code alias.
Definition at line 68 of file PRMInference.h.
|
inherited |
Code alias.
Definition at line 64 of file PRMInference.h.
gum::prm::StructuredInference< GUM_SCALAR >::StructuredInference | ( | const PRM< GUM_SCALAR > & | prm, |
const PRMSystem< GUM_SCALAR > & | system, | ||
gspan::SearchStrategy< GUM_SCALAR > * | strategy = 0 |
||
) |
Default constructor.
Definition at line 35 of file structuredInference_tpl.h.
gum::prm::StructuredInference< GUM_SCALAR >::StructuredInference | ( | const StructuredInference< GUM_SCALAR > & | source | ) |
Copy constructor.
Definition at line 52 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
virtual |
Destructor.
Definition at line 62 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
Add the nodes in the reduced graph.
Add edges in the reduced graph.
Definition at line 744 of file structuredInference_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 108 of file PRMInference_tpl.h.
|
private |
Definition at line 415 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
Build the DAG corresponding to Pattern data.pattern, initialize pool with all the Potentials of all variables in data.pattern. The first match of data.pattern (aka data.match) is used.
Definition at line 352 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
This calls reducePattern__() over each pattern and then build the reduced graph which is used for inference. The reduce graph is a triangulated instance graph.
Definition at line 209 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
inherited |
Remove all evidences.
Definition at line 35 of file PRMInference_tpl.h.
|
private |
Add in data.queries() any queried variable in one of data.pattern matches.
Proceeds with the elimination of observed variables in math and then call translatePotSet__().
Definition at line 502 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
Definition at line 480 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
inherited |
Returns EMap of evidences over i.
NotFound | if i has no evidence. |
Definition at line 156 of file PRMInference_tpl.h.
|
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.
|
protectedvirtual |
|
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 |
See PRMInference::evidenceRemoved_().
Definition at line 99 of file structuredInference_tpl.h.
|
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 GSpan< GUM_SCALAR > & gum::prm::StructuredInference< GUM_SCALAR >::gspan | ( | ) |
Returns the instance of gspan used to search patterns.
Definition at line 1024 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
INLINE const GSpan< GUM_SCALAR > & gum::prm::StructuredInference< GUM_SCALAR >::gspan | ( | ) | const |
Returns the instance of gspan used to search patterns.
Definition at line 1030 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
inherited |
Returns true if i has evidence.
Definition at line 197 of file PRMInference_tpl.h.
|
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.
std::string gum::prm::StructuredInference< GUM_SCALAR >::info | ( | ) | const |
Definition at line 183 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
Definition at line 315 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
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 264 of file PRMInference_tpl.h.
|
protectedvirtual |
Definition at line 176 of file structuredInference_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 |
Tells this algorithm to use pattern mining or not.
Implements gum::prm::PRMInference< GUM_SCALAR >.
Definition at line 1019 of file structuredInference_tpl.h.
StructuredInference< GUM_SCALAR > & gum::prm::StructuredInference< GUM_SCALAR >::operator= | ( | const StructuredInference< GUM_SCALAR > & | source | ) |
Copy operator.
Definition at line 83 of file structuredInference_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 234 of file PRMInference_tpl.h.
|
protectedvirtual |
See PRMInference::posterior_().
Definition at line 103 of file structuredInference_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 >.
|
private |
Add the reduced potentials of instances not in any used patterns.
Definition at line 619 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
Proceed with the elimination of all inner variables (observed or not) of all usable matches of Pattern p. Inner variables which are part of the query are not eliminated.
Definition at line 245 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
Definition at line 427 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
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 221 of file PRMInference_tpl.h.
|
private |
Definition at line 1035 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
void gum::prm::StructuredInference< GUM_SCALAR >::searchPatterns | ( | ) |
Search for patterns without doing any computations.
Definition at line 974 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
INLINE void gum::prm::StructuredInference< GUM_SCALAR >::setPatternMining | ( | bool | b | ) |
Tells this algorithm to use pattern mining or not.
Definition at line 983 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
Definition at line 988 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
Definition at line 995 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
Definition at line 1002 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
Translate a given Potential Set into one w.r.t. variables in match.
Definition at line 524 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
Mapping between a Class<GUM_SCALAR> and data about instances reduced using only Class<GUM_SCALAR> level information.
Definition at line 262 of file structuredInference.h.
|
private |
Unreduce the match containing the query.
Used to create strings
Definition at line 367 of file structuredInference.h.
|
private |
Mapping between a Pattern's match and its potential pool after inner variables were eliminated.
Definition at line 256 of file structuredInference.h.
|
private |
Flag with an explicit name.
Definition at line 283 of file structuredInference.h.
double gum::prm::StructuredInference< GUM_SCALAR >::full_time |
Definition at line 384 of file structuredInference.h.
|
private |
Pointer over th GSpan<GUM_SCALAR> instance used by this class.
Definition at line 249 of file structuredInference.h.
double gum::prm::StructuredInference< GUM_SCALAR >::inner_time |
Definition at line 382 of file structuredInference.h.
|
private |
Flag which tells to use pattern mining or not.
Definition at line 280 of file structuredInference.h.
double gum::prm::StructuredInference< GUM_SCALAR >::mining_time |
Definition at line 380 of file structuredInference.h.
double gum::prm::StructuredInference< GUM_SCALAR >::obs_time |
Definition at line 383 of file structuredInference.h.
|
private |
Definition at line 267 of file structuredInference.h.
double gum::prm::StructuredInference< GUM_SCALAR >::pattern_time |
Definition at line 381 of file structuredInference.h.
|
private |
The pattern data of the pattern which one of its matches contains the query.
Definition at line 277 of file structuredInference.h.
Timer gum::prm::StructuredInference< GUM_SCALAR >::plopTimer |
Definition at line 378 of file structuredInference.h.
|
protectedinherited |
The PRM<GUM_SCALAR> on which inference is done.
Definition at line 213 of file PRMInference.h.
|
private |
The query.
Definition at line 273 of file structuredInference.h.
|
private |
Definition at line 284 of file structuredInference.h.
|
private |
This keeps track of reduced instances.
Definition at line 270 of file structuredInference.h.
|
protectedinherited |
The Model on which inference is done.
Definition at line 216 of file PRMInference.h.
Timer gum::prm::StructuredInference< GUM_SCALAR >::timer |
Definition at line 377 of file structuredInference.h.
|
private |
Keeping track of create potentials to delete them after inference.
Definition at line 265 of file structuredInference.h.
double gum::prm::StructuredInference< GUM_SCALAR >::triang_time |
Definition at line 379 of file structuredInference.h.