aGrUM  0.20.3
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 55 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 58 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 65 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 61 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  }
PData * _pdata_
The pattern data of the pattern which one of its matches contains the query.
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.

◆ 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), _dot_(".") {
56  GUM_CONS_CPY(StructuredInference);
57  _gspan_ = new GSpan< GUM_SCALAR >(*(this->prm_), *(this->sys_));
58  }
PData * _pdata_
The pattern data of the pattern which one of its matches contains the query.
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:210
PRM< GUM_SCALAR > const * prm_
The PRM<GUM_SCALAR> on which inference is done.
Definition: PRMInference.h:207
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.
bool _found_query_
Flag with an explicit name.
+ Here is the call graph for this function:

◆ ~StructuredInference()

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

Destructor.

Definition at line 61 of file structuredInference_tpl.h.

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

61  {
62  GUM_DESTRUCTOR(StructuredInference);
63  delete this->_gspan_;
64 
65  for (const auto& elt: _elim_map_)
66  delete elt.second;
67 
68  for (const auto& elt: _cdata_map_)
69  delete elt.second;
70 
71  for (const auto elt: _trash_)
72  delete (elt);
73 
74  for (const auto& elt: _outputs_)
75  delete elt.second;
76 
77  if (_pdata_) delete _pdata_;
78  }
PData * _pdata_
The pattern data of the pattern which one of its matches contains the query.
GSpan< GUM_SCALAR > * _gspan_
Pointer over th GSpan<GUM_SCALAR> instance used by this class.
Set< Potential< GUM_SCALAR > *> _trash_
Keeping track of create potentials to delete them after inference.
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...
StructuredInference(const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &system, gspan::SearchStrategy< GUM_SCALAR > *strategy=0)
Default constructor.
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 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 690 of file structuredInference_tpl.h.

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

691  {
692  // We first add edges between variables already in pool (i.e. those of the
693  // reduced instances)
694  NodeId id_1, id_2;
695 
696  for (const auto pot: data.pool) {
697  const Sequence< const DiscreteVariable* >& vars = pot->variablesSequence();
698 
699  for (Size var_1 = 0; var_1 < vars.size(); ++var_1) {
700  if (data.var2node.existsFirst(vars.atPos(var_1))) {
701  id_1 = data.var2node.second(vars.atPos(var_1));
702  } else {
703  id_1 = data.reducedGraph.addNode();
704  data.var2node.insert(vars.atPos(var_1), id_1);
705  data.mods.insert(id_1, vars.atPos(var_1)->domainSize());
706  data.outputs().insert(id_1);
707  }
708 
709  for (Size var_2 = var_1 + 1; var_2 < vars.size(); ++var_2) {
710  if (data.var2node.existsFirst(vars.atPos(var_2))) {
711  id_2 = data.var2node.second(vars.atPos(var_2));
712  } else {
713  id_2 = data.reducedGraph.addNode();
714  data.var2node.insert(vars.atPos(var_2), id_2);
715  data.mods.insert(id_2, vars.atPos(var_2)->domainSize());
716  data.outputs().insert(id_2);
717  }
718 
719  try {
720  data.reducedGraph.addEdge(id_1, id_2);
721  } catch (DuplicateElement&) {}
722  }
723  }
724  }
725 
726  // Adding potentials obtained from reduced patterns
727  for (const auto& elt: _elim_map_) {
728  // We add edges between variables in the same reduced patterns
729  for (const auto pot: *elt.second) {
730  data.pool.insert(pot);
731  const Sequence< const DiscreteVariable* >& vars = pot->variablesSequence();
732 
733  for (Size var_1 = 0; var_1 < vars.size(); ++var_1) {
734  if (data.var2node.existsFirst(vars.atPos(var_1))) {
735  id_1 = data.var2node.second(vars.atPos(var_1));
736  } else {
737  id_1 = data.reducedGraph.addNode();
738  data.var2node.insert(vars.atPos(var_1), id_1);
739  data.mods.insert(id_1, vars.atPos(var_1)->domainSize());
740  data.outputs().insert(id_1);
741  }
742 
743  for (Size var_2 = var_1 + 1; var_2 < vars.size(); ++var_2) {
744  if (data.var2node.existsFirst(vars.atPos(var_2))) {
745  id_2 = data.var2node.second(vars.atPos(var_2));
746  } else {
747  id_2 = data.reducedGraph.addNode();
748  data.var2node.insert(vars.atPos(var_2), id_2);
749  data.mods.insert(id_2, vars.atPos(var_2)->domainSize());
750  data.outputs().insert(id_2);
751  }
752 
753  try {
754  data.reducedGraph.addEdge(id_1, id_2);
755  } catch (DuplicateElement&) {}
756  }
757  }
758  }
759  }
760  }
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...
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:47
Size NodeId
Type for node ids.
Definition: graphElements.h:97
+ Here is the call graph for this function:

