aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
gum::prm::StructuredInference< GUM_SCALAR > Class Template Referenceabstract

<agrum/PRM/structuredInference.h> More...

#include <structuredInference.h>

+ Inheritance diagram for gum::prm::StructuredInference< GUM_SCALAR >:
+ Collaboration diagram for gum::prm::StructuredInference< GUM_SCALAR >:

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...
 
StructuredInferenceoperator= (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.
EMapevidence (const PRMInstance< GUM_SCALAR > &i)
 Returns EMap of evidences over i. More...
 
EMapevidence (const PRMInstance< GUM_SCALAR > *i)
 Returns EMap of evidences over i. More...
 
const EMapevidence (const PRMInstance< GUM_SCALAR > &i) const
 Returns EMap of evidences over i. More...
 
const EMapevidence (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...
 

Detailed Description

template<typename GUM_SCALAR>
class gum::prm::StructuredInference< GUM_SCALAR >

<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.

Member Typedef Documentation

◆ Chain

template<typename GUM_SCALAR>
typedef std::pair< const PRMInstance< GUM_SCALAR >*, const PRMAttribute< GUM_SCALAR >* > gum::prm::PRMInference< GUM_SCALAR >::Chain
inherited

Code alias.

Definition at line 56 of file PRMInference.h.

◆ EMap

template<typename GUM_SCALAR>
typedef NodeProperty< const Potential< GUM_SCALAR >* > gum::prm::PRMInference< GUM_SCALAR >::EMap
inherited

Code alias.

Definition at line 59 of file PRMInference.h.

◆ EMapConstIterator

template<typename GUM_SCALAR>
typedef NodeProperty< const Potential< GUM_SCALAR >* >::const_iterator_safe gum::prm::PRMInference< GUM_SCALAR >::EMapConstIterator
inherited

Code alias.

Definition at line 68 of file PRMInference.h.

◆ EMapIterator

template<typename GUM_SCALAR>
typedef NodeProperty< const Potential< GUM_SCALAR >* >::iterator_safe gum::prm::PRMInference< GUM_SCALAR >::EMapIterator
inherited

Code alias.

Definition at line 64 of file PRMInference.h.

Constructor & Destructor Documentation

◆ StructuredInference() [1/2]

template<typename GUM_SCALAR >
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.

38  :
39  PRMInference< GUM_SCALAR >(prm, system),
40  gspan__(0), pdata__(0), mining__(false), dot__(".") {
41  GUM_CONSTRUCTOR(StructuredInference);
42  gspan__ = new GSpan< GUM_SCALAR >(prm, system, strategy);
43  triang_time = 0.0;
44  mining_time = 0.0;
45  pattern_time = 0.0;
46  inner_time = 0.0;
47  obs_time = 0.0;
48  full_time = 0.0;
49  }
GSpan< GUM_SCALAR > * gspan__
Pointer over th GSpan<GUM_SCALAR> instance used by this class.
std::string dot__
Unreduce the match containing the query.
StructuredInference(const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &system, gspan::SearchStrategy< GUM_SCALAR > *strategy=0)
Default constructor.
bool mining__
Flag which tells to use pattern mining or not.
PData * pdata__
The pattern data of the pattern which one of its matches contains the query.

◆ StructuredInference() [2/2]

template<typename GUM_SCALAR >
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().

53  :
54  PRMInference< GUM_SCALAR >(source),
55  gspan__(0), pdata__(0), mining__(source.mining__), found_query__(false),
56  dot__(".") {
57  GUM_CONS_CPY(StructuredInference);
58  gspan__ = new GSpan< GUM_SCALAR >(*(this->prm_), *(this->sys_));
59  }
GSpan< GUM_SCALAR > * gspan__
Pointer over th GSpan<GUM_SCALAR> instance used by this class.
std::string dot__
Unreduce the match containing the query.
PRMSystem< GUM_SCALAR > const * sys_
The Model on which inference is done.
Definition: PRMInference.h:216
PRM< GUM_SCALAR > const * prm_
The PRM<GUM_SCALAR> on which inference is done.
Definition: PRMInference.h:213
bool found_query__
Flag with an explicit name.
StructuredInference(const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &system, gspan::SearchStrategy< GUM_SCALAR > *strategy=0)
Default constructor.
bool mining__
Flag which tells to use pattern mining or not.
PData * pdata__
The pattern data of the pattern which one of its matches contains the query.
+ Here is the call graph for this function:

◆ ~StructuredInference()

template<typename GUM_SCALAR >
gum::prm::StructuredInference< GUM_SCALAR >::~StructuredInference ( )
virtual

Destructor.

Definition at line 62 of file structuredInference_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

62  {
63  GUM_DESTRUCTOR(StructuredInference);
64  delete this->gspan__;
65 
66  for (const auto& elt: elim_map__)
67  delete elt.second;
68 
69  for (const auto& elt: cdata_map__)
70  delete elt.second;
71 
72  for (const auto elt: trash__)
73  delete (elt);
74 
75  for (const auto& elt: outputs__)
76  delete elt.second;
77 
78  if (pdata__) delete pdata__;
79  }
GSpan< GUM_SCALAR > * gspan__
Pointer over th GSpan<GUM_SCALAR> instance used by this class.
StructuredInference(const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &system, gspan::SearchStrategy< GUM_SCALAR > *strategy=0)
Default constructor.
Set< Potential< GUM_SCALAR > *> trash__
Keeping track of create potentials to delete them after inference.
HashTable< const PRMClass< GUM_SCALAR > *, CData *> cdata_map__
Mapping between a Class<GUM_SCALAR> and data about instances reduced using only Class<GUM_SCALAR> lev...
HashTable< const Sequence< PRMInstance< GUM_SCALAR > *> *, Set< Potential< GUM_SCALAR > *> *> elim_map__
Mapping between a Pattern&#39;s match and its potential pool after inner variables were eliminated...
PData * pdata__
The pattern data of the pattern which one of its matches contains the query.
HashTable< const PRMClass< GUM_SCALAR > *, std::vector< NodeId > *> outputs__
+ Here is the call graph for this function:

Member Function Documentation

◆ addEdgesInReducedGraph__()

template<typename GUM_SCALAR >
void gum::prm::StructuredInference< GUM_SCALAR >::addEdgesInReducedGraph__ ( RGData data)
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().

745  {
746  // We first add edges between variables already in pool (i.e. those of the
747  // reduced instances)
748  NodeId id_1, id_2;
749 
750  for (const auto pot: data.pool) {
751  const Sequence< const DiscreteVariable* >& vars = pot->variablesSequence();
752 
753  for (Size var_1 = 0; var_1 < vars.size(); ++var_1) {
754  if (data.var2node.existsFirst(vars.atPos(var_1))) {
755  id_1 = data.var2node.second(vars.atPos(var_1));
756  } else {
757  id_1 = data.reducedGraph.addNode();
758  data.var2node.insert(vars.atPos(var_1), id_1);
759  data.mods.insert(id_1, vars.atPos(var_1)->domainSize());
760  data.outputs().insert(id_1);
761  }
762 
763  for (Size var_2 = var_1 + 1; var_2 < vars.size(); ++var_2) {
764  if (data.var2node.existsFirst(vars.atPos(var_2))) {
765  id_2 = data.var2node.second(vars.atPos(var_2));
766  } else {
767  id_2 = data.reducedGraph.addNode();
768  data.var2node.insert(vars.atPos(var_2), id_2);
769  data.mods.insert(id_2, vars.atPos(var_2)->domainSize());
770  data.outputs().insert(id_2);
771  }
772 
773  try {
774  data.reducedGraph.addEdge(id_1, id_2);
775  } catch (DuplicateElement&) {}
776  }
777  }
778  }
779 
780  // Adding potentials obtained from reduced patterns
781  for (const auto& elt: elim_map__) {
782  // We add edges between variables in the same reduced patterns
783  for (const auto pot: *elt.second) {
784  data.pool.insert(pot);
785  const Sequence< const DiscreteVariable* >& vars
786  = pot->variablesSequence();
787 
788  for (Size var_1 = 0; var_1 < vars.size(); ++var_1) {
789  if (data.var2node.existsFirst(vars.atPos(var_1))) {
790  id_1 = data.var2node.second(vars.atPos(var_1));
791  } else {
792  id_1 = data.reducedGraph.addNode();
793  data.var2node.insert(vars.atPos(var_1), id_1);
794  data.mods.insert(id_1, vars.atPos(var_1)->domainSize());
795  data.outputs().insert(id_1);
796  }
797 
798  for (Size var_2 = var_1 + 1; var_2 < vars.size(); ++var_2) {
799  if (data.var2node.existsFirst(vars.atPos(var_2))) {
800  id_2 = data.var2node.second(vars.atPos(var_2));
801  } else {
802  id_2 = data.reducedGraph.addNode();
803  data.var2node.insert(vars.atPos(var_2), id_2);
804  data.mods.insert(id_2, vars.atPos(var_2)->domainSize());
805  data.outputs().insert(id_2);
806  }
807 
808  try {
809  data.reducedGraph.addEdge(id_1, id_2);
810  } catch (DuplicateElement&) {}
811  }
812  }
813  }
814  }
815  }
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:47
HashTable< const Sequence< PRMInstance< GUM_SCALAR > *> *, Set< Potential< GUM_SCALAR > *> *> elim_map__
Mapping between a Pattern&#39;s match and its potential pool after inner variables were eliminated...
Size NodeId
Type for node ids.
Definition: graphElements.h:97
+ Here is the call graph for this function:

◆ addEvidence()

template<typename GUM_SCALAR>
void gum::prm::PRMInference< GUM_SCALAR >::addEvidence ( const Chain chain,
const Potential< GUM_SCALAR > &  p 
)
inherited

Add an evidence to the given instance's elt.

Parameters
chainThe variable being observed.
pThe Potential added (by copy) as evidence.
Exceptions
NotFoundRaised if elt does not belong to i.
OperationNotAllowedRaised if p is inconsistent with elt.

Definition at line 108 of file PRMInference_tpl.h.

109  {
110  if (chain.first->exists(chain.second->id())) {
111  if ((p.nbrDim() != 1) || (!p.contains(chain.second->type().variable())))
112  GUM_ERROR(OperationNotAllowed,
113  "illegal evidence for the given PRMAttribute.");
114 
115  Potential< GUM_SCALAR >* e = new Potential< GUM_SCALAR >();
116  e->add(chain.second->type().variable());
117  Instantiation i(*e);
118 
119  for (i.setFirst(); !i.end(); i.inc())
120  e->set(i, p.get(i));
121 
122  PRMInference< GUM_SCALAR >::EMap& emap = EMap__(chain.first);
123 
124  if (emap.exists(chain.second->id())) {
125  delete emap[chain.second->id()];
126  emap[chain.second->id()] = e;
127  } else {
128  emap.insert(chain.second->id(), e);
129  }
130 
131  evidenceAdded_(chain);
132  } else {
133  GUM_ERROR(NotFound,
134  "the given PRMAttribute does not belong to this "
135  "Instance<GUM_SCALAR>.");
136  }
137  }
virtual void evidenceAdded_(const Chain &chain)=0
This method is called whenever an evidence is added, but AFTER any processing made by PRMInference...
EMap & EMap__(const PRMInstance< GUM_SCALAR > *i)
Private getter over evidences__, if necessary creates an EMap for i.
NodeProperty< const Potential< GUM_SCALAR > *> EMap
Code alias.
Definition: PRMInference.h:59
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ allInstanceNoRefAttr__()

template<typename GUM_SCALAR >
bool gum::prm::StructuredInference< GUM_SCALAR >::allInstanceNoRefAttr__ ( typename StructuredInference< GUM_SCALAR >::PData data,
std::pair< Idx, std::string >  attr 
)
private

Definition at line 415 of file structuredInference_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

417  {
418  for (const auto mat: data.matches)
419  if (mat->atPos(attr.first)
420  ->hasRefAttr(mat->atPos(attr.first)->get(attr.second).id()))
421  return false;
422 
423  return true;
424  }
+ Here is the call graph for this function:

◆ buildPatternGraph__()

template<typename GUM_SCALAR >
void gum::prm::StructuredInference< GUM_SCALAR >::buildPatternGraph__ ( PData data,
Set< Potential< GUM_SCALAR > * > &  pool,
const Sequence< PRMInstance< GUM_SCALAR > * > &  match 
)
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().

355  {
356  std::pair< Idx, std::string > v;
357  Potential< GUM_SCALAR >* pot = 0;
358 
359  for (const auto inst: match) {
360  for (const auto& elt: *inst) {
361  NodeId id = data.graph.addNode();
362  v = std::make_pair(match.pos(inst), elt.second->safeName());
363  data.map.insert(id, v);
364  data.node2attr.insert(id, str__(inst, elt.second));
365  data.mod.insert(id, elt.second->type()->domainSize());
366  data.vars.insert(id, &(elt.second->type().variable()));
367  pool.insert(
368  const_cast< Potential< GUM_SCALAR >* >(&(elt.second->cpf())));
369  pot = &(
370  const_cast< Potential< GUM_SCALAR >& >(inst->get(v.second).cpf()));
371 
372  for (const auto var: pot->variablesSequence()) {
373  try {
374  if (id != data.vars.first(var))
375  data.graph.addEdge(id, data.vars.first(var));
376  } catch (DuplicateElement&) {
377  } catch (NotFound&) {}
378  }
379 
380  insertNodeInElimLists__(data, match, inst, elt.second, id, v);
381 
382  if (data.inners().exists(id)
383  && (inst->type().containerDag().children(elt.second->id()).size()
384  == 0)
385  && allInstanceNoRefAttr__(data, v))
386  data.barren.insert(id);
387  }
388  }
389 
390  if (!found_query__) {
391  for (const auto mat: data.matches) {
392  if (mat->exists(
393  const_cast< PRMInstance< GUM_SCALAR >* >(query__.first))) {
394  Idx pos
395  = mat->pos(const_cast< PRMInstance< GUM_SCALAR >* >(query__.first));
396  DiscreteVariable& var = match.atPos(pos)
397  ->get(query__.second->safeName())
398  .type()
399  .variable();
400  NodeId id = data.vars.first(&var);
401  data.barren.erase(id);
402  data.inners().erase(id);
403  data.obs().erase(id);
404  data.outputs().erase(id);
405  data.queries().insert(id);
406  found_query__ = true;
407  query_data__ = std::make_pair(pos, query__.second->safeName());
408  break;
409  }
410  }
411  }
412  }
std::pair< Idx, std::string > query_data__
void insertNodeInElimLists__(typename StructuredInference::PData &data, const Sequence< PRMInstance< GUM_SCALAR > * > &match, PRMInstance< GUM_SCALAR > *inst, PRMAttribute< GUM_SCALAR > *attr, NodeId id, std::pair< Idx, std::string > &v)
bool allInstanceNoRefAttr__(typename StructuredInference::PData &data, std::pair< Idx, std::string > attr)
bool found_query__
Flag with an explicit name.
std::string str__(const PRMInstance< GUM_SCALAR > *i, const PRMAttribute< GUM_SCALAR > *a) const
PRMInference< GUM_SCALAR >::Chain query__
The query.
Size NodeId
Type for node ids.
Definition: graphElements.h:97
+ Here is the call graph for this function:

◆ buildReduceGraph__()

template<typename GUM_SCALAR >
void gum::prm::StructuredInference< GUM_SCALAR >::buildReduceGraph__ ( RGData data)
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().

210  {
211  // Launch the pattern mining
212  plopTimer.reset();
213 
214  if (mining__) gspan__->discoverPatterns();
215 
217  // Reducing each used pattern
218  plopTimer.reset();
219  typedef std::vector< gspan::Pattern* >::const_iterator Iter;
220 
221  for (Iter p = gspan__->patterns().begin(); p != gspan__->patterns().end();
222  ++p)
223  if (gspan__->matches(**p).size()) reducePattern__(*p);
224 
226  // reducing instance not already reduced in a pattern
228  // Adding edges using the pools
230  // Placing the query where it belongs
231  NodeId id = data.var2node.second(&(query__.second->type().variable()));
232  data.outputs().erase(id);
233  data.queries().insert(id);
234  // Triangulating, then eliminating
235  PartialOrderedTriangulation t(&(data.reducedGraph),
236  &(data.mods),
237  &(data.partial_order));
238  const std::vector< NodeId >& elim_order = t.eliminationOrder();
239 
240  for (size_t i = 0; i < data.outputs().size(); ++i)
241  eliminateNode(data.var2node.first(elim_order[i]), data.pool, trash__);
242  }
double step() const
Returns the delta time between now and the last reset() call (or the constructor).
Definition: timer_inl.h:41
void reducePattern__(const gspan::Pattern *p)
Proceed with the elimination of all inner variables (observed or not) of all usable matches of Patter...
GSpan< GUM_SCALAR > * gspan__
Pointer over th GSpan<GUM_SCALAR> instance used by this class.
void reset()
Reset the timer.
Definition: timer_inl.h:31
Set< Potential< GUM_SCALAR > *> trash__
Keeping track of create potentials to delete them after inference.
void reduceAloneInstances__(RGData &data)
Add the reduced potentials of instances not in any used patterns.
void eliminateNode(const DiscreteVariable *var, Set< Potential< GUM_SCALAR > * > &pool, Set< Potential< GUM_SCALAR > * > &trash)
Proceeds with the elimination of var in pool.
void addEdgesInReducedGraph__(RGData &data)
Add the nodes in the reduced graph.
bool mining__
Flag which tells to use pattern mining or not.
PRMInference< GUM_SCALAR >::Chain query__
The query.
Size NodeId
Type for node ids.
Definition: graphElements.h:97
+ Here is the call graph for this function:

◆ clearEvidence()

template<typename GUM_SCALAR >
void gum::prm::PRMInference< GUM_SCALAR >::clearEvidence ( )
inherited

Remove all evidences.

Definition at line 35 of file PRMInference_tpl.h.

35  {
36  for (const auto& elt: evidences__) {
37  for (const auto& elt2: *elt.second)
38  delete elt2.second;
39 
40  delete elt.second;
41  }
42 
43  evidences__.clear();
44  }
HashTable< const PRMInstance< GUM_SCALAR > *, EMap *> evidences__
Mapping of evidence over PRMInstance<GUM_SCALAR>&#39;s nodes.
Definition: PRMInference.h:235

◆ eliminateObservedNodes__()

template<typename GUM_SCALAR >
Set< Potential< GUM_SCALAR > *> * gum::prm::StructuredInference< GUM_SCALAR >::eliminateObservedNodes__ ( typename StructuredInference< GUM_SCALAR >::PData data,
const Set< Potential< GUM_SCALAR > * > &  pool,
const Sequence< PRMInstance< GUM_SCALAR > * > &  match,
const std::vector< NodeId > &  elim_order 
)
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().

506  {
507  Set< Potential< GUM_SCALAR >* >* my_pool
508  = translatePotSet__(data, pool, match);
509  std::pair< Idx, std::string > target;
510  size_t end = data.inners().size() + data.obs().size();
511 
512  for (size_t idx = data.inners().size(); idx < end; ++idx) {
513  target = data.map[data.vars.first(data.vars.second(elim_order[idx]))];
514  eliminateNode(&(match[target.first]->get(target.second).type().variable()),
515  *my_pool,
516  trash__);
517  }
518 
519  return my_pool;
520  }
Set< Potential< GUM_SCALAR > *> trash__
Keeping track of create potentials to delete them after inference.
void eliminateNode(const DiscreteVariable *var, Set< Potential< GUM_SCALAR > * > &pool, Set< Potential< GUM_SCALAR > * > &trash)
Proceeds with the elimination of var in pool.
Set< Potential< GUM_SCALAR > *> * translatePotSet__(typename StructuredInference::PData &data, const Set< Potential< GUM_SCALAR > * > &pool, const Sequence< PRMInstance< GUM_SCALAR > * > &match)
Translate a given Potential Set into one w.r.t. variables in match.
+ Here is the call graph for this function:

◆ eliminateObservedNodesInSource__()

template<typename GUM_SCALAR >
Set< Potential< GUM_SCALAR > *> * gum::prm::StructuredInference< GUM_SCALAR >::eliminateObservedNodesInSource__ ( typename StructuredInference< GUM_SCALAR >::PData data,
const Set< Potential< GUM_SCALAR > * > &  pool,
const Sequence< PRMInstance< GUM_SCALAR > * > &  match,
const std::vector< NodeId > &  elim_order 
)
private

Definition at line 480 of file structuredInference_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

484  {
485  Set< Potential< GUM_SCALAR >* >* my_pool
486  = new Set< Potential< GUM_SCALAR >* >(pool);
487  std::pair< Idx, std::string > target;
488  size_t end = data.inners().size() + data.obs().size();
489 
490  for (size_t idx = data.inners().size(); idx < end; ++idx) {
491  target = data.map[data.vars.first(data.vars.second(elim_order[idx]))];
492  eliminateNode(&(match[target.first]->get(target.second).type().variable()),
493  *my_pool,
494  trash__);
495  }
496 
497  return my_pool;
498  }
Set< Potential< GUM_SCALAR > *> trash__
Keeping track of create potentials to delete them after inference.
void eliminateNode(const DiscreteVariable *var, Set< Potential< GUM_SCALAR > * > &pool, Set< Potential< GUM_SCALAR > * > &trash)
Proceeds with the elimination of var in pool.
+ Here is the call graph for this function:

◆ evidence() [1/4]

template<typename GUM_SCALAR>
INLINE PRMInference< GUM_SCALAR >::EMap & gum::prm::PRMInference< GUM_SCALAR >::evidence ( const PRMInstance< GUM_SCALAR > &  i)
inherited

Returns EMap of evidences over i.

Exceptions
NotFoundif i has no evidence.

Definition at line 156 of file PRMInference_tpl.h.

156  {
157  try {
158  return *(evidences__[&i]);
159  } catch (NotFound&) {
160  GUM_ERROR(NotFound, "this instance has no evidence.");
161  }
162  }
HashTable< const PRMInstance< GUM_SCALAR > *, EMap *> evidences__
Mapping of evidence over PRMInstance<GUM_SCALAR>&#39;s nodes.
Definition: PRMInference.h:235
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ evidence() [2/4]

template<typename GUM_SCALAR>
INLINE PRMInference< GUM_SCALAR >::EMap & gum::prm::PRMInference< GUM_SCALAR >::evidence ( const PRMInstance< GUM_SCALAR > *  i)
inherited

Returns EMap of evidences over i.

Exceptions
NotFoundif i has no evidence.

Definition at line 177 of file PRMInference_tpl.h.

177  {
178  try {
179  return *(evidences__[i]);
180  } catch (NotFound&) {
181  GUM_ERROR(NotFound, "this instance has no evidence.");
182  }
183  }
HashTable< const PRMInstance< GUM_SCALAR > *, EMap *> evidences__
Mapping of evidence over PRMInstance<GUM_SCALAR>&#39;s nodes.
Definition: PRMInference.h:235
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ evidence() [3/4]

template<typename GUM_SCALAR>
INLINE const PRMInference< GUM_SCALAR >::EMap & gum::prm::PRMInference< GUM_SCALAR >::evidence ( const PRMInstance< GUM_SCALAR > &  i) const
inherited

Returns EMap of evidences over i.

Exceptions
NotFoundif i has no evidence.

Definition at line 166 of file PRMInference_tpl.h.

167  {
168  try {
169  return *(evidences__[&i]);
170  } catch (NotFound&) {
171  GUM_ERROR(NotFound, "this instance has no evidence.");
172  }
173  }
HashTable< const PRMInstance< GUM_SCALAR > *, EMap *> evidences__
Mapping of evidence over PRMInstance<GUM_SCALAR>&#39;s nodes.
Definition: PRMInference.h:235
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ evidence() [4/4]

template<typename GUM_SCALAR>
INLINE const PRMInference< GUM_SCALAR >::EMap & gum::prm::PRMInference< GUM_SCALAR >::evidence ( const PRMInstance< GUM_SCALAR > *  i) const
inherited

Returns EMap of evidences over i.

Exceptions
NotFoundif i has no evidence.

Definition at line 187 of file PRMInference_tpl.h.

188  {
189  try {
190  return *(evidences__[i]);
191  } catch (NotFound&) {
192  GUM_ERROR(NotFound, "this instance has no evidence.");
193  }
194  }
HashTable< const PRMInstance< GUM_SCALAR > *, EMap *> evidences__
Mapping of evidence over PRMInstance<GUM_SCALAR>&#39;s nodes.
Definition: PRMInference.h:235
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ evidenceAdded_() [1/2]

template<typename GUM_SCALAR >
void gum::prm::StructuredInference< GUM_SCALAR >::evidenceAdded_ ( const typename PRMInference< GUM_SCALAR >::Chain chain)
protectedvirtual

See PRMInference::evidenceAdded_().

Definition at line 95 of file structuredInference_tpl.h.

96  {}

◆ evidenceAdded_() [2/2]

template<typename GUM_SCALAR>
virtual void gum::prm::PRMInference< GUM_SCALAR >::evidenceAdded_ ( const Chain chain)
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 >.

◆ evidenceRemoved_() [1/2]

template<typename GUM_SCALAR >
void gum::prm::StructuredInference< GUM_SCALAR >::evidenceRemoved_ ( const typename PRMInference< GUM_SCALAR >::Chain chain)
protectedvirtual

See PRMInference::evidenceRemoved_().

Definition at line 99 of file structuredInference_tpl.h.

100  {}

◆ evidenceRemoved_() [2/2]

template<typename GUM_SCALAR>
virtual void gum::prm::PRMInference< GUM_SCALAR >::evidenceRemoved_ ( const Chain chain)
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 >.

◆ gspan() [1/2]

template<typename 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().

1024  {
1025  return *gspan__;
1026  }
GSpan< GUM_SCALAR > * gspan__
Pointer over th GSpan<GUM_SCALAR> instance used by this class.
+ Here is the call graph for this function:

◆ gspan() [2/2]

template<typename GUM_SCALAR >
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().

1030  {
1031  return *gspan__;
1032  }
GSpan< GUM_SCALAR > * gspan__
Pointer over th GSpan<GUM_SCALAR> instance used by this class.
+ Here is the call graph for this function:

◆ hasEvidence() [1/4]

template<typename GUM_SCALAR>
INLINE bool gum::prm::PRMInference< GUM_SCALAR >::hasEvidence ( const PRMInstance< GUM_SCALAR > &  i) const
inherited

Returns true if i has evidence.

Definition at line 197 of file PRMInference_tpl.h.

198  {
199  return evidences__.exists(&i);
200  }
HashTable< const PRMInstance< GUM_SCALAR > *, EMap *> evidences__
Mapping of evidence over PRMInstance<GUM_SCALAR>&#39;s nodes.
Definition: PRMInference.h:235

◆ hasEvidence() [2/4]

template<typename GUM_SCALAR>
INLINE bool gum::prm::PRMInference< GUM_SCALAR >::hasEvidence ( const PRMInstance< GUM_SCALAR > *  i) const
inherited

Returns EMap of evidences over i.

Definition at line 203 of file PRMInference_tpl.h.

204  {
205  return evidences__.exists(i);
206  }
HashTable< const PRMInstance< GUM_SCALAR > *, EMap *> evidences__
Mapping of evidence over PRMInstance<GUM_SCALAR>&#39;s nodes.
Definition: PRMInference.h:235

◆ hasEvidence() [3/4]

template<typename GUM_SCALAR>
INLINE bool gum::prm::PRMInference< GUM_SCALAR >::hasEvidence ( const Chain chain) const
inherited

Returns true if i has evidence on PRMAttribute<GUM_SCALAR> a.

Definition at line 209 of file PRMInference_tpl.h.

209  {
210  return (hasEvidence(chain.first))
211  ? evidence(chain.first).exists(chain.second->id())
212  : false;
213  }
EMap & evidence(const PRMInstance< GUM_SCALAR > &i)
Returns EMap of evidences over i.
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
bool hasEvidence() const
Returns true if i has evidence on PRMAttribute<GUM_SCALAR> a.

◆ hasEvidence() [4/4]

template<typename GUM_SCALAR>
INLINE bool gum::prm::PRMInference< GUM_SCALAR >::hasEvidence ( ) const
inherited

Returns true if i has evidence on PRMAttribute<GUM_SCALAR> a.

Definition at line 216 of file PRMInference_tpl.h.

216  {
217  return (evidences__.size() != (Size)0);
218  }
HashTable< const PRMInstance< GUM_SCALAR > *, EMap *> evidences__
Mapping of evidence over PRMInstance<GUM_SCALAR>&#39;s nodes.
Definition: PRMInference.h:235
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:47

◆ info()

template<typename GUM_SCALAR >
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().

183  {
184  std::stringstream s;
185  s << "Triangulation time: " << triang_time << std::endl;
186  s << "Pattern mining time: " << mining_time << std::endl;
187  s << "Pattern elimination time: " << pattern_time << std::endl;
188  s << "Inner node elimination time: " << inner_time << std::endl;
189  s << "Observed node elimination time: " << obs_time << std::endl;
190  s << "Full inference time: " << full_time << std::endl;
191  s << "#patterns: " << gspan__->patterns().size() << std::endl;
192  Size count = 0;
193  typedef std::vector< gspan::Pattern* >::const_iterator Iter;
194 
195  for (Iter p = gspan__->patterns().begin(); p != gspan__->patterns().end();
196  ++p) {
197  if (gspan__->matches(**p).size()) {
198  s << "Pattern n°" << count++
199  << " match count: " << gspan__->matches(**p).size() << std::endl;
200  s << "Pattern n°" << count++ << " instance count: " << (**p).size()
201  << std::endl;
202  }
203  }
204 
205  return s.str();
206  }
GSpan< GUM_SCALAR > * gspan__
Pointer over th GSpan<GUM_SCALAR> instance used by this class.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:47
+ Here is the call graph for this function:

◆ insertNodeInElimLists__()

template<typename GUM_SCALAR >
void gum::prm::StructuredInference< GUM_SCALAR >::insertNodeInElimLists__ ( typename StructuredInference< GUM_SCALAR >::PData data,
const Sequence< PRMInstance< GUM_SCALAR > * > &  match,
PRMInstance< GUM_SCALAR > *  inst,
PRMAttribute< GUM_SCALAR > *  attr,
NodeId  id,
std::pair< Idx, std::string > &  v 
)
private

Definition at line 315 of file structuredInference_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

321  {
322  if ((*inst).hasRefAttr((*inst).get(v.second).id())) {
323  std::vector< std::pair< PRMInstance< GUM_SCALAR >*, std::string > >& refs
324  = inst->getRefAttr(inst->get(v.second).id());
325 
326  for (auto r = refs.begin(); r != refs.end(); ++r) {
327  if (!match.exists(r->first)) {
328  data.outputs().insert(id);
329  break;
330  }
331  }
332  }
333 
334  if (!(data.outputs().size() && (data.outputs().exists(id)))) {
335  for (const auto m: data.matches) {
336  if (this->hasEvidence(
337  std::make_pair((*m)[v.first], &((*m)[v.first]->get(v.second))))) {
338  GUM_ASSERT(inst->type().name() == (*m)[v.first]->type().name());
339  GUM_ASSERT(inst->get(v.second).safeName()
340  == (*m)[v.first]->get(v.second).safeName());
341  data.obs().insert(id);
342  break;
343  }
344  }
345 
346  if (!(data.obs().size() && (data.obs().exists(id))))
347  data.inners().insert(id);
348  }
349  }
bool hasEvidence() const
Returns true if i has evidence on PRMAttribute<GUM_SCALAR> a.
+ Here is the call graph for this function:

◆ joint()

template<typename GUM_SCALAR>
INLINE void gum::prm::PRMInference< GUM_SCALAR >::joint ( const std::vector< Chain > &  chains,
Potential< GUM_SCALAR > &  j 
)
inherited

Compute the joint probability of the formals attributes pointed by chains and stores it in m.

Parameters
chainsA Set of strings of the form instance.attribute.
jAn empty CPF which will be filed by the joint probability over chains.
Exceptions
NotFoundRaised if some chain in chains does not point to a formal attribute.
OperationNotAllowedRaise if m is not empty.

Definition at line 264 of file PRMInference_tpl.h.

266  {
267  if (j.nbrDim() > 0) {
268  GUM_ERROR(OperationNotAllowed, "the given Potential is not empty.");
269  }
270 
271  for (auto chain = chains.begin(); chain != chains.end(); ++chain) {
272  j.add(chain->second->type().variable());
273  }
274 
275  joint_(chains, j);
276  }
virtual void joint_(const std::vector< Chain > &queries, Potential< GUM_SCALAR > &j)=0
Generic method to compute the posterior of given element.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ joint_() [1/2]

template<typename GUM_SCALAR >
void gum::prm::StructuredInference< GUM_SCALAR >::joint_ ( const std::vector< typename PRMInference< GUM_SCALAR >::Chain > &  queries,
Potential< GUM_SCALAR > &  j 
)
protectedvirtual

See PRMInference::joint_().

Definition at line 176 of file structuredInference_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

178  {
179  GUM_ERROR(FatalError, "not implemented");
180  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54
+ Here is the call graph for this function:

◆ joint_() [2/2]

template<typename GUM_SCALAR>
virtual void gum::prm::PRMInference< GUM_SCALAR >::joint_ ( const std::vector< Chain > &  queries,
Potential< GUM_SCALAR > &  j 
)
protectedpure virtualinherited

Generic method to compute the posterior of given element.

Parameters
queriesSet of pairs of PRMInstance<GUM_SCALAR> and PRMAttribute<GUM_SCALAR>.
jCPF filled with the joint probability of queries. It is initialized properly.

Implemented in gum::prm::SVE< GUM_SCALAR >, and gum::prm::SVED< GUM_SCALAR >.

◆ name()

template<typename GUM_SCALAR >
INLINE std::string gum::prm::StructuredInference< GUM_SCALAR >::name ( ) const
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.

1019  {
1020  return "StructuredInference";
1021  }

◆ operator=()

template<typename GUM_SCALAR >
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().

84  {
85  this->prm_ = source.prm_;
86  this->sys_ = source.sys_;
87 
88  if (this->gspan__) delete this->gspan__;
89 
90  this->gspan__ = new GSpan< GUM_SCALAR >(*(this->prm_), *(this->sys_));
91  return *this;
92  }
GSpan< GUM_SCALAR > * gspan__
Pointer over th GSpan<GUM_SCALAR> instance used by this class.
PRMSystem< GUM_SCALAR > const * sys_
The Model on which inference is done.
Definition: PRMInference.h:216
PRM< GUM_SCALAR > const * prm_
The PRM<GUM_SCALAR> on which inference is done.
Definition: PRMInference.h:213
+ Here is the call graph for this function:

◆ posterior()

template<typename GUM_SCALAR>
INLINE void gum::prm::PRMInference< GUM_SCALAR >::posterior ( const Chain chain,
Potential< GUM_SCALAR > &  m 
)
inherited

Compute the posterior of the formal attribute pointed by chain and stores it in m.

Parameters
chainA string of the form instance.attribute.
mAn empty CPF which will be filed by the posterior of chain.
Exceptions
NotFoundRaised if chain is invalid.
TypeErrorRaised if chain does not point to an PRMAttribute<GUM_SCALAR>.
OperationNotAllowedRaise if m is not empty.

Definition at line 234 of file PRMInference_tpl.h.

236  {
237  if (m.nbrDim() > 0) {
238  GUM_ERROR(OperationNotAllowed, "the given Potential is not empty.");
239  }
240 
241  if (hasEvidence(chain)) {
242  m.add(chain.second->type().variable());
243  const Potential< GUM_SCALAR >& e
244  = *(evidence(chain.first)[chain.second->id()]);
245  Instantiation i(m), j(e);
246 
247  for (i.setFirst(), j.setFirst(); !i.end(); i.inc(), j.inc())
248  m.set(i, e.get(j));
249  } else {
250  if (chain.second != &(chain.first->get(chain.second->safeName()))) {
251  typename PRMInference< GUM_SCALAR >::Chain good_chain
252  = std::make_pair(chain.first,
253  &(chain.first->get(chain.second->safeName())));
254  m.add(good_chain.second->type().variable());
255  posterior_(good_chain, m);
256  } else {
257  m.add(chain.second->type().variable());
258  posterior_(chain, m);
259  }
260  }
261  }
EMap & evidence(const PRMInstance< GUM_SCALAR > &i)
Returns EMap of evidences over i.
virtual void posterior_(const Chain &chain, Potential< GUM_SCALAR > &m)=0
Generic method to compute the posterior of given element.
bool hasEvidence() const
Returns true if i has evidence on PRMAttribute<GUM_SCALAR> a.
std::pair< const PRMInstance< GUM_SCALAR > *, const PRMAttribute< GUM_SCALAR > *> Chain
Code alias.
Definition: PRMInference.h:56
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ posterior_() [1/2]

template<typename GUM_SCALAR >
void gum::prm::StructuredInference< GUM_SCALAR >::posterior_ ( const typename PRMInference< GUM_SCALAR >::Chain chain,
Potential< GUM_SCALAR > &  m 
)
protectedvirtual

See PRMInference::posterior_().

Definition at line 103 of file structuredInference_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

105  {
106  timer.reset();
107  found_query__ = false;
108  query__ = chain;
109  typename StructuredInference< GUM_SCALAR >::RGData data;
110 
111  if (!this->hasEvidence() && (chain.second->cpf().nbrDim() == 1)) {
112  Instantiation i(m);
113 
114  for (i.setFirst(); !i.end(); i.inc())
115  m.set(i, chain.second->cpf().get(i));
116 
117  return;
118  } else if (this->hasEvidence(chain)) {
119  Instantiation i(m);
120  const Potential< GUM_SCALAR >* e
121  = this->evidence(query__.first)[query__.second->id()];
122 
123  for (i.setFirst(); !i.end(); i.inc())
124  m.set(i, e->get(i));
125 
126  return;
127  }
128 
129  buildReduceGraph__(data);
130  Set< const Potential< GUM_SCALAR >* > pots;
131 
132  if (data.pool.size() > 1) {
133  for (const auto pot: data.pool)
134  if (pot->contains(query__.second->type().variable())) pots.insert(pot);
135 
136  if (pots.size() == 1) {
137  Potential< GUM_SCALAR >* pot
138  = const_cast< Potential< GUM_SCALAR >* >(*(pots.begin()));
139  GUM_ASSERT(pot->contains(query__.second->type().variable()));
140  GUM_ASSERT(pot->variablesSequence().size() == 1);
141  Instantiation i(*pot), j(m);
142 
143  for (i.setFirst(), j.setFirst(); !i.end(); i.inc(), j.inc())
144  m.set(j, pot->get(i));
145  } else {
146  MultiDimCombinationDefault< GUM_SCALAR, Potential > Comb(multPotential);
147  Potential< GUM_SCALAR >* tmp = Comb.combine(pots);
148  Instantiation i(m), j(*tmp);
149 
150  for (i.setFirst(), j.setFirst(); !i.end(); i.inc(), j.inc())
151  m.set(i, tmp->get(j));
152 
153  delete tmp;
154  }
155  } else {
156  Potential< GUM_SCALAR >* pot = *(data.pool.begin());
157  GUM_ASSERT(pot->contains(query__.second->type().variable()));
158  GUM_ASSERT(pot->variablesSequence().size() == 1);
159  Instantiation i(*pot), j(m);
160 
161  for (i.setFirst(), j.setFirst(); !i.end(); i.inc(), j.inc())
162  m.set(j, pot->get(i));
163  }
164 
165  m.normalize();
166 
167  if (pdata__) {
168  delete pdata__;
169  pdata__ = 0;
170  }
171 
172  full_time = timer.step();
173  }
double step() const
Returns the delta time between now and the last reset() call (or the constructor).
Definition: timer_inl.h:41
EMap & evidence(const PRMInstance< GUM_SCALAR > &i)
Returns EMap of evidences over i.
void reset()
Reset the timer.
Definition: timer_inl.h:31
bool found_query__
Flag with an explicit name.
void set(const Key &key, const Val &default_value)
Add a new property or modify it if it already existed.
bool hasEvidence() const
Returns true if i has evidence on PRMAttribute<GUM_SCALAR> a.
void buildReduceGraph__(RGData &data)
This calls reducePattern__() over each pattern and then build the reduced graph which is used for inf...
PRMInference< GUM_SCALAR >::Chain query__
The query.
PData * pdata__
The pattern data of the pattern which one of its matches contains the query.
Potential< GUM_SCALAR > * multPotential(const Potential< GUM_SCALAR > &t1, const Potential< GUM_SCALAR > &t2)
+ Here is the call graph for this function:

◆ posterior_() [2/2]

template<typename GUM_SCALAR>
virtual void gum::prm::PRMInference< GUM_SCALAR >::posterior_ ( const Chain chain,
Potential< GUM_SCALAR > &  m 
)
protectedpure virtualinherited

Generic method to compute the posterior of given element.

Parameters
chain
mCPF filled with the posterior of elt. It is initialized properly.

Implemented in gum::prm::SVE< GUM_SCALAR >, and gum::prm::SVED< GUM_SCALAR >.

◆ reduceAloneInstances__()

template<typename GUM_SCALAR >
void gum::prm::StructuredInference< GUM_SCALAR >::reduceAloneInstances__ ( RGData data)
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().

620  {
621  StructuredInference< GUM_SCALAR >::CData* data = 0;
622  Potential< GUM_SCALAR >* pot = nullptr;
623  PRMInstance< GUM_SCALAR >* inst = nullptr;
624 
625  for (const auto& elt: *this->sys_) {
626  inst = elt.second;
627 
628  if (!reducedInstances__.exists(inst)) {
629  // Checking if its not an empty class
630  if (inst->size()) {
631  Set< Potential< GUM_SCALAR >* > pool;
632 
633  try {
634  data = cdata_map__[&(inst->type())];
635  } catch (NotFound&) {
636  data = new StructuredInference< GUM_SCALAR >::CData(inst->type());
637  cdata_map__.insert(&(inst->type()), data);
638  }
639 
640  data->instances.insert(inst);
641  // Filling up the partial ordering
642  List< NodeSet > partial_order;
643 
644  if (data->inners().size()) partial_order.push_back(data->inners());
645 
646  if (data->aggregators().size())
647  for (const auto agg: data->aggregators())
648  partial_order[0].insert(agg);
649 
650  if (data->outputs().size()) partial_order.push_back(data->outputs());
651 
652  if (query__.first == inst) {
653  // First case, the instance contains the query
654  partial_order[0].erase(query__.second->id());
655 
656  if (partial_order[0].empty()) partial_order.erase(0);
657 
658  if (partial_order.size() > 1) {
659  partial_order[1].erase(query__.second->id());
660 
661  if (partial_order[1].empty()) partial_order.erase(1);
662  }
663 
664  NodeSet query_set;
665  query_set.insert(query__.second->id());
666  partial_order.insert(query_set);
667 
668  // Adding the potentials
669  for (auto attr = inst->begin(); attr != inst->end(); ++attr)
670  pool.insert(&(
671  const_cast< Potential< GUM_SCALAR >& >((*(attr.val())).cpf())));
672 
673  // Adding evidences if any
674  if (this->hasEvidence(inst))
675  for (const auto& elt: this->evidence(inst))
676  pool.insert(const_cast< Potential< GUM_SCALAR >* >(elt.second));
677 
678  PartialOrderedTriangulation t(&(data->moral_graph),
679  &(data->mods),
680  &(partial_order));
681  const std::vector< NodeId >& v = t.eliminationOrder();
682 
683  if (partial_order.size() > 1)
684  for (size_t idx = 0; idx < partial_order[0].size(); ++idx)
685  eliminateNode(&(inst->get(v[idx]).type().variable()),
686  pool,
687  trash__);
688  } else if (this->hasEvidence(inst)) {
689  // Second case, the instance has evidences
690  // Adding the potentials
691  for (const auto elt: *inst)
692  pool.insert(
693  &const_cast< Potential< GUM_SCALAR >& >(elt.second->cpf()));
694 
695  // Adding evidences
696  for (const auto& elt: this->evidence(inst))
697  pool.insert(const_cast< Potential< GUM_SCALAR >* >(elt.second));
698 
699  PartialOrderedTriangulation t(&(data->moral_graph),
700  &(data->mods),
701  &(partial_order));
702 
703  for (size_t idx = 0; idx < partial_order[0].size(); ++idx)
705  &(inst->get(t.eliminationOrder()[idx]).type().variable()),
706  pool,
707  trash__);
708  } else {
709  // Last cast, the instance neither contains evidences nor
710  // instances
711  // We translate the class level potentials into the instance ones
712  // and
713  // proceed with elimination
714  for (const auto srcPot: data->pool) {
715  pot = copyPotential(inst->bijection(), *srcPot);
716  pool.insert(pot);
717  trash__.insert(pot);
718  }
719 
720  for (const auto agg: data->c.aggregates())
721  pool.insert(&(const_cast< Potential< GUM_SCALAR >& >(
722  inst->get(agg->id()).cpf())));
723 
724  // We eliminate inner aggregators with their parents if necessary
725  // (see
726  // CData constructor)
727  Size size = data->inners().size() + data->aggregators().size();
728 
729  for (size_t idx = data->inners().size(); idx < size; ++idx)
731  &(inst->get(data->elim_order()[idx]).type().variable()),
732  pool,
733  trash__);
734  }
735 
736  for (const auto pot: pool)
737  rg_data.pool.insert(pot);
738  }
739  }
740  }
741  }
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
EMap & evidence(const PRMInstance< GUM_SCALAR > &i)
Returns EMap of evidences over i.
PRMSystem< GUM_SCALAR > const * sys_
The Model on which inference is done.
Definition: PRMInference.h:216
Set< Potential< GUM_SCALAR > *> trash__
Keeping track of create potentials to delete them after inference.
Potential< GUM_SCALAR > * copyPotential(const Bijection< const DiscreteVariable *, const DiscreteVariable * > &bij, const Potential< GUM_SCALAR > &source)
Returns a copy of a Potential after applying a bijection over the variables in source.
Definition: utils_prm_tpl.h:28
void eliminateNode(const DiscreteVariable *var, Set< Potential< GUM_SCALAR > * > &pool, Set< Potential< GUM_SCALAR > * > &trash)
Proceeds with the elimination of var in pool.
bool hasEvidence() const
Returns true if i has evidence on PRMAttribute<GUM_SCALAR> a.
HashTable< const PRMClass< GUM_SCALAR > *, CData *> cdata_map__
Mapping between a Class<GUM_SCALAR> and data about instances reduced using only Class<GUM_SCALAR> lev...
Set< const PRMInstance< GUM_SCALAR > *> reducedInstances__
This keeps track of reduced instances.
PRMInference< GUM_SCALAR >::Chain query__
The query.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:47
void insert(const Key &k)
Inserts a new element into the set.
Definition: set_tpl.h:632
+ Here is the call graph for this function:

◆ reducePattern__()

template<typename GUM_SCALAR >
void gum::prm::StructuredInference< GUM_SCALAR >::reducePattern__ ( const gspan::Pattern p)
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().

246  {
247  Set< Potential< GUM_SCALAR >* > pool;
248  typename StructuredInference< GUM_SCALAR >::PData data(*p,
249  gspan__->matches(*p));
250  buildPatternGraph__(data, pool, **(data.matches.begin()));
251  removeBarrenNodes__(data, pool);
252  PartialOrderedTriangulation t(&(data.graph),
253  &(data.mod),
254  data.partial_order());
255  const std::vector< NodeId >& elim_order = t.eliminationOrder();
256 
257  for (size_t i = 0; i < data.inners().size(); ++i)
258  if (!data.barren.exists(elim_order[i]))
259  eliminateNode(data.vars.second(elim_order[i]), pool, trash__);
260 
261  typename GSpan< GUM_SCALAR >::MatchedInstances fake_patterns;
263  = data.matches.begin();
264 
265  for (const auto elt: **iter)
266  reducedInstances__.insert(elt);
267 
268  if (data.obs().size())
269  elim_map__.insert(
270  *iter,
271  eliminateObservedNodesInSource__(data, pool, **iter, elim_order));
272  else
273  elim_map__.insert(*iter, new Set< Potential< GUM_SCALAR >* >(pool));
274 
275  ++iter;
276 
277  if (data.obs().size()) {
278  for (; iter != data.matches.end(); ++iter) {
279  try {
280  elim_map__.insert(
281  *iter,
282  eliminateObservedNodes__(data, pool, **iter, elim_order));
283  } catch (OperationNotAllowed&) { fake_patterns.insert(*iter); }
284  }
285  } else {
286  for (; iter != data.matches.end(); ++iter) {
287  try {
288  elim_map__.insert(*iter, translatePotSet__(data, pool, **iter));
289  } catch (OperationNotAllowed&) { fake_patterns.insert(*iter); }
290  }
291  }
292 
293  for (const auto pat: fake_patterns) {
294  for (const auto elt: *pat)
295  reducedInstances__.erase(elt);
296 
297  data.matches.erase(pat);
298  }
299 
300  obs_time += plopTimer.step();
301 
302  if (data.queries().size())
303  for (const auto m: data.matches)
304  if (!(m->exists(
305  const_cast< PRMInstance< GUM_SCALAR >* >(query__.first))))
306  eliminateNode(&(m->atPos(query_data__.first)
307  ->get(query_data__.second)
308  .type()
309  .variable()),
310  *(elim_map__[m]),
311  trash__);
312  }
double step() const
Returns the delta time between now and the last reset() call (or the constructor).
Definition: timer_inl.h:41
Set< Sequence< PRMInstance< GUM_SCALAR > *> *> MatchedInstances
Code alias.
Definition: gspan.h:169
std::pair< Idx, std::string > query_data__
GSpan< GUM_SCALAR > * gspan__
Pointer over th GSpan<GUM_SCALAR> instance used by this class.
Set< Potential< GUM_SCALAR > *> * eliminateObservedNodes__(typename StructuredInference::PData &data, const Set< Potential< GUM_SCALAR > * > &pool, const Sequence< PRMInstance< GUM_SCALAR > * > &match, const std::vector< NodeId > &elim_order)
Add in data.queries() any queried variable in one of data.pattern matches.
Set< Potential< GUM_SCALAR > *> trash__
Keeping track of create potentials to delete them after inference.
Set< Potential< GUM_SCALAR > *> * eliminateObservedNodesInSource__(typename StructuredInference::PData &data, const Set< Potential< GUM_SCALAR > * > &pool, const Sequence< PRMInstance< GUM_SCALAR > * > &match, const std::vector< NodeId > &elim_order)
void eliminateNode(const DiscreteVariable *var, Set< Potential< GUM_SCALAR > * > &pool, Set< Potential< GUM_SCALAR > * > &trash)
Proceeds with the elimination of var in pool.
void removeBarrenNodes__(typename StructuredInference::PData &data, Set< Potential< GUM_SCALAR > * > &pool)
Set< const PRMInstance< GUM_SCALAR > *> reducedInstances__
This keeps track of reduced instances.
PRMInference< GUM_SCALAR >::Chain query__
The query.
HashTable< const Sequence< PRMInstance< GUM_SCALAR > *> *, Set< Potential< GUM_SCALAR > *> *> elim_map__
Mapping between a Pattern&#39;s match and its potential pool after inner variables were eliminated...
SetIterator< Key > const_iterator
Types for STL compliance.
Definition: set.h:177
Set< Potential< GUM_SCALAR > *> * translatePotSet__(typename StructuredInference::PData &data, const Set< Potential< GUM_SCALAR > * > &pool, const Sequence< PRMInstance< GUM_SCALAR > * > &match)
Translate a given Potential Set into one w.r.t. variables in match.
void buildPatternGraph__(PData &data, Set< Potential< GUM_SCALAR > * > &pool, const Sequence< PRMInstance< GUM_SCALAR > * > &match)
Build the DAG corresponding to Pattern data.pattern, initialize pool with all the Potentials of all v...
+ Here is the call graph for this function:

◆ removeBarrenNodes__()

template<typename GUM_SCALAR >
void gum::prm::StructuredInference< GUM_SCALAR >::removeBarrenNodes__ ( typename StructuredInference< GUM_SCALAR >::PData data,
Set< Potential< GUM_SCALAR > * > &  pool 
)
private

Definition at line 427 of file structuredInference_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

429  {
430  Sequence< NodeId > candidates;
431 
432  for (const auto node: data.barren) {
433  for (const auto pot: pool)
434  if (pot->contains(*data.vars.second(node))) {
435  pool.erase(pot);
436  break;
437  }
438 
439  for (const auto nei: data.graph.neighbours(node))
440  if (data.inners().exists(nei)) {
441  try {
442  candidates.insert(nei);
443  } catch (DuplicateElement&) {}
444  }
445  }
446 
447  NodeId node;
448  Potential< GUM_SCALAR >* my_pot = nullptr;
449  short count = 0;
450 
451  while (candidates.size()) {
452  node = candidates.back();
453  candidates.erase(node);
454  count = 0;
455 
456  for (const auto pot: pool) {
457  if (pot->contains(*data.vars.second(node))) {
458  ++count;
459  my_pot = pot;
460  }
461  }
462 
463  if (count == 1) {
464  pool.erase(my_pot);
465  data.barren.insert(node);
466 
467  for (const auto nei: data.graph.neighbours(node)) {
468  if (data.inners().exists(nei)) {
469  try {
470  candidates.insert(nei);
471  } catch (DuplicateElement&) {}
472  }
473  }
474  }
475  }
476  }
Size size() const noexcept
Returns the size of the sequence.
Definition: sequence_tpl.h:37
void erase(const Key &k)
Remove an element from the sequence.
Definition: sequence_tpl.h:454
Size NodeId
Type for node ids.
Definition: graphElements.h:97
const Key & back() const
Returns the last element of the sequence.
Definition: sequence_tpl.h:569
void insert(const Key &k)
Insert an element at the end of the sequence.
Definition: sequence_tpl.h:409
+ Here is the call graph for this function:

◆ removeEvidence()

template<typename GUM_SCALAR >
INLINE void gum::prm::PRMInference< GUM_SCALAR >::removeEvidence ( const Chain chain)
inherited

Remove evidence on the given instance's elt.

Parameters
chainThe variable being observed.
Exceptions
NotFoundRaised if the given names are not found.
TypeErrorRaised if the elt is not an PRMAttribute<GUM_SCALAR>.

Definition at line 221 of file PRMInference_tpl.h.

221  {
222  try {
223  if (EMap__(chain.first).exists(chain.second->id())) {
224  evidenceRemoved_(chain);
225  delete EMap__(chain.first)[chain.second->id()];
226  EMap__(chain.first).erase(chain.second->id());
227  }
228  } catch (NotFound&) {
229  // Ok, we are only removing
230  }
231  }
void erase(const Key &key)
Removes a given element from the hash table.
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
virtual void evidenceRemoved_(const Chain &chain)=0
This method is called whenever an evidence is removed, but BEFORE any processing made by PRMInference...
EMap & EMap__(const PRMInstance< GUM_SCALAR > *i)
Private getter over evidences__, if necessary creates an EMap for i.

◆ removeNode__()

template<typename GUM_SCALAR >
INLINE void gum::prm::StructuredInference< GUM_SCALAR >::removeNode__ ( typename StructuredInference< GUM_SCALAR >::PData data,
NodeId  id,
Set< Potential< GUM_SCALAR > * > &  pool 
)
private

Definition at line 1035 of file structuredInference_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

1038  {
1039  data.graph.eraseNode(id);
1040  GUM_ASSERT(!data.graph.exists(id));
1041  data.mod.erase(id);
1042  GUM_ASSERT(!data.mod.exists(id));
1043  data.node2attr.eraseFirst(id);
1044  GUM_ASSERT(!data.node2attr.existsFirst(id));
1045  data.map.erase(id);
1046  GUM_ASSERT(!data.map.exists(id));
1047  data.vars.eraseFirst(id);
1048  GUM_ASSERT(!data.vars.existsFirst(id));
1049  data.inners().erase(id);
1050  GUM_ASSERT(!data.inners().exists(id));
1051  pool.erase(data.pots[id]);
1052  GUM_ASSERT(!pool.exists(data.pots[id]));
1053  data.pots.erase(id);
1054  GUM_ASSERT(!data.pots.exists(id));
1055  }
+ Here is the call graph for this function:

◆ searchPatterns()

template<typename GUM_SCALAR >
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().

974  {
975  const PRMInstance< GUM_SCALAR >* i = (this->sys_->begin()).val();
976  query__ = std::make_pair(i, i->begin().val());
977  found_query__ = false;
978  typename StructuredInference< GUM_SCALAR >::RGData data;
979  buildReduceGraph__(data);
980  }
PRMSystem< GUM_SCALAR > const * sys_
The Model on which inference is done.
Definition: PRMInference.h:216
bool found_query__
Flag with an explicit name.
void buildReduceGraph__(RGData &data)
This calls reducePattern__() over each pattern and then build the reduced graph which is used for inf...
PRMInference< GUM_SCALAR >::Chain query__
The query.
+ Here is the call graph for this function:

◆ setPatternMining()

template<typename GUM_SCALAR >
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().

983  {
984  mining__ = b;
985  }
bool mining__
Flag which tells to use pattern mining or not.
+ Here is the call graph for this function:

◆ str__() [1/3]

template<typename GUM_SCALAR >
INLINE std::string gum::prm::StructuredInference< GUM_SCALAR >::str__ ( const PRMInstance< GUM_SCALAR > *  i,
const PRMAttribute< GUM_SCALAR > *  a 
) const
private

Definition at line 988 of file structuredInference_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

990  {
991  return i->name() + dot__ + a->safeName();
992  }
std::string dot__
Unreduce the match containing the query.
+ Here is the call graph for this function:

◆ str__() [2/3]

template<typename GUM_SCALAR >
INLINE std::string gum::prm::StructuredInference< GUM_SCALAR >::str__ ( const PRMInstance< GUM_SCALAR > *  i,
const PRMAttribute< GUM_SCALAR > &  a 
) const
private

Definition at line 995 of file structuredInference_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

997  {
998  return i->name() + dot__ + a.safeName();
999  }
std::string dot__
Unreduce the match containing the query.
+ Here is the call graph for this function:

◆ str__() [3/3]

template<typename GUM_SCALAR >
INLINE std::string gum::prm::StructuredInference< GUM_SCALAR >::str__ ( const PRMInstance< GUM_SCALAR > *  i,
const PRMSlotChain< GUM_SCALAR > &  a 
) const
private

Definition at line 1002 of file structuredInference_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

1004  {
1005  return i->name() + dot__ + a.lastElt().safeName();
1006  }
std::string dot__
Unreduce the match containing the query.
+ Here is the call graph for this function:

◆ translatePotSet__()

template<typename GUM_SCALAR >
Set< Potential< GUM_SCALAR > *> * gum::prm::StructuredInference< GUM_SCALAR >::translatePotSet__ ( typename StructuredInference< GUM_SCALAR >::PData data,
const Set< Potential< GUM_SCALAR > * > &  pool,
const Sequence< PRMInstance< GUM_SCALAR > * > &  match 
)
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().

527  {
528 #ifdef DEBUG
529 
531  = data.matches.begin();
532  iter != data.matches.end();
533  ++iter) {
534  GUM_ASSERT((**iter).size() == match.size());
535 
536  for (Size idx = 0; idx < match.size(); ++idx) {
537  GUM_ASSERT((**iter).atPos(idx)->type() == match.atPos(idx)->type());
538  }
539  }
540 
541 #endif
542  Set< Potential< GUM_SCALAR >* >* my_pool
543  = new Set< Potential< GUM_SCALAR >* >();
544  std::pair< Idx, std::string > target;
545  Bijection< const DiscreteVariable*, const DiscreteVariable* > bij;
546  const Sequence< PRMInstance< GUM_SCALAR >* >& source
547  = **(data.matches.begin());
548 
549  for (Size idx = 0; idx < match.size(); ++idx) {
550  reducedInstances__.insert(match[idx]);
551  const auto& chains = source[idx]->type().slotChains();
552 
553  for (const auto sc: chains) {
554 #ifdef DEBUG
555  GUM_ASSERT(!(sc->isMultiple()));
556 #endif
557 
558  try {
559  bij.insert(&(source[idx]
560  ->getInstance(sc->id())
561  .get(sc->lastElt().safeName())
562  .type()
563  .variable()),
564  &(match[idx]
565  ->getInstance(sc->id())
566  .get(sc->lastElt().safeName())
567  .type()
568  .variable()));
569  } catch (DuplicateElement&) {
570  try {
571  if (bij.first(&(match[idx]
572  ->getInstance(sc->id())
573  .get(sc->lastElt().safeName())
574  .type()
575  .variable()))
576  != &(source[idx]
577  ->getInstance(sc->id())
578  .get(sc->lastElt().safeName())
579  .type()
580  .variable())) {
581  delete my_pool;
582  GUM_ERROR(OperationNotAllowed, "fake pattern");
583  }
584  } catch (NotFound&) {
585  delete my_pool;
586  GUM_ERROR(OperationNotAllowed, "fake pattern");
587  }
588  }
589  }
590  }
591 
592  for (const auto p: pool) {
593  for (const auto v: p->variablesSequence()) {
594  try {
595  target = data.map[data.vars.first(v)];
596  bij.insert(
597  v,
598  &(match[target.first]->get(target.second).type().variable()));
599  } catch (NotFound&) {
600  GUM_ASSERT(bij.existsFirst(v));
601  } catch (DuplicateElement&) {}
602  }
603 
604  try {
605  my_pool->insert(copyPotential(bij, *p));
606  } catch (Exception&) {
607  for (const auto pot: *my_pool)
608  delete pot;
609 
610  delete my_pool;
611  GUM_ERROR(OperationNotAllowed, "fake pattern");
612  }
613  }
614 
615  return my_pool;
616  }
Potential< GUM_SCALAR > * copyPotential(const Bijection< const DiscreteVariable *, const DiscreteVariable * > &bij, const Potential< GUM_SCALAR > &source)
Returns a copy of a Potential after applying a bijection over the variables in source.
Definition: utils_prm_tpl.h:28
Set< const PRMInstance< GUM_SCALAR > *> reducedInstances__
This keeps track of reduced instances.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:47
SetIterator< Key > const_iterator
Types for STL compliance.
Definition: set.h:177
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54
+ Here is the call graph for this function:

