![]() |
aGrUM
0.20.3
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 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.
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 61 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 690 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
Definition at line 383 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 328 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 203 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
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 467 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
Definition at line 447 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
Definition at line 294 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
Add the reduced potentials of instances not in any used patterns.
Definition at line 576 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 236 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
Definition at line 394 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
Definition at line 973 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
Definition at line 928 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
Definition at line 935 of file structuredInference_tpl.h.
References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().
|
private |
Definition at line 942 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 487 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 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 |
|
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 97 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 963 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 968 of file structuredInference_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.
std::string gum::prm::StructuredInference< GUM_SCALAR >::info | ( | ) | const |
Definition at line 179 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 241 of file PRMInference_tpl.h.
|
protectedvirtual |
Definition at line 172 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 958 of file structuredInference_tpl.h.
StructuredInference< GUM_SCALAR > & gum::prm::StructuredInference< GUM_SCALAR >::operator= | ( | const StructuredInference< GUM_SCALAR > & | source | ) |
Copy operator.
Definition at line 81 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 215 of file PRMInference_tpl.h.
|
protectedvirtual |
See PRMInference::posterior_().
Definition at line 101 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 >.
|
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.
void gum::prm::StructuredInference< GUM_SCALAR >::searchPatterns | ( | ) |
Search for patterns without doing any computations.
Definition at line 913 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 922 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 256 of file structuredInference.h.
|
private |
Unreduce the match containing the query.
Used to create strings
Definition at line 359 of file structuredInference.h.
|
private |
Mapping between a Pattern's match and its potential pool after inner variables were eliminated.
Definition at line 250 of file structuredInference.h.
|
private |
Flag with an explicit name.
Definition at line 277 of file structuredInference.h.
|
private |
Pointer over th GSpan<GUM_SCALAR> instance used by this class.
Definition at line 244 of file structuredInference.h.
|
private |
Flag which tells to use pattern mining or not.
Definition at line 274 of file structuredInference.h.
|
private |
Definition at line 261 of file structuredInference.h.
|
private |
The pattern data of the pattern which one of its matches contains the query.
Definition at line 271 of file structuredInference.h.
|
private |
The query.
Definition at line 267 of file structuredInference.h.
|
private |
Definition at line 278 of file structuredInference.h.
|
private |
This keeps track of reduced instances.
Definition at line 264 of file structuredInference.h.
|
private |
Keeping track of create potentials to delete them after inference.
Definition at line 259 of file structuredInference.h.
double gum::prm::StructuredInference< GUM_SCALAR >::full_time |
Definition at line 376 of file structuredInference.h.
double gum::prm::StructuredInference< GUM_SCALAR >::inner_time |
Definition at line 374 of file structuredInference.h.
double gum::prm::StructuredInference< GUM_SCALAR >::mining_time |
Definition at line 372 of file structuredInference.h.
double gum::prm::StructuredInference< GUM_SCALAR >::obs_time |
Definition at line 375 of file structuredInference.h.
double gum::prm::StructuredInference< GUM_SCALAR >::pattern_time |
Definition at line 373 of file structuredInference.h.
Timer gum::prm::StructuredInference< GUM_SCALAR >::plopTimer |
Definition at line 370 of file structuredInference.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.
Timer gum::prm::StructuredInference< GUM_SCALAR >::timer |
Definition at line 369 of file structuredInference.h.
double gum::prm::StructuredInference< GUM_SCALAR >::triang_time |
Definition at line 371 of file structuredInference.h.