◆ _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 383 of file structuredInference_tpl.h.

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

385  {
386  for (const auto mat: data.matches)
387  if (mat->atPos(attr.first)->hasRefAttr(mat->atPos(attr.first)->get(attr.second).id()))
388  return false;
389 
390  return true;
391  }
+ 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 328 of file structuredInference_tpl.h.

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

331  {
332  std::pair< Idx, std::string > v;
333  Potential< GUM_SCALAR >* pot = 0;
334 
335  for (const auto inst: match) {
336  for (const auto& elt: *inst) {
337  NodeId id = data.graph.addNode();
338  v = std::make_pair(match.pos(inst), elt.second->safeName());
339  data.map.insert(id, v);
340  data.node2attr.insert(id, _str_(inst, elt.second));
341  data.mod.insert(id, elt.second->type()->domainSize());
342  data.vars.insert(id, &(elt.second->type().variable()));
343  pool.insert(const_cast< Potential< GUM_SCALAR >* >(&(elt.second->cpf())));
344  pot = &(const_cast< Potential< GUM_SCALAR >& >(inst->get(v.second).cpf()));
345 
346  for (const auto var: pot->variablesSequence()) {
347  try {
348  if (id != data.vars.first(var)) data.graph.addEdge(id, data.vars.first(var));
349  } catch (DuplicateElement&) {
350  } catch (NotFound&) {}
351  }
352 
353  _insertNodeInElimLists_(data, match, inst, elt.second, id, v);
354 
355  if (data.inners().exists(id)
356  && (inst->type().containerDag().children(elt.second->id()).size() == 0)
357  && _allInstanceNoRefAttr_(data, v))
358  data.barren.insert(id);
359  }
360  }
361 
362  if (!_found_query_) {
363  for (const auto mat: data.matches) {
364  if (mat->exists(const_cast< PRMInstance< GUM_SCALAR >* >(_query_.first))) {
365  Idx pos = mat->pos(const_cast< PRMInstance< GUM_SCALAR >* >(_query_.first));
366  DiscreteVariable& var
367  = match.atPos(pos)->get(_query_.second->safeName()).type().variable();
368  NodeId id = data.vars.first(&var);
369  data.barren.erase(id);
370  data.inners().erase(id);
371  data.obs().erase(id);
372  data.outputs().erase(id);
373  data.queries().insert(id);
374  _found_query_ = true;
375  _query_data_ = std::make_pair(pos, _query_.second->safeName());
376  break;
377  }
378  }
379  }
380  }
std::string _str_(const PRMInstance< GUM_SCALAR > *i, const PRMAttribute< GUM_SCALAR > *a) const
bool _allInstanceNoRefAttr_(typename StructuredInference::PData &data, std::pair< Idx, std::string > attr)
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)
std::pair< Idx, std::string > _query_data_
PRMInference< GUM_SCALAR >::Chain _query_
The query.
bool _found_query_
Flag with an explicit name.
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 203 of file structuredInference_tpl.h.

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

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

◆ _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 467 of file structuredInference_tpl.h.

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