Member Data Documentation

◆ cdata_map__

template<typename GUM_SCALAR >
HashTable< const PRMClass< GUM_SCALAR >*, CData* > gum::prm::StructuredInference< GUM_SCALAR >::cdata_map__
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.

◆ dot__

template<typename GUM_SCALAR >
std::string gum::prm::StructuredInference< GUM_SCALAR >::dot__
private

Unreduce the match containing the query.

Used to create strings

Definition at line 367 of file structuredInference.h.

◆ elim_map__

template<typename GUM_SCALAR >
HashTable< const Sequence< PRMInstance< GUM_SCALAR >* >*, Set< Potential< GUM_SCALAR >* >* > gum::prm::StructuredInference< GUM_SCALAR >::elim_map__
private

Mapping between a Pattern's match and its potential pool after inner variables were eliminated.

Definition at line 256 of file structuredInference.h.

◆ found_query__

template<typename GUM_SCALAR >
bool gum::prm::StructuredInference< GUM_SCALAR >::found_query__
private

Flag with an explicit name.

Definition at line 283 of file structuredInference.h.

◆ full_time

template<typename GUM_SCALAR >
double gum::prm::StructuredInference< GUM_SCALAR >::full_time

Definition at line 384 of file structuredInference.h.

◆ gspan__

