aGrUM  0.21.0
a C++ library for (probabilistic) graphical models
credalNet.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 #ifndef __CREDAL_NET__H__
23 #define __CREDAL_NET__H__
24 
25 /**
26  * @file
27  * @brief Class representing Credal Networks
28  * @author Matthieu HOURBRACQ and Pierre-Henri WUILLEMIN(@LIP6)
29  */
30 
31 #include <agrum/agrum.h>
32 
33 #include <iostream>
34 #include <vector>
35 
36 #ifdef HAVE_UNISTD_H
37 # include <unistd.h>
38 #else
39 # include <agrum/tools/core/mvsc/unistd.h>
40 #endif
41 
42 //#include <sys/wait.h>
43 #include <algorithm>
44 #include <cstdlib>
45 #include <fcntl.h>
46 #include <fstream>
47 #include <set>
48 #include <sstream>
49 #include <string>
50 #include <sys/stat.h>
51 
52 #include <utility> /// c++11 stuff, like declval ( decltype from prototype without a default constructor )
53 
54 #include <agrum/tools/core/math/math_utils.h>
55 #include <agrum/BN/BayesNet.h>
56 #include <agrum/BN/io/BIF/BIFReader.h>
57 #include <agrum/BN/io/BIF/BIFWriter.h>
58 #include <agrum/tools/core/exceptions.h>
59 
60 #include <agrum/tools/core/math/pow.h> // custom pow functions with integers, faster implementation
61 #include <agrum/tools/core/math/rational.h> // custom decimal to rational
62 
63 #include <agrum/CN/polytope/LrsWrapper.h>
64 
65 #include <agrum/tools/core/OMPThreads.h>
66 
67 // 64 bits for windows (long is 32 bits)
68 #ifdef _MSC_VER
69 typedef __int64 int64_t;
70 typedef unsigned __int64 uint64_t;
71 #else
72 # include <stdint.h>
73 #endif
74 
75 namespace gum {
76  namespace credal {
77 
78  /**
79  * @class CredalNet
80  * @headerfile credalNet.h <agrum/CN/credalNet.h>
81  * @brief Class template representing a Credal Network.
82  * @ingroup cn_group
83  * @tparam GUM_SCALAR A floating type ( float, GUM_SCALAR, long GUM_SCALAR
84  * ... ).
85  * @author Matthieu HOURBRACQ and Pierre-Henri WUILLEMIN(@LIP6)
86  */
87  template < typename GUM_SCALAR >
88  class CredalNet {
89  public:
90  /** @brief NodeType to speed-up computations in some algorithms */
91  enum class NodeType : char
92  {
93  Precise,
94  Credal,
95  Vacuous,
96  Indic
97  };
98 
99  /// @name Constructors / Destructors
100  /// @{
101 
102  /**
103  * Constructor used to create a CredalNet step by step, i.e. node by node,
104  * arc
105  * by arc, manually filling potentials.
106  */
107  CredalNet();
108 
109  /**
110  * Constructor for interval defined credal network which takes 2 BayesNet
111  * file path. One can also provide a single BayesNet to perturb it's
112  * probability distributions into credal sets according to another BayesNet
113  * containing the amount cases, for each node, of each parent
114  * instantiation met during learning, i.e. \f$ p(X = 0 \mid pa(X) = j) =
115  * N_{pa(X) = j} \f$.
116  *
117  * @param src_min_num The path to a BayesNet which contains lower
118  *probabilities.
119  * @param src_max_den The ( optional ) path to a BayesNet which contains
120  *upper probabilities.
121  */
122  CredalNet(const std::string& src_min_num, const std::string& src_max_den = "");
123 
124  /**
125  * Constructor for interval defined credal network which takes 2 BayesNet.
126  * One can also provide a single BayesNet in order to perturb it's
127  * probability distributions into credal sets according to another BayesNet
128  * containing the number of cases, for each node, of each parent
129  * instantiation met during learning, i.e. \f$ p(X = 0 \mid pa(X) = j) =
130  * N_{pa(X) = j} \f$.
131  *
132  * @param src_min_num The BayesNet which contains lower probabilities.
133  * @param src_max_den The ( optional ) BayesNet which contains upper
134  *probabilities.
135  */
136  CredalNet(const BayesNet< GUM_SCALAR >& src_min_num,
137  const BayesNet< GUM_SCALAR >& src_max_den = BayesNet< GUM_SCALAR >());
138 
139  /**
140  * Destructor.
141  */
142  ~CredalNet();
143 
144  /// @}
145 
146  /// @name Credal network creation
147  /// @{
148 
149  /**
150  * @brief Adds a discrete node into the network
151  * @param name The name of the discrete variable to be added
152  * @param card The cardinality of the variable
153  * @return The \c NodeId of the variable in the network
154  */
155  NodeId addVariable(const std::string& name, const Size& card);
156 
157  /**
158  * @brief Adds an arc between two nodes.
159  * @param tail The \c NodeId of the tail node
160  * @param head The \c NodeId of the head node
161  */
162  void addArc(const NodeId& tail, const NodeId& head);
163 
164  /**
165  * @brief %Set the vertices of the credal sets ( all of the conditionals )
166  *of a
167  *given node
168  * @param id The \c NodeId of the node
169  * @param cpt The vertices of every credal set ( for each instantiation of
170  *the
171  *parents )
172  *
173  * @warning : Does not change the \c BayesNet (s) associated to this
174  *credal net !
175  *
176  * First dimension is instantiation position ( from 0 to K - 1 ).
177  * Second is the credal set vertice index
178  * Third is the vertex
179  */
180  void setCPTs(const NodeId& id,
181  const std::vector< std::vector< std::vector< GUM_SCALAR > > >& cpt);
182 
183  /**
184  * @brief %Set the vertices of one credal set of a given node ( any
185  *instantiation index )
186  * @param id The \c NodeId of the node
187  * @param entry The index of the instantiation ( from 0 to K - 1 )
188  *excluding
189  *the given node ( only the parents are used to compute the index of the
190  *credal
191  *set )
192  * @param cpt The vertices of every credal set ( for each instantiation of
193  *the
194  *parents )
195  *
196  * Use this with either \c LRSWrapper or \c LpInterface to get the
197  *vertices of
198  *a credal set represented by linear constraints.
199  * @warning : Does not change the \c BayesNet (s) associated to this
200  *credal net
201  *!
202  */
203  void
204  setCPT(const NodeId& id, Size& entry, const std::vector< std::vector< GUM_SCALAR > >& cpt);
205 
206  /**
207  * @brief %Set the vertices of one credal set of a given node ( any
208  *instantiation )
209  * @param id The \c NodeId of the node
210  * @param ins The \c Instantiation ( only the parents matter to find the
211  *credal
212  *set index )
213  * @param cpt The vertices of every credal set ( for each instantiation of
214  *the
215  *parents )
216  *
217  * Use this with either \c LRSWrapper or \c LpInterface to get the
218  *vertices of a credal set represented by linear constraints.
219  * @warning : Does not change the \c BayesNet (s) associated to this
220  *credal net
221  *!
222  *
223  * @note we forget the master ref of \c ins to check variable order in the
224  *instantiation ( to get index ), therefor we pass it by value
225  */
226  void setCPT(const NodeId& id,
227  Instantiation ins,
228  const std::vector< std::vector< GUM_SCALAR > >& cpt);
229 
230  /**
231  * @brief %Set the interval constraints of the credal sets of a given node
232  *(all instantiations )
233  * @param id The \c NodeId of the node
234  * @param lower The lower value for each probability in correct order
235  * @param upper The upper value for each probability in correct order
236  *
237  * You need to call intervalToCredal when done filling all constraints.
238  *
239  * @warning : DOES change the \c BayesNet (s) associated to this credal
240  *net !
241  * @note we forget the master ref of \c ins to check variable order in the
242  *instantiation ( to get index ), therefore we pass it by value
243  */
244  void fillConstraints(const NodeId& id,
245  const std::vector< GUM_SCALAR >& lower,
246  const std::vector< GUM_SCALAR >& upper);
247 
248  /**
249  * @brief %Set the interval constraints of a credal set of a given node (
250  *from an instantiation index )
251  * @param id The \c NodeId of the node
252  * @param entry The index of the instantiation excluding the given node (
253  * only the parents are used to compute the index of the credal set )
254  * @param lower The lower value for each probability in correct order
255  * @param upper The upper value for each probability in correct order
256  *
257  * You need to call intervalToCredal when done filling all constraints.
258  *
259  * @warning : DOES change the \c BayesNet (s) associated to this credal
260  *net !
261  * @note we forget the master ref of \c ins to check variable order in the
262  *instantiation ( to get index ), therefore we pass it by value
263  */
264  void fillConstraint(const NodeId& id,
265  const Idx& entry,
266  const std::vector< GUM_SCALAR >& lower,
267  const std::vector< GUM_SCALAR >& upper);
268 
269  /**
270  * @brief %Set the interval constraints of a credal sets of a given node (
271  *from
272  *an instantiation )
273  * @param id The \c NodeId of the node
274  * @param ins The \c Instantiation
275  * @param lower The lower value for each probability in correct order
276  * @param upper The upper value for each probability in correct order
277  *
278  * You need to call intervalToCredal when done filling all constraints.
279  *
280  * @warning : DOES change the \c BayesNet (s) associated to this credal
281  *net !
282  * @note we forget the master ref of \c ins to check variable order in the
283  *instantiation ( to get index ), therefor we pass it by value
284  */
285  void fillConstraint(const NodeId& id,
286  Instantiation ins,
287  const std::vector< GUM_SCALAR >& lower,
288  const std::vector< GUM_SCALAR >& upper);
289 
290  /**
291  * @brief %Get an \c Instantiation from a node id, usefull to fill the
292  * constraints of the network
293  * @param id The \c NodeId we want an instantiation from
294  * @return The instantiation
295  */
296  Instantiation instantiation(const NodeId& id);
297 
298  /**
299  * @brief %Get the cardinality of a node
300  * @param id The \c NodeId of the node
301  * @return The cardinality of the node
302  */
303  Size domainSize(const NodeId& id);
304 
305  /// @}
306 
307  /// @name Public manipulation methods
308  /// @{
309 
310  /**
311  * Perturbates the BayesNet provided as input for this CredalNet by
312  *generating intervals instead of point probabilities and then computes each
313  *vertex of each credal set.
314  *
315  * The perturbations are done according to the number of cases met for
316  *each node and each of it's parent instantiation, i.e. \f$ \epsilon =
317  *\beta^{ln(N_{pa(X) = j} + 1)} \f$ is the imprecision introduced which
318  *leads to \f$ \underline{p}(X = i \mid pa(X) = j) = (1 - \epsilon) p(X = i
319  *\mid pa(X) = j) \f$ and \f$ \overline{p}(X = i \mid pa(X) = j)
320  *=\underline{p}(X =i \mid pa(X) = j) + \epsilon \f$. Use this method when
321  *using a single BayesNet storing counts of events with \c oneNet set to \c
322  *TRUE or when using two BayesNet, one with lower probabilities and one with
323  *upper probabilities, with \c oneNet set to \c FALSE.
324  *
325  * @param beta The beta used to perturbate the network. \f$ 0 \leq \beta
326  *\leq 1 \f$.
327  * @param oneNet Boolean used as a flag. %Set to \c TRUE if one BayesNet
328  * if provided with counts, to \c FALSE if two BayesNet are provided; one
329  *with probabilities (the lower net) and one with denominators over the first
330  *modalities (the upper net).
331  * @param keepZeroes Boolean used as a flag as whether or not -
332  *respectively \c TRUE or \c FALSE - we keep zeroes as zeroes. Default is \c
333  *FALSE, i.e. zeroes are not kept.
334  */
335  void bnToCredal(const GUM_SCALAR beta, const bool oneNet, const bool keepZeroes = false);
336 
337  /**
338  * @deprecated Use intervalToCredal ( lrsWrapper with no input / output
339  *files needed ).
340  *
341  * Computes the vertices of each credal set according to their interval
342  *definition (uses lrs).
343  *
344  * Use this method when using a single BayesNet storing counts of events.
345  */
346  void intervalToCredalWithFiles();
347 
348  /**
349  * Computes the vertices of each credal set according to their interval
350  *definition (uses lrs).
351  *
352  * Use this method when using two BayesNet, one with lower probabilities
353  *and one with upper probabilities.
354  */
355  void intervalToCredal();
356 
357  /**
358  * Normalize counts of a BayesNet storing counts of each events such that
359  *no probability is 0.
360  *
361  * Use this method when using a single BayesNet storing counts of events.
362  * Lagrange normalization. This call is irreversible and modify counts
363  *stored by \c _src_bn_.
364  *
365  * Doest not performs computations of the parameters but keeps normalized
366  *counts of events only. Call \c idmLearning to compute the probabilities
367  *(with any parameter value).
368  */
369  void lagrangeNormalization();
370 
371  /**
372  * Learns parameters from a BayesNet storing counts of events.
373  *
374  * Use this method when using a single BayesNet storing counts of events.
375  * IDM model if \c s > 0, standard point probability if \c s = 0 (default
376  *value if none precised).
377  * @param s The IDM parameter.
378  * @param keepZeroes Boolean used as a flag as whether or not -
379  *respectively \c TRUE or \c FALSE - we keep zeroes as zeroes. Default is \c
380  *FALSE, i.e. zeroes are not kept.
381  */
382  void idmLearning(const Idx s = 0, const bool keepZeroes = false);
383 
384  /**
385  * Approximate binarization. Each bit has a lower and upper probability
386  * which is the lowest - resp. highest - over all vertices of the credal set.
387  * Enlarge the original credal sets and may induce huge imprecision.
388  *
389  * @warning Enlarge the original credal sets and therefore induce huge
390  *imprecision by propagation. Not recommended, use MCSampling or something
391  *else
392  *instead.
393  */
394  void approximatedBinarization();
395 
396  /// @}
397 
398  // other utility member methods
399  // PH void saveCNet ( const std::string &cn_path ) const;
400  // PH void loadCNet ( const std::string &src_cn_path );
401 
402  /**
403  * If this CredalNet was built over a perturbed BayesNet, one can save the
404  *intervals as two BayesNet.
405  *
406  * @param min_path The path to save the BayesNet which contains the lower
407  *probabilities of each node X, i.e. \f$ \underline{p}(X = i \mid pa(X) =
408  *j)
409  *\f$.
410  * @param max_path The path to save the BayesNet which contains the upper
411  *probabilities of each node X, i.e. \f$ \overline{p}(X = i \mid pa(X) =
412  *j)
413  *\f$.
414  */
415  void saveBNsMinMax(const std::string& min_path, const std::string& max_path) const;
416 
417  // PH void vacants ( int &result ) const;
418  // PH void notVacants ( int &result ) const;
419  // PH void averageVertices ( GUM_SCALAR &result ) const;
420 
421  /**
422  * @return Returns the string representation of this CredalNet, i.e. it's
423  * CPTs
424  * (which also represent arcs).
425  */
426  std::string toString() const;
427  // PH void toPNG ( const std::string &png_path ) const;
428 
429  /**
430  * Used with binary networks to speed-up L2U inference.
431  *
432  * Store the lower and upper probabilities of each node X over the "true"
433  *modality, i.e. respectively \f$ \underline{p}(X = 1 \mid pa(X) = j) \f$
434  *and
435  *\f$ \overline{p}(X = 1 \mid pa(X) = j) \f$.
436  */
437  void computeBinaryCPTMinMax(); // REDO THIS IN PRIVATE !!!
438 
439  /// @name Getters and setters
440  /// @{
441  /**
442  * @return Returns a constant reference to the original BayesNet (used as
443  * a
444  * DAG, it's CPTs does not matter).
445  */
446  const BayesNet< GUM_SCALAR >& src_bn() const;
447 
448  /**
449  * @return Returs a constant reference to the actual BayesNet (used as a
450  * DAG,
451  * it's CPTs does not matter).
452  */
453  const BayesNet< GUM_SCALAR >& current_bn() const;
454 
455  /**
456  * @return Returns a constant reference to the ( up-to-date ) CredalNet
457  * CPTs.
458  */
459  const NodeProperty< std::vector< std::vector< std::vector< GUM_SCALAR > > > >&
460  credalNet_currentCpt() const;
461 
462  /**
463  * @return Returns a constant reference to the ( up-to-date ) CredalNet
464  * CPTs.
465  */
466  const NodeProperty< std::vector< std::vector< std::vector< GUM_SCALAR > > > >&
467  credalNet_srcCpt() const;
468 
469  /**
470  * @param id The constant reference to the choosen NodeId
471  * @return Returns the type of the choosen node in the ( up-to-date )
472  * CredalNet
473  * _current_bn_ if any, _src_bn_ otherwise.
474  */
475  NodeType currentNodeType(const NodeId& id) const;
476 
477  /**
478  * @param id The constant reference to the choosen NodeId
479  * @return Returns the type of the choosen node in the ( up-to-date )
480  * CredalNet
481  * in _src_bn_.
482  */
483  NodeType nodeType(const NodeId& id) const;
484 
485  /**
486  * @return Returns a constant reference to the lowest perturbation of the
487  * BayesNet provided as input for this CredalNet.
488  */
489  const GUM_SCALAR& epsilonMin() const;
490 
491  /**
492  * @return Returns a constant reference to the highest perturbation of the
493  * BayesNet provided as input for this CredalNet.
494  */
495  const GUM_SCALAR& epsilonMax() const;
496 
497  /**
498  * @return Returns a constant reference to the average perturbation of the
499  * BayesNet provided as input for this CredalNet.
500  */
501  const GUM_SCALAR& epsilonMean() const;
502 
503  /**
504  * @return Returns \c TRUE if this CredalNet is separately and interval
505  * specified, \c FALSE otherwise.
506  */
507  const bool isSeparatelySpecified() const;
508 
509  /**
510  * @return Returns \c TRUE if this CredalNet has called
511  * computeBinaryCPTMinMax() to speed-up inference with binary networks and
512  * L2U. This needs to be reworked as it is too easy to forget to call it and
513  * it can't be called within the inference engine (constness).
514  */
515  const bool hasComputedBinaryCPTMinMax() const;
516 
517  /**
518  * Used with binary networks to speed-up L2U inference.
519  *
520  * @return Returns a constant reference to the lower probabilities of each
521  *node
522  *X over the "true" modality, i.e. \f$ \underline{p}(X = 1 \mid pa(X) = j)
523  *\f$.
524  */
525  const std::vector< std::vector< GUM_SCALAR > >& get_binaryCPT_min() const;
526 
527  /**
528  * Used with binary networks to speed-up L2U inference.
529  *
530  * @return Returns a constant reference to the upper probabilities of each
531  *node
532  *X over the "true" modality, i.e. \f$ \overline{p}(X = 1 \mid pa(X) = j)
533  *\f$.
534  */
535  const std::vector< std::vector< GUM_SCALAR > >& get_binaryCPT_max() const;
536 
537  // PH const std::vector< std::vector< NodeId > > & var_bits() const;
538 
539  /// @}
540 
541  protected:
542  private:
543  /** @brief 1e6 by default, used by _fracC_ as precision. */
544  GUM_SCALAR _precisionC_; // = 1e6;
545  /** @brief 5 by default, used by _fracC_ as number of decimals. */
546  GUM_SCALAR _deltaC_; // = 5;
547 
548  /** @brief The lowest perturbation of the BayesNet provided as input for
549  * this
550  * CredalNet. */
551  GUM_SCALAR _epsilonMin_;
552  /** @brief The highest perturbation of the BayesNet provided as input for
553  * this
554  * CredalNet. */
555  GUM_SCALAR _epsilonMax_;
556  /** @brief The average perturbation of the BayesNet provided as input for
557  * this
558  * CredalNet. */
559  GUM_SCALAR _epsilonMoy_;
560 
561  /** @brief Value under which a decimal number is considered to be zero
562  * when
563  * computing redundant vertices. */
564  GUM_SCALAR _epsRedund_; //= 1e-6;
565 
566  /** @brief Value under which a decimal number is considered to be zero
567  * when
568  * using _farey_. */
569  GUM_SCALAR _epsF_; // = 1e-6;
570  /** @brief Highest possible denominator allowed when using _farey_. A
571  * value too
572  * high may lead to lrs being unable to find vertices. */
573  GUM_SCALAR _denMax_; // = 1e6; // beware LRS
574 
575  /** @brief Precision used by _frac_. */
576  GUM_SCALAR _precision_; // = 1e6; // beware LRS
577 
578  /** @brief \c TRUE if this CredalNet is separately and interval specified,
579  * \c
580  * FALSE otherwise. */
581  bool _separatelySpecified_;
582 
583  /** @brief Original BayesNet (used as a DAG). Is never modified. */
584  BayesNet< GUM_SCALAR > _src_bn_;
585 
586  /** @brief BayesNet used to store lower probabilities. */
587  BayesNet< GUM_SCALAR > _src_bn_min_;
588  /** @brief BayesNet used to store upper probabilities. */
589  BayesNet< GUM_SCALAR > _src_bn_max_;
590 
591  /** @brief Up-to-date BayesNet (used as a DAG). */
592  BayesNet< GUM_SCALAR >* _current_bn_; // = nullptr;
593 
594  /** @brief This CredalNet original CPTs. */
595  NodeProperty< std::vector< std::vector< std::vector< GUM_SCALAR > > > > _credalNet_src_cpt_;
596 
597  /** @brief This CredalNet up-to-date CPTs. */
598  NodeProperty< std::vector< std::vector< std::vector< GUM_SCALAR > > > >*
599  _credalNet_current_cpt_; // = nullptr;
600 
601  /** @deprecated @brief Corresponding bits of each variable. */
602  NodeProperty< std::vector< NodeId > > _var_bits_;
603 
604  /** @brief The NodeType of each node from the ORIGINAL network. */
605  NodeProperty< NodeType > _original_nodeType_;
606  /** @brief The NodeType of each node from the up-to-date network. */
607  NodeProperty< NodeType >* _current_nodeType_; // = nullptr;
608 
609  /** @brief Used by L2U, to know if lower and upper probabilities over the
610  * second modality has been stored in order to speed-up the algorithm. */
611  bool _hasComputedBinaryCPTMinMax_;
612  /**
613  * @brief Used with binary networks to speed-up L2U inference. Store the
614  * lower
615  * probabilities of each node X over the "true" modality, i.e. \f$
616  * \underline{p}(X = 1 \mid pa(X) = j) \f$.
617  */
618  typename std::vector< std::vector< GUM_SCALAR > > _binCptMin_;
619 
620  /**
621  * @brief Used with binary networks to speed-up L2U inference. Store the
622  * upper
623  * probabilities of each node X over the "true" modality, i.e. \f$
624  * \overline{p}(X = 1 \mid pa(X) = j) \f$.
625  */
626  typename std::vector< std::vector< GUM_SCALAR > > _binCptMax_;
627 
628  /** @brief %Set the NodeType of each node */
629  void _sort_varType_();
630 
631  /**
632  * @deprecated
633  * @param var_cpt The reference to a node CPT which may need a Decision
634  * Node.
635  * @return Returns the cardinality of the Decision Node.
636  */
637  int _find_dNode_card_(
638  const std::vector< std::vector< std::vector< GUM_SCALAR > > >& var_cpt) const;
639 
640  /**
641  * Computes the vertices of each credal set according to their interval
642  *definition (does not use lrs). Only works with credal sets defined such
643  *that
644  *when one modality reach it's upper probability, all others are at their
645  *lowest.
646  *
647  * Called by bnToCredal and idmLearning.
648  */
649  void _intervalToCredal_();
650 
651  /** @brief Initialize private constant variables after the Constructor has
652  * been
653  * called */
654  void _initParams_();
655 
656  /** @brief Initialize private BayesNet variables after the Constructor has
657  * been
658  * called */
659  void _initCNNets_(const std::string& src_min_num, const std::string& src_max_den);
660 
661  /** @brief Initialize private BayesNet variables after the Constructor has
662  * been
663  * called */
664  void _initCNNets_(const BayesNet< GUM_SCALAR >& src_min_num,
665  const BayesNet< GUM_SCALAR >& src_max_den);
666 
667  /**
668  * @deprecated
669  * @warning May be useless since the BayesNet copy constructor seems to
670  *now
671  *work well (parent order is preserved).
672  *
673  * Copy the up-to-date BayesNet associated with this CredalNet. Since all
674  *we
675  *care about is the DAG, only arcs are copied. Because the order with
676  *which
677  *arcs are created is important, the function iterates over the CPTs
678  *variables
679  *to be sure parent order stays the same from a net to it's copy.
680  *
681  * @param bn_dest The reference to the new copy
682  */
683  void _bnCopy_(BayesNet< GUM_SCALAR >& bn_dest);
684 
685  // void _H2Vcdd_ ( const std::vector< std::vector< GUM_SCALAR > > & h_rep,
686  // std::vector< std::vector< GUM_SCALAR > > & v_rep ) const;
687  /**
688  * @deprecated one should use the LrsWrapper class
689  * Computes the V-representation of a credal set, i.e. it's vertices, from
690  *it's
691  *H-representation, i.e. the hyper-plan inequalities. Uses lrs.
692  *
693  * @param h_rep A constant reference to the H-representation of a credal
694  *set.
695  * @param v_rep A reference to the V-representation of the same credal
696  *set.
697  */
698  void _H2Vlrs_(const std::vector< std::vector< GUM_SCALAR > >& h_rep,
699  std::vector< std::vector< GUM_SCALAR > >& v_rep) const;
700 
701  }; // CredalNet
702 
703 
704 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
705  extern template class CredalNet< double >;
706 #endif
707 
708  } // namespace credal
709 } // namespace gum
710 
711 #include <agrum/CN/credalNet_tpl.h>
712 
713 #endif // __CREDAL_NET__H__