aGrUM  0.15.1
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  this->_dag.addArc(tail, head);
350  // Add parent in the child's CPT
351  (*(__probaMap[head])) << variable(tail);
352  }
353 
354  template < typename GUM_SCALAR >
355  INLINE void BayesNet< GUM_SCALAR >::eraseArc(const Arc& arc) {
356  if (__varMap.exists(arc.tail()) && __varMap.exists(arc.head())) {
357  NodeId head = arc.head(), tail = arc.tail();
358  this->_dag.eraseArc(arc);
359  // Remove parent froms child's CPT
360  (*(__probaMap[head])) >> variable(tail);
361  }
362  }
363 
364  template < typename GUM_SCALAR >
366  eraseArc(Arc(tail, head));
367  }
368 
369  template < typename GUM_SCALAR >
371  // check that the arc exsists
372  if (!__varMap.exists(arc.tail()) || !__varMap.exists(arc.head())
373  || !dag().existsArc(arc)) {
374  GUM_ERROR(InvalidArc, "a nonexisting arc cannot be reversed");
375  }
376 
377  NodeId tail = arc.tail(), head = arc.head();
378 
379  // check that the reversal does not induce a cycle
380  try {
381  DAG d = dag();
382  d.eraseArc(arc);
383  d.addArc(head, tail);
384  } catch (Exception&) {
385  GUM_ERROR(InvalidArc, "this arc reversal would induce a directed cycle");
386  }
387 
388  // with the same notations as Shachter (1986), "evaluating influence
389  // diagrams",
390  // p.878, we shall first compute the product of probabilities:
391  // pi_j^old (x_j | x_c^old(j) ) * pi_i^old (x_i | x_c^old(i) )
392  Potential< GUM_SCALAR > prod{cpt(tail) * cpt(head)};
393 
394  // modify the topology of the graph: add to tail all the parents of head
395  // and add to head all the parents of tail
396  beginTopologyTransformation();
397  NodeSet new_parents;
398  for (const auto node : this->parents(tail))
399  new_parents.insert(node);
400  for (const auto node : this->parents(head))
401  new_parents.insert(node);
402  // remove arc (head, tail)
403  eraseArc(arc);
404 
405  // add the necessary arcs to the tail
406  for (const auto p : new_parents) {
407  if ((p != tail) && !dag().existsArc(p, tail)) { addArc(p, tail); }
408  }
409 
410  addArc(head, tail);
411  // add the necessary arcs to the head
412  new_parents.erase(tail);
413 
414  for (const auto p : new_parents) {
415  if ((p != head) && !dag().existsArc(p, head)) { addArc(p, head); }
416  }
417 
418  endTopologyTransformation();
419 
420  // update the conditional distributions of head and tail
422  del_vars << &(variable(tail));
423  Potential< GUM_SCALAR > new_cpt_head = prod.margSumOut(del_vars);
424  auto& cpt_head = const_cast< Potential< GUM_SCALAR >& >(cpt(head));
425  cpt_head = std::move(new_cpt_head);
426 
427  Potential< GUM_SCALAR > new_cpt_tail{prod / cpt_head};
428  auto& cpt_tail = const_cast< Potential< GUM_SCALAR >& >(cpt(tail));
429  cpt_tail = std::move(new_cpt_tail);
430  }
431 
432  template < typename GUM_SCALAR >
434  reverseArc(Arc(tail, head));
435  }
436 
437 
438  //==============================================
439  // Aggregators
440  //=============================================
441  template < typename GUM_SCALAR >
443  return add(var, new aggregator::Amplitude< GUM_SCALAR >());
444  }
445 
446  template < typename GUM_SCALAR >
448  if (var.domainSize() > 2) GUM_ERROR(SizeError, "an AND has to be boolean");
449 
450  return add(var, new aggregator::And< GUM_SCALAR >());
451  }
452 
453  template < typename GUM_SCALAR >
455  Idx value) {
456  return add(var, new aggregator::Count< GUM_SCALAR >(value));
457  }
458 
459  template < typename GUM_SCALAR >
461  Idx value) {
462  if (var.domainSize() > 2) GUM_ERROR(SizeError, "an EXISTS has to be boolean");
463 
464  return add(var, new aggregator::Exists< GUM_SCALAR >(value));
465  }
466 
467  template < typename GUM_SCALAR >
469  Idx value) {
470  if (var.domainSize() > 2) GUM_ERROR(SizeError, "an EXISTS has to be boolean");
471 
472  return add(var, new aggregator::Forall< GUM_SCALAR >(value));
473  }
474 
475  template < typename GUM_SCALAR >
477  return add(var, new aggregator::Max< GUM_SCALAR >());
478  }
479 
480  template < typename GUM_SCALAR >
482  return add(var, new aggregator::Median< GUM_SCALAR >());
483  }
484 
485  template < typename GUM_SCALAR >
487  return add(var, new aggregator::Min< GUM_SCALAR >());
488  }
489 
490  template < typename GUM_SCALAR >
492  if (var.domainSize() > 2) GUM_ERROR(SizeError, "an OR has to be boolean");
493 
494  return add(var, new aggregator::Or< GUM_SCALAR >());
495  }
496 
497 
498  //================================
499  // ICIModels
500  //================================
501  template < typename GUM_SCALAR >
503  GUM_SCALAR external_weight) {
504  return addNoisyORCompound(var, external_weight);
505  }
506 
507  template < typename GUM_SCALAR >
509  const DiscreteVariable& var, GUM_SCALAR external_weight) {
510  return add(var, new MultiDimNoisyORCompound< GUM_SCALAR >(external_weight));
511  }
512 
513  template < typename GUM_SCALAR >
515  GUM_SCALAR external_weight) {
516  return add(var, new MultiDimNoisyORNet< GUM_SCALAR >(external_weight));
517  }
518 
519  template < typename GUM_SCALAR >
521  GUM_SCALAR external_weight) {
522  return add(var, new MultiDimNoisyAND< GUM_SCALAR >(external_weight));
523  }
524 
525  template < typename GUM_SCALAR >
527  GUM_SCALAR external_weight) {
528  return add(var, new MultiDimLogit< GUM_SCALAR >(external_weight));
529  }
530 
531  template < typename GUM_SCALAR >
533  GUM_SCALAR external_weight,
534  NodeId id) {
535  return addNoisyORCompound(var, external_weight, id);
536  }
537 
538  template < typename GUM_SCALAR >
540  GUM_SCALAR external_weight,
541  NodeId id) {
542  return add(var, new MultiDimNoisyAND< GUM_SCALAR >(external_weight), id);
543  }
544 
545  template < typename GUM_SCALAR >
547  GUM_SCALAR external_weight,
548  NodeId id) {
549  return add(var, new MultiDimLogit< GUM_SCALAR >(external_weight), id);
550  }
551 
552  template < typename GUM_SCALAR >
554  const DiscreteVariable& var, GUM_SCALAR external_weight, NodeId id) {
555  return add(
556  var, new MultiDimNoisyORCompound< GUM_SCALAR >(external_weight), id);
557  }
558 
559  template < typename GUM_SCALAR >
561  GUM_SCALAR external_weight,
562  NodeId id) {
563  return add(var, new MultiDimNoisyORNet< GUM_SCALAR >(external_weight), id);
564  }
565 
566  template < typename GUM_SCALAR >
568  NodeId head,
569  GUM_SCALAR causalWeight) {
570  auto* CImodel =
571  dynamic_cast< const MultiDimICIModel< GUM_SCALAR >* >(cpt(head).content());
572 
573  if (CImodel != 0) {
574  // or is OK
575  addArc(tail, head);
576 
577  CImodel->causalWeight(variable(tail), causalWeight);
578  } else {
580  "Head variable (" << variable(head).name()
581  << ") is not a CIModel variable !");
582  }
583  }
584 
585  template < typename GUM_SCALAR >
586  INLINE std::ostream& operator<<(std::ostream& output,
587  const BayesNet< GUM_SCALAR >& bn) {
588  output << bn.toString();
589  return output;
590  }
591 
593  template < typename GUM_SCALAR >
595  for (const auto node : nodes())
596  __probaMap[node]->beginMultipleChanges();
597  }
598 
600  template < typename GUM_SCALAR >
602  for (const auto node : nodes())
603  __probaMap[node]->endMultipleChanges();
604  }
605 
607  template < typename GUM_SCALAR >
609  // Removing previous potentials
610  for (const auto& elt : __probaMap) {
611  delete elt.second;
612  }
613 
614  __probaMap.clear();
615  }
616 
618  template < typename GUM_SCALAR >
620  const BayesNet< GUM_SCALAR >& source) {
621  // Copying potentials
622 
623  for (const auto src : source.__probaMap) {
624  // First we build the node's CPT
626  copy_array->beginMultipleChanges();
627  for (gum::Idx i = 0; i < src.second->nbrDim(); i++) {
628  (*copy_array) << variableFromName(src.second->variable(i).name());
629  }
630  copy_array->endMultipleChanges();
631  copy_array->copyFrom(*(src.second));
632 
633  // We add the CPT to the CPT's hashmap
634  __probaMap.insert(src.first, copy_array);
635  }
636  }
637 
638  template < typename GUM_SCALAR >
640  for (const auto node : nodes())
641  generateCPT(node);
642  }
643  template < typename GUM_SCALAR >
644  INLINE void BayesNet< GUM_SCALAR >::generateCPT(NodeId node) const {
646 
647  generator.generateCPT(cpt(node).pos(variable(node)), cpt(node));
648  }
649 
650  template < typename GUM_SCALAR >
652  Potential< GUM_SCALAR >* newPot) {
653  if (cpt(id).nbrDim() != newPot->nbrDim()) {
655  "cannot exchange potentials with different "
656  "dimensions for variable with id "
657  << id);
658  }
659 
660  for (Idx i = 0; i < cpt(id).nbrDim(); i++) {
661  if (&cpt(id).variable(i) != &(newPot->variable(i))) {
663  "cannot exchange potentials because, for variable with id "
664  << id << ", dimension " << i << " differs. ");
665  }
666  }
667 
668  _unsafeChangePotential(id, newPot);
669  }
670 
671  template < typename GUM_SCALAR >
673  NodeId id, Potential< GUM_SCALAR >* newPot) {
674  delete __probaMap[id];
675  __probaMap[id] = newPot;
676  }
677 
678  template < typename GUM_SCALAR >
679  void BayesNet< GUM_SCALAR >::changePotential(const std::string& name,
680  Potential< GUM_SCALAR >* newPot) {
681  changePotential(idFromName(name), newPot);
682  }
683 
684 } /* 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:650
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:653
Noisy AND representation.
void generateCPTs() const
randomly generates CPTs for a given structure
Definition: BayesNet_tpl.h:639
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:586
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