template<typename GUM_SCALAR >
GSpan< GUM_SCALAR >* gum::prm::StructuredInference< GUM_SCALAR >::gspan__
private

Pointer over th GSpan<GUM_SCALAR> instance used by this class.

Definition at line 249 of file structuredInference.h.

◆ inner_time

template<typename GUM_SCALAR >
double gum::prm::StructuredInference< GUM_SCALAR >::inner_time

Definition at line 382 of file structuredInference.h.

◆ mining__

template<typename GUM_SCALAR >
bool gum::prm::StructuredInference< GUM_SCALAR >::mining__
private

Flag which tells to use pattern mining or not.

Definition at line 280 of file structuredInference.h.

◆ mining_time

template<typename GUM_SCALAR >
double gum::prm::StructuredInference< GUM_SCALAR >::mining_time

Definition at line 380 of file structuredInference.h.

◆ obs_time

template<typename GUM_SCALAR >
double gum::prm::StructuredInference< GUM_SCALAR >::obs_time

Definition at line 383 of file structuredInference.h.

◆ outputs__

template<typename GUM_SCALAR >
HashTable< const PRMClass< GUM_SCALAR >*, std::vector< NodeId >* > gum::prm::StructuredInference< GUM_SCALAR >::outputs__
private

Definition at line 267 of file structuredInference.h.