471  {
472  Set< Potential< GUM_SCALAR >* >* my_pool = _translatePotSet_(data, pool, match);
473  std::pair< Idx, std::string > target;
474  size_t end = data.inners().size() + data.obs().size();
475 
476  for (size_t idx = data.inners().size(); idx < end; ++idx) {
477  target = data.map[data.vars.first(data.vars.second(elim_order[idx]))];
478  eliminateNode(&(match[target.first]->get(target.second).type().variable()),
479  *my_pool,
480  _trash_);
481  }
482 
483  return my_pool;
484  }
Set< Potential< GUM_SCALAR > *> _trash_
Keeping track of create potentials to delete them after inference.
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 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:

◆ _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 447 of file structuredInference_tpl.h.

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

451  {
452  Set< Potential< GUM_SCALAR >* >* my_pool = new Set< Potential< GUM_SCALAR >* >(pool);
453  std::pair< Idx, std::string > target;
454  size_t end = data.inners().size() + data.obs().size();
455 
456  for (size_t idx = data.inners().size(); idx < end; ++idx) {
457  target = data.map[data.vars.first(data.vars.second(elim_order[idx]))];
458  eliminateNode(&(match[target.first]->get(target.second).type().variable()),
459  *my_pool,
460  _trash_);
461  }
462 
463  return my_pool;
464  }
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:

◆ _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 294 of file structuredInference_tpl.h.

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

300  {
301  if ((*inst).hasRefAttr((*inst).get(v.second).id())) {
302  std::vector< std::pair< PRMInstance< GUM_SCALAR >*, std::string > >& refs
303  = inst->getRefAttr(inst->get(v.second).id());
304 
305  for (auto r = refs.begin(); r != refs.end(); ++r) {
306  if (!match.exists(r->first)) {
307  data.outputs().insert(id);
308  break;
309  }
310  }
311  }
312 
313  if (!(data.outputs().size() && (data.outputs().exists(id)))) {
314  for (const auto m: data.matches) {
315  if (this->hasEvidence(std::make_pair((*m)[v.first], &((*m)[v.first]->get(v.second))))) {
316  GUM_ASSERT(inst->type().name() == (*m)[v.first]->type().name());
317  GUM_ASSERT(inst->get(v.second).safeName() == (*m)[v.first]->get(v.second).safeName());
318  data.obs().insert(id);
319  break;
320  }
321  }
322 
323  if (!(data.obs().size() && (data.obs().exists(id)))) data.inners().insert(id);
324  }
325  }
bool hasEvidence() const
Returns true if i has evidence on PRMAttribute<GUM_SCALAR> a.
+ Here is the call graph for this function:

◆ _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 576 of file structuredInference_tpl.h.

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

577  {
578  StructuredInference< GUM_SCALAR >::CData* data = 0;
579  Potential< GUM_SCALAR >* pot = nullptr;
580  PRMInstance< GUM_SCALAR >* inst = nullptr;
581 
582  for (const auto& elt: *this->sys_) {
583  inst = elt.second;
584 
585  if (!_reducedInstances_.exists(inst)) {
586  // Checking if its not an empty class
587  if (inst->size()) {
588  Set< Potential< GUM_SCALAR >* > pool;
589 
590  try {
591  data = _cdata_map_[&(inst->type())];
592  } catch (NotFound&) {
593  data = new StructuredInference< GUM_SCALAR >::CData(inst->type());
594  _cdata_map_.insert(&(inst->type()), data);
595  }
596 
597  data->instances.insert(inst);
598  // Filling up the partial ordering
599  List< NodeSet > partial_order;
600 
601  if (data->inners().size()) partial_order.push_back(data->inners());
602 
603  if (data->aggregators().size())
604  for (const auto agg: data->aggregators())
605  partial_order[0].insert(agg);
606 
607  if (data->outputs().size()) partial_order.push_back(data->outputs());
608 
609  if (_query_.first == inst) {
610  // First case, the instance contains the query
611  partial_order[0].erase(_query_.second->id());
612 
613  if (partial_order[0].empty()) partial_order.erase(0);
614 
615  if (partial_order.size() > 1) {
616  partial_order[1].erase(_query_.second->id());
617 
618  if (partial_order[1].empty()) partial_order.erase(1);
619  }
620 
621  NodeSet query_set;
622  query_set.insert(_query_.second->id());
623  partial_order.insert(query_set);
624 
625  // Adding the potentials
626  for (auto attr = inst->begin(); attr != inst->end(); ++attr)
627  pool.insert(&(const_cast< Potential< GUM_SCALAR >& >((*(attr.val())).cpf())));
628 
629  // Adding evidences if any
630  if (this->hasEvidence(inst))
631  for (const auto& elt: this->evidence(inst))
632  pool.insert(const_cast< Potential< GUM_SCALAR >* >(elt.second));
633 
634  PartialOrderedTriangulation t(&(data->moral_graph), &(data->mods), &(partial_order));
635  const std::vector< NodeId >& v = t.eliminationOrder();
636 
637  if (partial_order.size() > 1)
638  for (size_t idx = 0; idx < partial_order[0].size(); ++idx)
639  eliminateNode(&(inst->get(v[idx]).type().variable()), pool, _trash_);
640  } else if (this->hasEvidence(inst)) {
641  // Second case, the instance has evidences
642  // Adding the potentials
643  for (const auto elt: *inst)
644  pool.insert(&const_cast< Potential< GUM_SCALAR >& >(elt.second->cpf()));
645 
646  // Adding evidences
647  for (const auto& elt: this->evidence(inst))
648  pool.insert(const_cast< Potential< GUM_SCALAR >* >(elt.second));
649 
650  PartialOrderedTriangulation t(&(data->moral_graph), &(data->mods), &(partial_order));
651 
652  for (size_t idx = 0; idx < partial_order[0].size(); ++idx)
653  eliminateNode(&(inst->get(t.eliminationOrder()[idx]).type().variable()),
654  pool,
655  _trash_);
656  } else {
657  // Last cast, the instance neither contains evidences nor
658  // instances
659  // We translate the class level potentials into the instance ones
660  // and
661  // proceed with elimination
662  for (const auto srcPot: data->pool) {
663  pot = copyPotential(inst->bijection(), *srcPot);
664  pool.insert(pot);
665  _trash_.insert(pot);
666  }
667 
668  for (const auto agg: data->c.aggregates())
669  pool.insert(&(const_cast< Potential< GUM_SCALAR >& >(inst->get(agg->id()).cpf())));
670 
671  // We eliminate inner aggregators with their parents if necessary
672  // (see
673  // CData constructor)
674  Size size = data->inners().size() + data->aggregators().size();
675 
676  for (size_t idx = data->inners().size(); idx < size; ++idx)
677  eliminateNode(&(inst->get(data->elim_order()[idx]).type().variable()),
678  pool,
679  _trash_);
680  }
681 
682  for (const auto pot: pool)
683  rg_data.pool.insert(pot);
684  }
685  }
686  }
687  }
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
EMap & evidence(const PRMInstance< GUM_SCALAR > &i)
Returns EMap of evidences over i.
Set< const PRMInstance< GUM_SCALAR > *> _reducedInstances_
This keeps track of reduced instances.
Set< Potential< GUM_SCALAR > *> _trash_
Keeping track of create potentials to delete them after inference.
PRMSystem< GUM_SCALAR > const * sys_
The Model on which inference is done.
Definition: PRMInference.h:210
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:29
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.
PRMInference< GUM_SCALAR >::Chain _query_
The query.
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...
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:606
+ 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 236 of file structuredInference_tpl.h.

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

236  {
237  Set< Potential< GUM_SCALAR >* > pool;
238  typename StructuredInference< GUM_SCALAR >::PData data(*p, _gspan_->matches(*p));
239  _buildPatternGraph_(data, pool, **(data.matches.begin()));
240  _removeBarrenNodes_(data, pool);
241  PartialOrderedTriangulation t(&(data.graph), &(data.mod), data.partial_order());
242  const std::vector< NodeId >& elim_order = t.eliminationOrder();
243 
244  for (size_t i = 0; i < data.inners().size(); ++i)
245  if (!data.barren.exists(elim_order[i]))
246  eliminateNode(data.vars.second(elim_order[i]), pool, _trash_);
247 
248  typename GSpan< GUM_SCALAR >::MatchedInstances fake_patterns;
249  typename GSpan< GUM_SCALAR >::MatchedInstances::const_iterator iter = data.matches.begin();
250 
251  for (const auto elt: **iter)
252  _reducedInstances_.insert(elt);
253 
254  if (data.obs().size())
255  _elim_map_.insert(*iter, _eliminateObservedNodesInSource_(data, pool, **iter, elim_order));
256  else
257  _elim_map_.insert(*iter, new Set< Potential< GUM_SCALAR >* >(pool));
258 
259  ++iter;
260 
261  if (data.obs().size()) {
262  for (; iter != data.matches.end(); ++iter) {
263  try {
264  _elim_map_.insert(*iter, _eliminateObservedNodes_(data, pool, **iter, elim_order));
265  } catch (OperationNotAllowed&) { fake_patterns.insert(*iter); }
266  }
267  } else {
268  for (; iter != data.matches.end(); ++iter) {
269  try {
270  _elim_map_.insert(*iter, _translatePotSet_(data, pool, **iter));
271  } catch (OperationNotAllowed&) { fake_patterns.insert(*iter); }
272  }
273  }
274 
275  for (const auto pat: fake_patterns) {
276  for (const auto elt: *pat)
277  _reducedInstances_.erase(elt);
278 
279  data.matches.erase(pat);
280  }
281 
282  obs_time += plopTimer.step();
283 
284  if (data.queries().size())
285  for (const auto m: data.matches)
286  if (!(m->exists(const_cast< PRMInstance< GUM_SCALAR >* >(_query_.first))))
288  &(m->atPos(_query_data_.first)->get(_query_data_.second).type().variable()),
289  *(_elim_map_[m]),
290  _trash_);
291  }
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...
double step() const
Returns the delta time between now and the last reset() call (or the constructor).
Definition: timer_inl.h:41
GSpan< GUM_SCALAR > * _gspan_
Pointer over th GSpan<GUM_SCALAR> instance used by this class.
Set< Sequence< PRMInstance< GUM_SCALAR > *> *> MatchedInstances
Code alias.
Definition: gspan.h:169
void _removeBarrenNodes_(typename StructuredInference::PData &data, Set< Potential< GUM_SCALAR > * > &pool)
Set< const PRMInstance< GUM_SCALAR > *> _reducedInstances_
This keeps track of reduced instances.
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)
Set< Potential< GUM_SCALAR > *> _trash_
Keeping track of create potentials to delete them after inference.
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...
std::pair< Idx, std::string > _query_data_
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 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 > *> * _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.
PRMInference< GUM_SCALAR >::Chain _query_
The query.
SetIterator< Key > const_iterator
Types for STL compliance.
Definition: set.h:177
+ 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 394 of file structuredInference_tpl.h.

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

396  {
397  Sequence< NodeId > candidates;
398 
399  for (const auto node: data.barren) {
400  for (const auto pot: pool)
401  if (pot->contains(*data.vars.second(node))) {
402  pool.erase(pot);
403  break;
404  }
405 
406  for (const auto nei: data.graph.neighbours(node))
407  if (data.inners().exists(nei)) {
408  try {
409  candidates.insert(nei);
410  } catch (DuplicateElement&) {}
411  }
412  }
413 
414  NodeId node;
415  Potential< GUM_SCALAR >* my_pot = nullptr;
416  short count = 0;
417 
418  while (candidates.size()) {
419  node = candidates.back();
420  candidates.erase(node);
421  count = 0;
422 
423  for (const auto pot: pool) {
424  if (pot->contains(*data.vars.second(node))) {
425  ++count;
426  my_pot = pot;
427  }
428  }
429 
430  if (count == 1) {
431  pool.erase(my_pot);
432  data.barren.insert(node);
433 
434  for (const auto nei: data.graph.neighbours(node)) {
435  if (data.inners().exists(nei)) {
436  try {
437  candidates.insert(nei);
438  } catch (DuplicateElement&) {}
439  }
440  }
441  }
442  }
443  }
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:437
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:546
void insert(const Key &k)
Insert an element at the end of the sequence.
Definition: sequence_tpl.h:393
+ Here is the call graph for this function:

◆ _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 973 of file structuredInference_tpl.h.

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

976  {
977  data.graph.eraseNode(id);
978  GUM_ASSERT(!data.graph.exists(id));
979  data.mod.erase(id);
980  GUM_ASSERT(!data.mod.exists(id));
981  data.node2attr.eraseFirst(id);
982  GUM_ASSERT(!data.node2attr.existsFirst(id));
983  data.map.erase(id);
984  GUM_ASSERT(!data.map.exists(id));
985  data.vars.eraseFirst(id);
986  GUM_ASSERT(!data.vars.existsFirst(id));
987  data.inners().erase(id);
988  GUM_ASSERT(!data.inners().exists(id));
989  pool.erase(data.pots[id]);
990  GUM_ASSERT(!pool.exists(data.pots[id]));
991  data.pots.erase(id);
992  GUM_ASSERT(!data.pots.exists(id));
993  }
+ 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 928 of file structuredInference_tpl.h.

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

929  {
930  return i->name() + _dot_ + a->safeName();
931  }
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 935 of file structuredInference_tpl.h.

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

936  {
937  return i->name() + _dot_ + a.safeName();
938  }
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 942 of file structuredInference_tpl.h.

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

943  {
944  return i->name() + _dot_ + a.lastElt().safeName();
945  }
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 487 of file structuredInference_tpl.h.

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

490  {
491 #ifdef DEBUG
492 
493  for (GSpan< GUM_SCALAR >::MatchedInstances::const_iterator iter = data.matches.begin();
494  iter != data.matches.end();
495  ++iter) {
496  GUM_ASSERT((**iter).size() == match.size());
497 
498  for (Size idx = 0; idx < match.size(); ++idx) {
499  GUM_ASSERT((**iter).atPos(idx)->type() == match.atPos(idx)->type());
500  }
501  }
502 
503 #endif
504  Set< Potential< GUM_SCALAR >* >* my_pool = new Set< Potential< GUM_SCALAR >* >();
505  std::pair< Idx, std::string > target;
506  Bijection< const DiscreteVariable*, const DiscreteVariable* > bij;
507  const Sequence< PRMInstance< GUM_SCALAR >* >& source = **(data.matches.begin());
508 
509  for (Size idx = 0; idx < match.size(); ++idx) {
510  _reducedInstances_.insert(match[idx]);
511  const auto& chains = source[idx]->type().slotChains();
512 
513  for (const auto sc: chains) {
514 #ifdef DEBUG
515  GUM_ASSERT(!(sc->isMultiple()));
516 #endif
517 
518  try {
519  bij.insert(&(source[idx]
520  ->getInstance(sc->id())
521  .get(sc->lastElt().safeName())
522  .type()
523  .variable()),
524  &(match[idx]
525  ->getInstance(sc->id())
526  .get(sc->lastElt().safeName())
527  .type()
528  .variable()));
529  } catch (DuplicateElement&) {
530  try {
531  if (bij.first(&(match[idx]
532  ->getInstance(sc->id())
533  .get(sc->lastElt().safeName())
534  .type()
535  .variable()))
536  != &(source[idx]
537  ->getInstance(sc->id())
538  .get(sc->lastElt().safeName())
539  .type()
540  .variable())) {
541  delete my_pool;
542  GUM_ERROR(OperationNotAllowed, "fake pattern")
543  }
544  } catch (NotFound&) {
545  delete my_pool;
546  GUM_ERROR(OperationNotAllowed, "fake pattern")
547  }
548  }
549  }
550  }
551 
552  for (const auto p: pool) {
553  for (const auto v: p->variablesSequence()) {
554  try {
555  target = data.map[data.vars.first(v)];
556  bij.insert(v, &(match[target.first]->get(target.second).type().variable()));
557  } catch (NotFound&) { GUM_ASSERT(bij.existsFirst(v)); } catch (DuplicateElement&) {
558  }
559  }
560 
561  try {
562  my_pool->insert(copyPotential(bij, *p));
563  } catch (Exception&) {
564  for (const auto pot: *my_pool)
565  delete pot;
566 
567  delete my_pool;
568  GUM_ERROR(OperationNotAllowed, "fake pattern")
569  }
570  }
571 
572  return my_pool;
573  }
Set< const PRMInstance< GUM_SCALAR > *> _reducedInstances_
This keeps track of reduced instances.
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:29
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:51
+ 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 105 of file PRMInference_tpl.h.

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

◆ 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:228

◆ 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 151 of file PRMInference_tpl.h.

151  {
152  try {
153  return *(_evidences_[&i]);
154  } catch (NotFound&) { GUM_ERROR(NotFound, "this instance has no evidence.") }
155  }
HashTable< const PRMInstance< GUM_SCALAR > *, EMap *> _evidences_
Mapping of evidence over PRMInstance<GUM_SCALAR>&#39;s nodes.
Definition: PRMInference.h:228
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ 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 167 of file PRMInference_tpl.h.

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

◆ 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 159 of file PRMInference_tpl.h.

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

◆ 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 175 of file PRMInference_tpl.h.

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

◆ 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 93 of file structuredInference_tpl.h.

94  {}

◆ 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 97 of file structuredInference_tpl.h.

98  {}

◆ 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 963 of file structuredInference_tpl.h.

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

963  {
964  return *_gspan_;
965  }
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 968 of file structuredInference_tpl.h.

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

968  {
969  return *_gspan_;
970  }
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 182 of file PRMInference_tpl.h.

182  {
183  return _evidences_.exists(&i);
184  }
HashTable< const PRMInstance< GUM_SCALAR > *, EMap *> _evidences_
Mapping of evidence over PRMInstance<GUM_SCALAR>&#39;s nodes.
Definition: PRMInference.h:228

◆ 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 187 of file PRMInference_tpl.h.

187  {
188  return _evidences_.exists(i);
189  }
HashTable< const PRMInstance< GUM_SCALAR > *, EMap *> _evidences_
Mapping of evidence over PRMInstance<GUM_SCALAR>&#39;s nodes.
Definition: PRMInference.h:228

◆ 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 192 of file PRMInference_tpl.h.

192  {
193  return (hasEvidence(chain.first)) ? evidence(chain.first).exists(chain.second->id()) : false;
194  }
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 197 of file PRMInference_tpl.h.

197  {
198  return (_evidences_.size() != (Size)0);
199  }
HashTable< const PRMInstance< GUM_SCALAR > *, EMap *> _evidences_
Mapping of evidence over PRMInstance<GUM_SCALAR>&#39;s nodes.
Definition: PRMInference.h:228
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 179 of file structuredInference_tpl.h.

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

179  {
180  std::stringstream s;
181  s << "Triangulation time: " << triang_time << std::endl;
182  s << "Pattern mining time: " << mining_time << std::endl;
183  s << "Pattern elimination time: " << pattern_time << std::endl;
184  s << "Inner node elimination time: " << inner_time << std::endl;
185  s << "Observed node elimination time: " << obs_time << std::endl;
186  s << "Full inference time: " << full_time << std::endl;
187  s << "#patterns: " << _gspan_->patterns().size() << std::endl;
188  Size count = 0;
189  typedef std::vector< gspan::Pattern* >::const_iterator Iter;
190 
191  for (Iter p = _gspan_->patterns().begin(); p != _gspan_->patterns().end(); ++p) {
192  if (_gspan_->matches(**p).size()) {
193  s << "Pattern n°" << count++ << " match count: " << _gspan_->matches(**p).size()
194  << std::endl;
195  s << "Pattern n°" << count++ << " instance count: " << (**p).size() << std::endl;
196  }
197  }
198 
199  return s.str();
200  }
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:

◆ 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 241 of file PRMInference_tpl.h.

243  {
244  if (j.nbrDim() > 0) { GUM_ERROR(OperationNotAllowed, "the given Potential is not empty.") }
245 
246  for (auto chain = chains.begin(); chain != chains.end(); ++chain) {
247  j.add(chain->second->type().variable());
248  }
249 
250  joint_(chains, j);
251  }
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:51

◆ 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 172 of file structuredInference_tpl.h.

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

