aGrUM  0.13.2
BayesNetInference_tpl.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
27 
28 namespace gum {
29 
30 
31  // Default Constructor
32  template < typename GUM_SCALAR >
34  const IBayesNet< GUM_SCALAR >* bn) :
35  __bn(bn) {
37 
38  GUM_CONSTRUCTOR(BayesNetInference);
39  }
40 
41 
42  // Default Constructor
43  template < typename GUM_SCALAR >
45  GUM_CONSTRUCTOR(BayesNetInference);
46  }
47 
48 
49  // Destructor
50  template < typename GUM_SCALAR >
52  // clear all evidence.
53  // Warning: Do not use method eraseAllEvidence () because it contains a call
54  // to pure virtual method _onAllEvidenceErased which belongs to an inherited
55  // instance and, therefore, does not exist anymore when ~BayesNetInference ()
56  // is called
57  for (const auto& pair : __evidence) {
58  if (pair.second != nullptr) { delete (pair.second); }
59  }
60 
61  GUM_DESTRUCTOR(BayesNetInference);
62  }
63 
64 
65  // returns whether the inference object is in a ready state
66  template < typename GUM_SCALAR >
69  }
70  // returns whether the inference object is in a OutdatedBNStructure state
71  template < typename GUM_SCALAR >
72  INLINE bool
74  noexcept {
76  }
77  // returns whether the inference object is in a OutdatedBNPotential state
78  template < typename GUM_SCALAR >
79  INLINE bool
81  noexcept {
83  }
84  // returns whether the inference object is in a InferenceDone state
85  template < typename GUM_SCALAR >
86  INLINE bool BayesNetInference< GUM_SCALAR >::isInferenceDone() const noexcept {
87  return (__state == StateOfInference::Done);
88  }
89 
90 
91  // returns whether the inference object is in a done state
92  template < typename GUM_SCALAR >
93  INLINE bool BayesNetInference< GUM_SCALAR >::isDone() const noexcept {
94  return (__state == StateOfInference::Done);
95  }
96 
97 
98  // returns the state of the inference engine
99  template < typename GUM_SCALAR >
102  return __state;
103  }
104 
105  // set the state of the inference
106  template < typename GUM_SCALAR >
107  INLINE void
109  if (__state != state) {
110  __state = state;
111  _onStateChanged();
112  }
113  }
114 
115  // Returns a constant reference over the IBayesNet referenced by this class
116  template < typename GUM_SCALAR >
117  INLINE const IBayesNet< GUM_SCALAR >&
119  if (__bn == nullptr)
121  "No Bayes net has been assigned to "
122  "the inference algorithm.");
123  return *__bn;
124  }
125 
126 
127  // assigns a new BN to the inference engine
128  template < typename GUM_SCALAR >
130  clear();
131  __bn = bn;
133  _onBayesNetChanged(bn);
135  }
136 
137 
138  // assigns a BN to a newly constructed inference engine
139  template < typename GUM_SCALAR >
141  const IBayesNet< GUM_SCALAR >* bn) {
142  __bn = bn;
145  }
146 
147 
148  // clears all the data structures allocated for the last inference
149  template < typename GUM_SCALAR >
153  }
154 
155 
157  template < typename GUM_SCALAR >
159  __domain_sizes.clear();
160  if (__bn != nullptr) {
161  for (const auto node : __bn->dag()) {
162  __domain_sizes.insert(node, __bn->variable(node).domainSize());
163  }
164  }
165  }
166 
167 
168  // get the domain sizes of the random variables of the BN
169  template < typename GUM_SCALAR >
170  INLINE const NodeProperty< Size >&
172  return __domain_sizes;
173  }
174 
175 
176  // ##############################################################################
177  // Evidence
178  // ##############################################################################
179 
180  // create the internal structure for a hard evidence
181  template < typename GUM_SCALAR >
184  const Idx val) const {
185  // check that it is possible to create the evidence
186  if (__bn == nullptr)
188  "No Bayes net has been assigned to the "
189  "inference algorithm");
190 
191  if (!__bn->dag().exists(id)) {
192  GUM_ERROR(UndefinedElement, id << " is not a NodeId in the bn");
193  }
194 
195  if (__bn->variable(id).domainSize() <= val) {
197  "node " << __bn->variable(id) << " has fewer possible values than "
198  << val);
199  }
200 
201  // create the deterministic potential
203  pot.beginMultipleChanges();
204  pot << __bn->variable(id);
205  pot.endMultipleChanges(0.0);
206 
207  Instantiation I(pot);
208  I.chgVal(__bn->variable(id), val);
209  pot.set(I, 1.0);
210 
211  return pot;
212  }
213 
214 
215  // checks wether a potential corresponds to a hard evidence
216  template < typename GUM_SCALAR >
218  const Potential< GUM_SCALAR >& pot, Idx& val) const {
219  // checking if pot is determininstic
220  bool notZero = false;
221  Instantiation I(pot);
222 
223  for (I.setFirst(); !I.end(); I.inc()) {
224  if (pot[I] != 0.0) {
225  if (notZero) { // we already met a non-zero value
226  return false;
227  } else {
228  val = I.val(0);
229  notZero = true; // this is the first met non-zero value
230  }
231  }
232  }
233 
234  if (!notZero) { // we met no non-zero value
235  GUM_ERROR(FatalError, "Evidence of impossibility (vector of 0s)");
236  }
237 
238  return true; // pot is deterministic
239  }
240 
241 
242  // adds a new hard evidence on node id
243  template < typename GUM_SCALAR >
245  const Idx val) {
247  }
248 
249  // adds a new hard evidence on node id
250  template < typename GUM_SCALAR >
251  INLINE void
252  BayesNetInference< GUM_SCALAR >::addEvidence(const std::string& nodeName,
253  const Idx val) {
254  addEvidence(this->BN().idFromName(nodeName), val);
255  }
256 
257  // adds a new hard evidence on node id
258  template < typename GUM_SCALAR >
259  INLINE void
261  const std::string& label) {
262  addEvidence(id, this->BN().variable(id)[label]);
263  }
264 
265  // adds a new hard evidence on node id
266  template < typename GUM_SCALAR >
267  INLINE void
268  BayesNetInference< GUM_SCALAR >::addEvidence(const std::string& nodeName,
269  const std::string& label) {
270  NodeId id = this->BN().idFromName(nodeName);
271  addEvidence(id, this->BN().variable(id)[label]);
272  }
273 
274  // adds a new evidence on node id (might be soft or hard)
275  template < typename GUM_SCALAR >
277  NodeId id, const std::vector< GUM_SCALAR >& vals) {
278  // checks that the evidence is meaningful
279  if (__bn == nullptr)
281  "No Bayes net has been assigned to the "
282  "inference algorithm");
283 
284  if (!__bn->dag().exists(id)) {
285  GUM_ERROR(UndefinedElement, id << " is not a NodeId in the bn");
286  }
287 
288  if (__bn->variable(id).domainSize() != vals.size()) {
290  "node " << __bn->variable(id)
291  << " and its evidence vector have different sizes.");
292  }
293 
295  pot.add(__bn->variable(id));
296  pot.fillWith(vals);
297  addEvidence(std::move(pot));
298  }
299 
300  // adds a new evidence on node id (might be soft or hard)
301  template < typename GUM_SCALAR >
303  const std::string& nodeName, const std::vector< GUM_SCALAR >& vals) {
304  addEvidence(this->BN().idFromName(nodeName), vals);
305  }
306 
307  // adds a new evidence on node id (might be soft or hard)
308  template < typename GUM_SCALAR >
309  void
311  // check if the potential corresponds to an evidence
312  if (pot.nbrDim() != 1) {
313  GUM_ERROR(InvalidArgument, pot << " is not mono-dimensional.");
314  }
315  if (__bn == nullptr)
317  "No Bayes net has been assigned to the "
318  "inference algorithm");
319 
320  NodeId id = __bn->nodeId(pot.variable(0));
321 
322  if (hasEvidence(id)) {
324  " node " << id
325  << " already has an evidence. Please use chgEvidence().");
326  }
327 
328  // check whether we have a hard evidence (and also check whether the
329  // potential only contains 0 (in this case, this will automatically raise
330  // an exception) )
331  Idx val;
332  bool is_hard_evidence = __isHardEvidence(pot, val);
333 
334  // insert the evidence
335  __evidence.insert(
336  id,
337  new Potential< GUM_SCALAR >(std::forward< Potential< GUM_SCALAR > >(pot)));
338  if (is_hard_evidence) { // pot is deterministic
339  __hard_evidence.insert(id, val);
341  } else {
343  }
345  _onEvidenceAdded(id, is_hard_evidence);
346  }
347 
348 
349  // adds a new evidence on node id (might be soft or hard)
350  template < typename GUM_SCALAR >
352  const Potential< GUM_SCALAR >& pot) {
353  Potential< GUM_SCALAR > new_pot(pot);
354  addEvidence(std::move(new_pot));
355  }
356 
357 
359  template < typename GUM_SCALAR >
361  const List< const Potential< GUM_SCALAR >* >& potlist) {
362  for (const auto pot : potlist)
363  addEvidence(*pot);
364  }
365 
366 
368  template < typename GUM_SCALAR >
370  const Set< const Potential< GUM_SCALAR >* >& potset) {
371  for (const auto pot : potset)
372  addEvidence(*pot);
373  }
374 
375 
376  // indicates whether some node(s) have received evidence
377  template < typename GUM_SCALAR >
379  return !__evidence.empty();
380  }
381 
382 
383  // indicates whether node id has received an evidence
384  template < typename GUM_SCALAR >
386  return __evidence.exists(id);
387  }
388 
389 
390  // indicates whether node id has received a hard evidence
391  template < typename GUM_SCALAR >
393  return __hard_evidence_nodes.exists(id);
394  }
395 
396 
397  // indicates whether node id has received a soft evidence
398  template < typename GUM_SCALAR >
400  return __soft_evidence_nodes.exists(id);
401  }
402 
403 
404  // indicates whether node id has received an evidence
405  template < typename GUM_SCALAR >
407  const std::string& nodeName) const {
408  return hasEvidence(this->BN().idFromName(nodeName));
409  }
410 
411 
412  // indicates whether node id has received a hard evidence
413  template < typename GUM_SCALAR >
415  const std::string& nodeName) const {
416  return hasHardEvidence(this->BN().idFromName(nodeName));
417  }
418 
419 
420  // indicates whether node id has received a soft evidence
421  template < typename GUM_SCALAR >
423  const std::string& nodeName) const {
424  return hasSoftEvidence(this->BN().idFromName(nodeName));
425  }
426 
427  // change the value of an already existing hard evidence
428  template < typename GUM_SCALAR >
430  const Idx val) {
432  }
433 
434  // change the value of an already existing hard evidence
435  template < typename GUM_SCALAR >
436  INLINE void
437  BayesNetInference< GUM_SCALAR >::chgEvidence(const std::string& nodeName,
438  const Idx val) {
439  chgEvidence(this->BN().idFromName(nodeName), val);
440  }
441 
442  // change the value of an already existing hard evidence
443  template < typename GUM_SCALAR >
444  INLINE void
446  const std::string& label) {
447  chgEvidence(id, this->BN().variable(id)[label]);
448  }
449 
450  // change the value of an already existing hard evidence
451  template < typename GUM_SCALAR >
452  INLINE void
453  BayesNetInference< GUM_SCALAR >::chgEvidence(const std::string& nodeName,
454  const std::string& label) {
455  NodeId id = this->BN().idFromName(nodeName);
456  chgEvidence(id, this->BN().variable(id)[label]);
457  }
458 
459  // change the value of an already existing evidence (might be soft or hard)
460  template < typename GUM_SCALAR >
462  NodeId id, const std::vector< GUM_SCALAR >& vals) {
463  // check whether this corresponds to an evidence
464  if (__bn == nullptr)
466  "No Bayes net has been assigned to the "
467  "inference algorithm");
468 
469  if (!__bn->dag().exists(id)) {
470  GUM_ERROR(UndefinedElement, id << " is not a NodeId in the bn");
471  }
472 
473  if (__bn->variable(id).domainSize() != vals.size()) {
475  "node " << __bn->variable(id)
476  << " and its evidence have different sizes.");
477  }
478 
479  // create the potential corresponding to vals
481  pot.add(__bn->variable(id));
482  pot.fillWith(vals);
483  chgEvidence(pot);
484  }
485 
486  // change the value of an already existing evidence (might be soft or hard)
487  template < typename GUM_SCALAR >
489  const std::string& nodeName, const std::vector< GUM_SCALAR >& vals) {
490  chgEvidence(this->BN().idFromName(nodeName), vals);
491  }
492 
493 
494  // change the value of an already existing evidence (might be soft or hard)
495  template < typename GUM_SCALAR >
497  const Potential< GUM_SCALAR >& pot) {
498  // check if the potential corresponds to an evidence
499  if (pot.nbrDim() != 1) {
500  GUM_ERROR(InvalidArgument, pot << " is not a mono-dimensional potential.");
501  }
502  if (__bn == nullptr)
504  "No Bayes net has been assigned to the "
505  "inference algorithm");
506 
507  NodeId id = __bn->nodeId(pot.variable(0));
508 
509  if (!hasEvidence(id)) {
511  id << " has no evidence. Please use addEvidence().");
512  }
513 
514  // check whether we have a hard evidence (and also check whether the
515  // potential only contains 0 (in this case, this will automatically raise
516  // an exception) )
517  Idx val;
518  bool is_hard_evidence = __isHardEvidence(pot, val);
519 
520  // modify the evidence already stored
521  const Potential< GUM_SCALAR >* localPot = __evidence[id];
522  Instantiation I(pot);
523  for (I.setFirst(); !I.end(); I.inc()) {
524  localPot->set(I, pot[I]);
525  }
526 
527  // the inference state will be different
528  // whether evidence change from Hard to Soft or not.
529  bool hasChangedSoftHard = false;
530 
531  if (is_hard_evidence) {
532  if (!hasHardEvidence(id)) {
533  hasChangedSoftHard = true;
534  __hard_evidence.insert(id, val);
537  } else {
538  __hard_evidence[id] = val;
539  }
540  } else {
541  if (hasHardEvidence(id)) { // evidence was hard
542  __hard_evidence.erase(id);
545  hasChangedSoftHard = true;
546  }
547  }
548 
549  if (hasChangedSoftHard) {
551  } else {
554  }
555  }
556 
557  _onEvidenceChanged(id, hasChangedSoftHard);
558  }
559 
560 
561  // removed the evidence, if any, corresponding to node id
562  template < typename GUM_SCALAR >
564  if (hasEvidence(id)) {
565  if (hasHardEvidence(id)) {
566  _onEvidenceErased(id, true);
567  __hard_evidence.erase(id);
570  } else {
571  _onEvidenceErased(id, false);
575  }
576  }
577 
578  delete (__evidence[id]);
579  __evidence.erase(id);
580  }
581  }
582  // removed the evidence, if any, corresponding to node of name nodeName
583  template < typename GUM_SCALAR >
584  INLINE void
585  BayesNetInference< GUM_SCALAR >::eraseEvidence(const std::string& nodeName) {
586  eraseEvidence(this->BN().idFromName(nodeName));
587  }
588 
589 
590  // removes all the evidence entered into the network
591  template < typename GUM_SCALAR >
593  bool has_hard_evidence = !__hard_evidence.empty();
594  this->_onAllEvidenceErased(has_hard_evidence);
595 
596  for (const auto& pair : __evidence) {
597  if (pair.second != nullptr) { delete (pair.second); }
598  }
599 
600  __evidence.clear();
601  __hard_evidence.clear();
604 
605  if (has_hard_evidence) {
607  } else {
610  }
611  }
612  }
613 
614 
615  // returns the number of evidence entered into the Bayesian network
616  template < typename GUM_SCALAR >
618  return __evidence.size();
619  }
620 
621 
622  // returns the number of hard evidence entered into the Bayesian network
623  template < typename GUM_SCALAR >
625  return __hard_evidence_nodes.size();
626  }
627 
628 
629  // returns the number of soft evidence entered into the Bayesian network
630  template < typename GUM_SCALAR >
632  return __soft_evidence_nodes.size();
633  }
634 
635 
636  // indicate for each node with hard evidence which value it took
637  template < typename GUM_SCALAR >
638  INLINE const NodeProperty< Idx >&
640  return __hard_evidence;
641  }
642 
643 
644  // the set of evidence entered into the network
645  template < typename GUM_SCALAR >
648  return __evidence;
649  }
650 
651 
653  template < typename GUM_SCALAR >
654  INLINE const NodeSet&
656  return __soft_evidence_nodes;
657  }
658 
659 
661  template < typename GUM_SCALAR >
662  INLINE const NodeSet&
664  return __hard_evidence_nodes;
665  }
666 
667 
668  // ##############################################################################
669  // Inference
670  // ##############################################################################
671 
672  // put the inference into an unprepared state
673  template < typename GUM_SCALAR >
676  }
677 
678 
681  template < typename GUM_SCALAR >
684  }
685 
686 
687  // prepare the internal inference structures for the next inference
688  template < typename GUM_SCALAR >
690  if (isInferenceReady() || isDone()) { return; }
691 
692  if (__bn == nullptr)
694  "No Bayes net has been assigned to the "
695  "inference algorithm");
696 
699  else
701 
703  }
704 
705 
706  // perform the heavy computations needed to compute the targets' posteriors
707  template < typename GUM_SCALAR >
709  if (isDone()) { return; }
710 
711  if (!isInferenceReady()) { prepareInference(); }
712 
713  _makeInference();
714 
716  }
717 
718 
719 } /* namespace gum */
void __setBayesNetDuringConstruction(const IBayesNet< GUM_SCALAR > *bn)
assigns a BN during the inference engine construction
virtual bool hasSoftEvidence(NodeId id) const final
indicates whether node id has received a soft evidence
virtual Size nbrEvidence() const final
returns the number of evidence entered into the Bayesian network
virtual Size nbrSoftEvidence() const final
returns the number of soft evidence entered into the Bayesian network
aGrUM&#39;s Potential is a multi-dimensional array with tensor operators.
Definition: potential.h:57
NodeProperty< const Potential< GUM_SCALAR > * > __evidence
the set of evidence entered into the network
NodeProperty< Size > __domain_sizes
the domain sizes of the random variables
virtual void _onStateChanged()=0
fired when the stage is changed
virtual void beginMultipleChanges() final
Default implementation of MultiDimContainer::set().
virtual void __setState(const StateOfInference state) final
set the state of the inference engine and call the notification _onStateChanged when necessary (i...
NodeProperty< Idx > __hard_evidence
assign to each node with a hard evidence the index of its observed value
unsigned long Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:50
virtual Idx nbrDim() const final
Returns the number of vars in the multidimensional container.
virtual void addSetOfEvidence(const Set< const Potential< GUM_SCALAR > * > &potset) final
adds a new set of evidence
virtual void _onEvidenceAdded(NodeId id, bool isHardEvidence)=0
fired after a new evidence is inserted
virtual bool hasHardEvidence(NodeId id) const final
indicates whether node id has received a hard evidence
virtual void _onBayesNetChanged(const IBayesNet< GUM_SCALAR > *bn)=0
fired after a new Bayes net has been assigned to the engine
unsigned int NodeId
Type for node ids.
Definition: graphElements.h:97
const NodeProperty< const Potential< GUM_SCALAR > * > & evidence() const
returns the set of evidence
virtual void addListOfEvidence(const List< const Potential< GUM_SCALAR > * > &potlist) final
adds a new list of evidence
StateOfInference __state
the current state of the inference (outdated/ready/done)
virtual ~BayesNetInference()
destructor
BayesNetInference()
default constructor with a null BN (useful for virtual inheritance)
virtual void _onAllEvidenceErased(bool contains_hard_evidence)=0
fired before all the evidence are erased
virtual bool isInferenceReady() const noexceptfinal
returns whether the inference object is in a ready state
virtual void _makeInference()=0
called when the inference has to be performed effectively
Potential< GUM_SCALAR > __createHardEvidence(NodeId id, Idx val) const
create the internal structure for a hard evidence
virtual void prepareInference() final
prepare the internal inference structures for the next inference
bool exists(const Key &k) const
Indicates whether a given elements belong to the set.
Definition: set_tpl.h:607
const IBayesNet< GUM_SCALAR > * __bn
the Bayes net on which we perform inferences
Instantiation & chgVal(const DiscreteVariable &v, Idx newval)
Assign newval to variable v in the Instantiation.
virtual void _onEvidenceChanged(NodeId id, bool hasChangedSoftHard)=0
fired after an evidence is changed, in particular when its status (soft/hard) changes ...
void erase(const Key &k)
Erases an element from the set.
Definition: set_tpl.h:656
Generic doubly linked lists.
Definition: list.h:369
Class representing the minimal interface for Bayesian Network.
Definition: IBayesNet.h:59
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
bool __isHardEvidence(const Potential< GUM_SCALAR > &pot, Idx &val) const
checks whether a potential corresponds to a hard evidence or not
const NodeProperty< Idx > & hardEvidence() const
indicate for each node with hard evidence which value it took
The class for generic Hash Tables.
Definition: hashTable.h:676
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:162
virtual void makeInference() final
perform the heavy computations needed to compute the targets&#39; posteriors
virtual bool isInferenceDone() const noexceptfinal
returns whether the inference object is in a InferenceDone state
<agrum/BN/inference/BayesNetInference.h>
NodeSet __soft_evidence_nodes
the set of nodes that received soft evidence
virtual const NodeProperty< Size > & domainSizes() const final
get the domain sizes of the random variables of the BN
void inc()
Operator increment.
virtual void _updateOutdatedBNPotentials()=0
prepares inference when the latter is in OutdatedBNPotentials state
virtual void chgEvidence(NodeId id, const Idx val) final
change the value of an already existing hard evidence
virtual bool hasEvidence() const final
indicates whether some node(s) have received evidence
virtual void addEvidence(NodeId id, const Idx val) final
adds a new hard evidence on node id
This file contains abstract class definitions for Bayesian networks inference classes.
virtual void _updateOutdatedBNStructure()=0
prepares inference when the latter is in OutdatedBNStructure state
virtual void eraseAllEvidence() final
removes all the evidence entered into the network
virtual void _onEvidenceErased(NodeId id, bool isHardEvidence)=0
fired before an evidence is removed
virtual const DiscreteVariable & variable(Idx) const final
Returns a const ref to the ith var.
virtual void setBN(const IBayesNet< GUM_SCALAR > *bn)
assigns a new BN to the inference engine
void _setOutdatedBNStructureState()
put the inference into an outdated BN structure state
bool end() const
Returns true if the Instantiation reached the end.
const NodeSet & hardEvidenceNodes() const
returns the set of nodes with hard evidence
Class for assigning/browsing values to tuples of discrete variables.
Definition: instantiation.h:80
virtual void clear()
clears all the data structures allocated for the last inference
virtual void add(const DiscreteVariable &v) final
Adds a new var to the variables of the multidimensional matrix.
void __computeDomainSizes()
computes the domain sizes of the random variables
virtual void set(const Instantiation &i, const GUM_SCALAR &value) const final
Default implementation of MultiDimContainer::set().
const NodeSet & softEvidenceNodes() const
returns the set of nodes with soft evidence
void setFirst()
Assign the first values to the tuple of the Instantiation.
NodeSet __hard_evidence_nodes
the set of nodes that received hard evidence
virtual bool isInferenceOutdatedBNStructure() const noexceptfinal
returns whether the inference object is in a OutdatedBNStructure state
void clear()
Removes all the elements, if any, from the set.
Definition: set_tpl.h:375
Size size() const noexcept
Returns the number of elements in the set.
Definition: set_tpl.h:701
virtual Size nbrHardEvidence() const final
returns the number of hard evidence entered into the Bayesian network
unsigned long Idx
Type for indexes.
Definition: types.h:43
StateOfInference
current state of the inference
virtual const IBayesNet< GUM_SCALAR > & BN() const final
Returns a constant reference over the IBayesNet referenced by this class.
virtual bool isDone() const noexceptfinal
returns whether the inference object is in a done state
void insert(const Key &k)
Inserts a new element into the set.
Definition: set_tpl.h:613
Idx val(Idx i) const
Returns the current value of the variable at position i.
virtual bool isInferenceOutdatedBNPotentials() const noexceptfinal
returns whether the inference object is in a OutdatedBNPotential state
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66
virtual StateOfInference state() const noexceptfinal
returns the state of the inference engine
void _setOutdatedBNPotentialsState()
puts the inference into an OutdatedBNPotentials state if it is not already in an OutdatedBNStructure ...
virtual void eraseEvidence(NodeId id) final
removed the evidence, if any, corresponding to node id