◆ pattern_time

template<typename GUM_SCALAR >
double gum::prm::StructuredInference< GUM_SCALAR >::pattern_time

Definition at line 381 of file structuredInference.h.

◆ pdata__

template<typename GUM_SCALAR >
PData* gum::prm::StructuredInference< GUM_SCALAR >::pdata__
private

The pattern data of the pattern which one of its matches contains the query.

Definition at line 277 of file structuredInference.h.

◆ plopTimer

template<typename GUM_SCALAR >
Timer gum::prm::StructuredInference< GUM_SCALAR >::plopTimer

Definition at line 378 of file structuredInference.h.

◆ prm_

template<typename GUM_SCALAR>
PRM< GUM_SCALAR > const* gum::prm::PRMInference< GUM_SCALAR >::prm_
protectedinherited

The PRM<GUM_SCALAR> on which inference is done.

Definition at line 213 of file PRMInference.h.

◆ query__

template<typename GUM_SCALAR >
PRMInference< GUM_SCALAR >::Chain gum::prm::StructuredInference< GUM_SCALAR >::query__
private

The query.

Definition at line 273 of file structuredInference.h.

◆ query_data__

template<typename GUM_SCALAR >
std::pair< Idx, std::string > gum::prm::StructuredInference< GUM_SCALAR >::query_data__
private

Definition at line 284 of file structuredInference.h.

◆ reducedInstances__

template<typename GUM_SCALAR >
Set< const PRMInstance< GUM_SCALAR >* > gum::prm::StructuredInference< GUM_SCALAR >::reducedInstances__
private

This keeps track of reduced instances.

Definition at line 270 of file structuredInference.h.

◆ sys_

template<typename GUM_SCALAR>
PRMSystem< GUM_SCALAR > const* gum::prm::PRMInference< GUM_SCALAR >::sys_
protectedinherited

The Model on which inference is done.

Definition at line 216 of file PRMInference.h.

◆ timer

template<typename GUM_SCALAR >
Timer gum::prm::StructuredInference< GUM_SCALAR >::timer

Definition at line 377 of file structuredInference.h.

◆ trash__

template<typename GUM_SCALAR >
Set< Potential< GUM_SCALAR >* > gum::prm::StructuredInference< GUM_SCALAR >::trash__
private

Keeping track of create potentials to delete them after inference.

Definition at line 265 of file structuredInference.h.

◆ triang_time

template<typename GUM_SCALAR >
double gum::prm::StructuredInference< GUM_SCALAR >::triang_time

Definition at line 379 of file structuredInference.h.


The documentation for this class was generated from the following files: