aGrUM  0.16.0
BayesNet_tpl.h
Go to the documentation of this file.
1 
30 #include <limits>
31 #include <set>
32 
33 #include <agrum/BN/BayesNet.h>
34 #include <agrum/BN/IBayesNet.h>
35 #include <agrum/BN/IBayesNet.h>
36 
39 
49 
53 
55 
58 
59 namespace gum {
60  template < typename GUM_SCALAR >
62  std::string node,
63  gum::Size domainSize) {
64  std::string name = node;
65  auto ds = domainSize;
66  std::vector< std::string > labels;
67 
68  // node like "n[5]"
69  auto posBrack = node.find('[');
70  if (posBrack != std::string::npos) {
71  if (*(node.rbegin()) != ']')
72  name = node; // a name with '[' inside but no ']' at the end
73  else {
74  name = node.substr(0, posBrack);
75  ds = static_cast< Size >(
76  std::stoi(node.substr(posBrack + 1, node.size() - posBrack - 2)));
77  }
78  }
79 
80  // node like "n{one|two|three}"
81  posBrack = node.find('{');
82  if (posBrack != std::string::npos) {
83  if (*(node.rbegin()) != '}')
84  name = node; // a name with '{' inside but no '}' at the end
85  else {
86  name = node.substr(0, posBrack);
87  labels = split(node.substr(posBrack + 1, node.size() - posBrack - 2), "|");
88  if (labels.size() < 2) {
89  GUM_ERROR(InvalidArgument, "Not enough labels in node " << node);
90  }
91  if (!hasUniqueElts(labels)) {
92  GUM_ERROR(InvalidArgument, "Duplicate labels in node " << node);
93  }
94  ds = static_cast< Size >(labels.size());
95  }
96  }
97 
98  if (ds == 0) {
99  GUM_ERROR(InvalidArgument, "No value for variable " << name << ".");
100  } else if (ds == 1) {
102  "Only one value for variable " << name
103  << " (2 at least are needed).");
104  }
105 
106  // now we add the node in the BN
107  NodeId idVar;
108  try {
109  idVar = bn.idFromName(name);
110  } catch (gum::NotFound&) {
111  if (labels.empty()) {
112  idVar = bn.add(RangeVariable(name, name, 0, ds - 1));
113  } else {
114  auto l = LabelizedVariable(name, name, 0);
115  for (const auto& label : labels) {
116  l.addLabel(label);
117  }
118  idVar = bn.add(l);
119  }
120  }
121 
122  return idVar;
123  }
124 
125  template < typename GUM_SCALAR >
127  BayesNet< GUM_SCALAR >::fastPrototype(const std::string& dotlike,
128  Size domainSize) {
130 
131 
132  for (const auto& chaine : split(dotlike, ";")) {
133  NodeId lastId = 0;
134  bool notfirst = false;
135  for (const auto& souschaine : split(chaine, "->")) {
136  bool forward = true;
137  for (const auto& node : split(souschaine, "<-")) {
138  auto idVar = build_node(bn, node, domainSize);
139  if (notfirst) {
140  if (forward) {
141  bn.addArc(lastId, idVar);
142  forward = false;
143  } else {
144  bn.addArc(idVar, lastId);
145  }
146  } else {
147  notfirst = true;
148  forward = false;
149  }
150  lastId = idVar;
151  }
152  }
153  }
154  bn.generateCPTs();
155  bn.setProperty("name", dotlike);
156  return bn;
157  }
158 
159  template < typename GUM_SCALAR >
160  INLINE BayesNet< GUM_SCALAR >::BayesNet() : IBayesNet< GUM_SCALAR >() {
161  GUM_CONSTRUCTOR(BayesNet);
162  }
163 
164  template < typename GUM_SCALAR >
165  INLINE BayesNet< GUM_SCALAR >::BayesNet(std::string name) :
166  IBayesNet< GUM_SCALAR >(name) {
167  GUM_CONSTRUCTOR(BayesNet);
168  }
169 
170  template < typename GUM_SCALAR >
172  IBayesNet< GUM_SCALAR >(source), __varMap(source.__varMap) {
173  GUM_CONS_CPY(BayesNet);
174 
175  __copyPotentials(source);
176  }
177 
178  template < typename GUM_SCALAR >
181  if (this != &source) {
183  __varMap = source.__varMap;
184 
185  __clearPotentials();
186  __copyPotentials(source);
187  }
188 
189  return *this;
190  }
191 
192  template < typename GUM_SCALAR >
194  GUM_DESTRUCTOR(BayesNet);
195  for (const auto p : __probaMap) {
196  delete p.second;
197  }
198  }
199 
200  template < typename GUM_SCALAR >
201  INLINE const DiscreteVariable&
203  return __varMap.get(id);
204  }
205 
206  template < typename GUM_SCALAR >
207  INLINE void
209  const std::string& new_name) {
210  __varMap.changeName(id, new_name);
211  }
212 
213  template < typename GUM_SCALAR >
215  NodeId id, const std::string& old_label, const std::string& new_label) {
216  if (variable(id).varType() != VarType::Labelized) {
217  GUM_ERROR(NotFound, "Variable " << id << " is not a LabelizedVariable.");
218  }
219  LabelizedVariable* var = dynamic_cast< LabelizedVariable* >(
220  const_cast< DiscreteVariable* >(&variable(id)));
221 
222  var->changeLabel(var->posLabel(old_label), new_label);
223  }
224 
225 
226  template < typename GUM_SCALAR >
228  return __varMap.get(var);
229  }
230 
231  template < typename GUM_SCALAR >
233  auto ptr = new MultiDimArray< GUM_SCALAR >();
234  NodeId res = 0;
235 
236  try {
237  res = add(var, ptr);
238 
239  } catch (Exception&) {
240  delete ptr;
241  throw;
242  }
243 
244  return res;
245  }
246 
247  template < typename GUM_SCALAR >
248  INLINE NodeId BayesNet< GUM_SCALAR >::add(const std::string& name,
249  unsigned int nbrmod) {
250  if (nbrmod < 2) {
252  "Variable " << name << "needs more than " << nbrmod
253  << " modalities");
254  }
255 
256  LabelizedVariable v(name, name, nbrmod);
257  return add(v);
258  }
259 
260  template < typename GUM_SCALAR >
263  NodeId proposedId = dag().nextNodeId();
264  NodeId res = 0;
265 
266  res = add(var, aContent, proposedId);
267 
268  return res;
269  }
270 
271  template < typename GUM_SCALAR >
273  NodeId id) {
274  auto ptr = new MultiDimArray< GUM_SCALAR >();
275  NodeId res = 0;
276 
277  try {
278  res = add(var, ptr, id);
279 
280  } catch (Exception&) {
281  delete ptr;
282  throw;
283  }
284 
285  return res;
286  }
287 
288  template < typename GUM_SCALAR >
289  NodeId
292  NodeId id) {
293  __varMap.insert(id, var);
294  this->_dag.addNodeWithId(id);
295 
296  auto cpt = new Potential< GUM_SCALAR >(aContent);
297  (*cpt) << variable(id);
298  __probaMap.insert(id, cpt);
299  return id;
300  }
301 
302  template < typename GUM_SCALAR >
303  INLINE NodeId BayesNet< GUM_SCALAR >::idFromName(const std::string& name) const {
304  return __varMap.idFromName(name);
305  }
306 
307  template < typename GUM_SCALAR >
308  INLINE const DiscreteVariable&
309  BayesNet< GUM_SCALAR >::variableFromName(const std::string& name) const {
310  return __varMap.variableFromName(name);
311  }
312 
313  template < typename GUM_SCALAR >
314  INLINE const Potential< GUM_SCALAR >&
316  return *(__probaMap[varId]);
317  }
318 
319  template < typename GUM_SCALAR >
321  return __varMap;
322  }
323 
324  template < typename GUM_SCALAR >
326  erase(__varMap.get(var));
327  }
328 
329  template < typename GUM_SCALAR >
331  if (__varMap.exists(varId)) {
332  // Reduce the variable child's CPT
333  const NodeSet& children = this->children(varId);
334 
335  for (const auto c : children) {
336  __probaMap[c]->erase(variable(varId));
337  }
338 
339  delete __probaMap[varId];
340 
341  __probaMap.erase(varId);
342  __varMap.erase(varId);
343  this->_dag.eraseNode(varId);
344  }
345  }
346 
347  template < typename GUM_SCALAR >
348  INLINE void BayesNet< GUM_SCALAR >::addArc(NodeId tail, NodeId head) {
349  if (this->_dag.existsArc(tail, head)) {
351  "The arc (" << tail << "," << head << ") already exists.")
352  }
353 
354  this->_dag.addArc(tail, head);
355  // Add parent in the child's CPT
356  (*(__probaMap[head])) << variable(tail);
357  }
358 
359  template < typename GUM_SCALAR >
360  INLINE void BayesNet< GUM_SCALAR >::addArc(const std::string& tail,
361  const std::string& head) {
362  try {
363  addArc(this->idFromName(tail), this->idFromName(head));
364  } catch (DuplicateElement) {
366  "The arc " << tail << "->" << head << " already exists.")
367  }
368  }
369 
370  template < typename GUM_SCALAR >
371  INLINE void BayesNet< GUM_SCALAR >::eraseArc(const Arc& arc) {
372  if (__varMap.exists(arc.tail()) && __varMap.exists(arc.head())) {
373  NodeId head = arc.head(), tail = arc.tail();
374  this->_dag.eraseArc(arc);
375  // Remove parent froms child's CPT
376  (*(__probaMap[head])) >> variable(tail);
377  }
378  }
379 
380  template < typename GUM_SCALAR >
382  eraseArc(Arc(tail, head));
383  }
384 
385  template < typename GUM_SCALAR >
387  // check that the arc exsists
388  if (!__varMap.exists(arc.tail()) || !__varMap.exists(arc.head())
389  || !dag().existsArc(arc)) {
390  GUM_ERROR(InvalidArc, "a nonexisting arc cannot be reversed");
391  }
392 
393  NodeId tail = arc.tail(), head = arc.head();
394 
395  // check that the reversal does not induce a cycle
396  try {
397  DAG d = dag();
398  d.eraseArc(arc);
399  d.addArc(head, tail);
400  } catch (Exception&) {
401  GUM_ERROR(InvalidArc, "this arc reversal would induce a directed cycle");
402  }
403 
404  // with the same notations as Shachter (1986), "evaluating influence
405  // diagrams",
406  // p.878, we shall first compute the product of probabilities:
407  // pi_j^old (x_j | x_c^old(j) ) * pi_i^old (x_i | x_c^old(i) )
408  Potential< GUM_SCALAR > prod{cpt(tail) * cpt(head)};
409 
410  // modify the topology of the graph: add to tail all the parents of head
411  // and add to head all the parents of tail
412  beginTopologyTransformation();
413  NodeSet new_parents;
414  for (const auto node : this->parents(tail))
415  new_parents.insert(node);
416  for (const auto node : this->parents(head))
417  new_parents.insert(node);
418  // remove arc (head, tail)
419  eraseArc(arc);
420 
421  // add the necessary arcs to the tail
422  for (const auto p : new_parents) {
423  if ((p != tail) && !dag().existsArc(p, tail)) { addArc(p, tail); }
424  }
425 
426  addArc(head, tail);
427  // add the necessary arcs to the head
428  new_parents.erase(tail);
429 
430  for (const auto p : new_parents) {
431  if ((p != head) && !dag().existsArc(p, head)) { addArc(p, head); }
432  }
433 
434  endTopologyTransformation();
435 
436  // update the conditional distributions of head and tail
438  del_vars << &(variable(tail));
439  Potential< GUM_SCALAR > new_cpt_head =
440  prod.margSumOut(del_vars).putFirst(&variable(head));
441 
442  auto& cpt_head = const_cast< Potential< GUM_SCALAR >& >(cpt(head));
443  cpt_head = std::move(new_cpt_head);
444 
445  Potential< GUM_SCALAR > new_cpt_tail{
446  (prod / cpt_head).putFirst(&variable(tail))};
447  auto& cpt_tail = const_cast< Potential< GUM_SCALAR >& >(cpt(tail));
448  cpt_tail = std::move(new_cpt_tail);
449  }
450 
451  template < typename GUM_SCALAR >
453  reverseArc(Arc(tail, head));
454  }
455 
456 
457  //==============================================
458  // Aggregators
459  //=============================================
460  template < typename GUM_SCALAR >
462  return add(var, new aggregator::Amplitude< GUM_SCALAR >());
463  }
464 
465  template < typename GUM_SCALAR >
467  if (var.domainSize() > 2) GUM_ERROR(SizeError, "an AND has to be boolean");
468 
469  return add(var, new aggregator::And< GUM_SCALAR >());
470  }
471 
472  template < typename GUM_SCALAR >
474  Idx value) {
475  return add(var, new aggregator::Count< GUM_SCALAR >(value));
476  }
477 
478  template < typename GUM_SCALAR >
480  Idx value) {
481  if (var.domainSize() > 2) GUM_ERROR(SizeError, "an EXISTS has to be boolean");
482 
483  return add(var, new aggregator::Exists< GUM_SCALAR >(value));
484  }
485 
486  template < typename GUM_SCALAR >
488  Idx value) {
489  if (var.domainSize() > 2) GUM_ERROR(SizeError, "an EXISTS has to be boolean");
490 
491  return add(var, new aggregator::Forall< GUM_SCALAR >(value));
492  }
493 
494  template < typename GUM_SCALAR >
496  return add(var, new aggregator::Max< GUM_SCALAR >());
497  }
498 
499  template < typename GUM_SCALAR >
501  return add(var, new aggregator::Median< GUM_SCALAR >());
502  }
503 
504  template < typename GUM_SCALAR >
506  return add(var, new aggregator::Min< GUM_SCALAR >());
507  }
508 
509  template < typename GUM_SCALAR >
511  if (var.domainSize() > 2) GUM_ERROR(SizeError, "an OR has to be boolean");
512 
513  return add(var, new aggregator::Or< GUM_SCALAR >());
514  }
515 
516 
517  //================================
518  // ICIModels
519  //================================
520  template < typename GUM_SCALAR >
522  GUM_SCALAR external_weight) {
523  return addNoisyORCompound(var, external_weight);
524  }
525 
526  template < typename GUM_SCALAR >
528  const DiscreteVariable& var, GUM_SCALAR external_weight) {
529  return add(var, new MultiDimNoisyORCompound< GUM_SCALAR >(external_weight));
530  }
531 
532  template < typename GUM_SCALAR >
534  GUM_SCALAR external_weight) {
535  return add(var, new MultiDimNoisyORNet< GUM_SCALAR >(external_weight));
536  }
537 
538  template < typename GUM_SCALAR >
540  GUM_SCALAR external_weight) {
541  return add(var, new MultiDimNoisyAND< GUM_SCALAR >(external_weight));
542  }
543 
544  template < typename GUM_SCALAR >
546  GUM_SCALAR external_weight) {
547  return add(var, new MultiDimLogit< GUM_SCALAR >(external_weight));
548  }
549 
550  template < typename GUM_SCALAR >
552  GUM_SCALAR external_weight,
553  NodeId id) {
554  return addNoisyORCompound(var, external_weight, id);
555  }
556 
557  template < typename GUM_SCALAR >
559  GUM_SCALAR external_weight,
560  NodeId id) {
561  return add(var, new MultiDimNoisyAND< GUM_SCALAR >(external_weight), id);
562  }
563 
564  template < typename GUM_SCALAR >
566  GUM_SCALAR external_weight,
567  NodeId id) {
568  return add(var, new MultiDimLogit< GUM_SCALAR >(external_weight), id);
569  }
570 
571  template < typename GUM_SCALAR >
573  const DiscreteVariable& var, GUM_SCALAR external_weight, NodeId id) {
574  return add(
575  var, new MultiDimNoisyORCompound< GUM_SCALAR >(external_weight), id);
576  }
577 
578  template < typename GUM_SCALAR >
580  GUM_SCALAR external_weight,
581  NodeId id) {
582  return add(var, new MultiDimNoisyORNet< GUM_SCALAR >(external_weight), id);
583  }
584 
585  template < typename GUM_SCALAR >
587  NodeId head,
588  GUM_SCALAR causalWeight) {
589  auto* CImodel =
590  dynamic_cast< const MultiDimICIModel< GUM_SCALAR >* >(cpt(head).content());
591 
592  if (CImodel != 0) {
593  // or is OK
594  addArc(tail, head);
595 
596  CImodel->causalWeight(variable(tail), causalWeight);
597  } else {
599  "Head variable (" << variable(head).name()
600  << ") is not a CIModel variable !");
601  }
602  }
603 
604  template < typename GUM_SCALAR >
605  INLINE std::ostream& operator<<(std::ostream& output,
606  const BayesNet< GUM_SCALAR >& bn) {
607  output << bn.toString();
608  return output;
609  }
610 
612  template < typename GUM_SCALAR >
614  for (const auto node : nodes())
615  __probaMap[node]->beginMultipleChanges();
616  }
617 
619  template < typename GUM_SCALAR >
621  for (const auto node : nodes())
622  __probaMap[node]->endMultipleChanges();
623  }
624 
626  template < typename GUM_SCALAR >
628  // Removing previous potentials
629  for (const auto& elt : __probaMap) {
630  delete elt.second;
631  }
632 
633  __probaMap.clear();
634  }
635 
637  template < typename GUM_SCALAR >
639  const BayesNet< GUM_SCALAR >& source) {
640  // Copying potentials
641 
642  for (const auto src : source.__probaMap) {
643  // First we build the node's CPT
645  copy_array->beginMultipleChanges();
646  for (gum::Idx i = 0; i < src.second->nbrDim(); i++) {
647  (*copy_array) << variableFromName(src.second->variable(i).name());
648  }
649  copy_array->endMultipleChanges();
650  copy_array->copyFrom(*(src.second));
651 
652  // We add the CPT to the CPT's hashmap
653  __probaMap.insert(src.first, copy_array);
654  }
655  }
656 
657  template < typename GUM_SCALAR >
659  for (const auto node : nodes())
660  generateCPT(node);
661  }
662 
663  template < typename GUM_SCALAR >
664  INLINE void BayesNet< GUM_SCALAR >::generateCPT(NodeId node) const {
666 
667  generator.generateCPT(cpt(node).pos(variable(node)), cpt(node));
668  }
669 
670  template < typename GUM_SCALAR >
672  Potential< GUM_SCALAR >* newPot) {
673  if (cpt(id).nbrDim() != newPot->nbrDim()) {
675  "cannot exchange potentials with different "
676  "dimensions for variable with id "
677  << id);
678  }
679 
680  for (Idx i = 0; i < cpt(id).nbrDim(); i++) {
681  if (&cpt(id).variable(i) != &(newPot->variable(i))) {
683  "cannot exchange potentials because, for variable with id "
684  << id << ", dimension " << i << " differs. ");
685  }
686  }
687 
688  _unsafeChangePotential(id, newPot);
689  }
690 
691  template < typename GUM_SCALAR >
693  NodeId id, Potential< GUM_SCALAR >* newPot) {
694  delete __probaMap[id];
695  __probaMap[id] = newPot;
696  }
697 
698  template < typename GUM_SCALAR >
699  void BayesNet< GUM_SCALAR >::changePotential(const std::string& name,
700  Potential< GUM_SCALAR >* newPot) {
701  changePotential(idFromName(name), newPot);
702  }
703 
704 } /* namespace gum */
void addArc(NodeId tail, NodeId head)
Add an arc in the BN, and update arc.head&#39;s CPT.
Definition: BayesNet_tpl.h:348
Noisy OR representation.
aGrUM&#39;s Potential is a multi-dimensional array with tensor operators.
Definition: potential.h:60
Class representing a Bayesian Network.
Definition: BayesNet.h:78
virtual void beginMultipleChanges() final
Default implementation of MultiDimContainer::set().
virtual Idx nbrDim() const final
Returns the number of vars in the multidimensional container.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void changeLabel(Idx pos, const std::string &aLabel) const
change a label for this index
bool hasUniqueElts(std::vector< T > const &x)
NodeId build_node(gum::BayesNet< GUM_SCALAR > &bn, std::string node, gum::Size domainSize)
Definition: BayesNet_tpl.h:61
class LabelizedVariable
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
or aggregator
Definition: or.h:56
NodeId add(const DiscreteVariable &var)
Add a variable to the gum::BayesNet.
Definition: BayesNet_tpl.h:232
virtual void eraseArc(const Arc &arc)
removes an arc from the ArcGraphPart
VariableNodeMap __varMap
the map between variable and id
Definition: BayesNet.h:651
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Container used to map discrete variables with nodes.
BayesNet()
Default constructor.
Definition: BayesNet_tpl.h:160
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Base class for discrete random variable.
Class representing the minimal interface for Bayesian Network.
Definition: IBayesNet.h:62
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
std::vector< std::string > split(const std::string &str, const std::string &delim)
Split str using the delimiter.
NodeId head() const
returns the head of the arc
static BayesNet< GUM_SCALAR > fastPrototype(const std::string &dotlike, Size domainSize=2)
Create a bn with a dotlike syntax : &#39;a->b->c;b->d;&#39;.
Definition: BayesNet_tpl.h:127
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
forall aggregator
Definition: forall.h:55
const DiscreteVariable & variableFromName(const std::string &name) const final
Returns a variable given its name in the gum::BayesNet.
Definition: BayesNet_tpl.h:309
virtual Size domainSize() const =0
And aggregator.
Definition: and.h:55
Logit representation.
Definition: multiDimLogit.h:53
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
exists aggregator
Definition: exists.h:54
virtual void endMultipleChanges() final
Default implementation of MultiDimContainer::set().
void setProperty(const std::string &name, const std::string &value)
Add or change a property of this DAGModel.
Definition: DAGmodel_inl.h:56
abstract class for Conditional Indepency Models
The base class for all directed edgesThis class is used as a basis for manipulating all directed edge...
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual const DiscreteVariable & variable(Idx) const final
Returns a const ref to the ith var.
Base class for all aGrUM&#39;s exceptions.
Definition: exceptions.h:106
Idx posLabel(const std::string &label) const
return the pos from label
Multidimensional matrix stored as an array in memory.
Definition: multiDimArray.h:54
virtual void addArc(const NodeId tail, const NodeId head)
insert a new arc into the directed graph
Definition: DAG_inl.h:43
<agrum/BN/generator/simpleCPTGenerator.h>
NodeProperty< Potential< GUM_SCALAR > *> __probaMap
Mapping between the variable&#39;s id and their CPT.
Definition: BayesNet.h:654
Noisy AND representation.
void generateCPTs() const
randomly generates CPTs for a given structure
Definition: BayesNet_tpl.h:658
Defines a discrete random variable over an integer interval.
Definition: rangeVariable.h:54
virtual void copyFrom(const MultiDimContainer< GUM_SCALAR > &src) const
Basic copy of a MultiDimContainer.
INLINE std::ostream & operator<<(std::ostream &output, const BayesNet< GUM_SCALAR > &bn)
Prints map&#39;s DAG in output using the Graphviz-dot format.
Definition: BayesNet_tpl.h:605
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Potential< GUM_SCALAR > margSumOut(const Set< const DiscreteVariable * > &del_vars) const
Projection using sum as operation (and implementation-optimized operations)
std::string toString() const
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
<agrum/multidim/multiDimImplementation.h>
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Size Idx
Type for indexes.
Definition: types.h:53
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
max aggregator
Definition: max.h:54
median aggregator
Definition: median.h:60
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
NodeId idFromName(const std::string &name) const final
Returns a variable&#39;s id given its name in the gum::BayesNet.
Definition: BayesNet_tpl.h:303
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Base class for dag.
Definition: DAG.h:102
amplitude aggregator
Definition: amplitude.h:55
Size NodeId
Type for node ids.
Definition: graphElements.h:98
void insert(const Key &k)
Inserts a new element into the set.
Definition: set_tpl.h:613
void generateCPT(const Idx &varId, const Potential< GUM_SCALAR > &cpt) override
Generates a CPT using floats.
min aggregator
Definition: min.h:53
NodeId tail() const
returns the tail of the arc
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
count aggregator
Definition: count.h:57