174  {
175  GUM_ERROR(FatalError, "not implemented")
176  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51
+ 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 958 of file structuredInference_tpl.h.

958  {
959  return "StructuredInference";
960  }

◆ operator=()

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

82  {
83  this->prm_ = source.prm_;
84  this->sys_ = source.sys_;
85 
86  if (this->_gspan_) delete this->_gspan_;
87 
88  this->_gspan_ = new GSpan< GUM_SCALAR >(*(this->prm_), *(this->sys_));
89  return *this;
90  }
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:210
PRM< GUM_SCALAR > const * prm_
The PRM<GUM_SCALAR> on which inference is done.
Definition: PRMInference.h:207
+ 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 215 of file PRMInference_tpl.h.

217  {
218  if (m.nbrDim() > 0) { GUM_ERROR(OperationNotAllowed, "the given Potential is not empty.") }
219 
220  if (hasEvidence(chain)) {
221  m.add(chain.second->type().variable());
222  const Potential< GUM_SCALAR >& e = *(evidence(chain.first)[chain.second->id()]);
223  Instantiation i(m), j(e);
224 
225  for (i.setFirst(), j.setFirst(); !i.end(); i.inc(), j.inc())
226  m.set(i, e.get(j));
227  } else {
228  if (chain.second != &(chain.first->get(chain.second->safeName()))) {
229  typename PRMInference< GUM_SCALAR >::Chain good_chain
230  = std::make_pair(chain.first, &(chain.first->get(chain.second->safeName())));
231  m.add(good_chain.second->type().variable());
232  posterior_(good_chain, m);
233  } else {
234  m.add(chain.second->type().variable());
235  posterior_(chain, m);
236  }
237  }
238  }
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:55
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ 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 101 of file structuredInference_tpl.h.

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

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

◆ 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 202 of file PRMInference_tpl.h.

202  {
203  try {
204  if (_EMap_(chain.first).exists(chain.second->id())) {
205  evidenceRemoved_(chain);
206  delete _EMap_(chain.first)[chain.second->id()];
207  _EMap_(chain.first).erase(chain.second->id());
208  }
209  } catch (NotFound&) {
210  // Ok, we are only removing
211  }
212  }
EMap & _EMap_(const PRMInstance< GUM_SCALAR > *i)
Private getter over evidences, if necessary creates an EMap for i.
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...

◆ searchPatterns()

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

913  {
914  const PRMInstance< GUM_SCALAR >* i = (this->sys_->begin()).val();
915  _query_ = std::make_pair(i, i->begin().val());
916  _found_query_ = false;
917  typename StructuredInference< GUM_SCALAR >::RGData data;
918  _buildReduceGraph_(data);
919  }
void _buildReduceGraph_(RGData &data)
This calls reducePattern() over each pattern and then build the reduced graph which is used for infer...
PRMSystem< GUM_SCALAR > const * sys_
The Model on which inference is done.
Definition: PRMInference.h:210
PRMInference< GUM_SCALAR >::Chain _query_
The query.
bool _found_query_
Flag with an explicit name.
+ 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 922 of file structuredInference_tpl.h.

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

922  {
923  _mining_ = b;
924  }
bool _mining_
Flag which tells to use pattern mining or not.
+ 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 256 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 359 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 250 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 277 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 244 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 274 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 261 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 271 of file structuredInference.h.

◆ _query_

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

The query.

Definition at line 267 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 278 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 264 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 259 of file structuredInference.h.

◆ full_time

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

Definition at line 376 of file structuredInference.h.

◆ inner_time

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

Definition at line 374 of file structuredInference.h.

◆ mining_time

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

Definition at line 372 of file structuredInference.h.

◆ obs_time

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

Definition at line 375 of file structuredInference.h.

◆ pattern_time

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

Definition at line 373 of file structuredInference.h.

◆ plopTimer

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

Definition at line 370 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 207 of file PRMInference.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 210 of file PRMInference.h.

◆ timer

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

Definition at line 369 of file structuredInference.h.

◆ triang_time

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

Definition at line 371 of file structuredInference.h.


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