aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
credalNet.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright 2005-2020 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 in order to perturb it's
112  * probability distributions into credal sets according to another BayesNet
113  * containing the number of 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,
123  const std::string& src_max_den = "");
124 
125  /**
126  * Constructor for interval defined credal network which takes 2 BayesNet.
127  * One can also provide a single BayesNet in order to perturb it's
128  * probability distributions into credal sets according to another BayesNet
129  * containing the number of cases, for each node, of each parent
130  * instantiation met during learning, i.e. \f$ p(X = 0 \mid pa(X) = j) =
131  * N_{pa(X) = j} \f$.
132  *
133  * @param src_min_num The BayesNet which contains lower probabilities.
134  * @param src_max_den The ( optional ) BayesNet which contains upper
135  *probabilities.
136  */
137  CredalNet(const BayesNet< GUM_SCALAR >& src_min_num,
138  const BayesNet< GUM_SCALAR >& src_max_den
139  = BayesNet< GUM_SCALAR >());
140 
141  /**
142  * Destructor.
143  */
144  ~CredalNet();
145 
146  /// @}
147 
148  /// @name Credal network creation
149  /// @{
150 
151  /**
152  * @brief Adds a discrete node into the network
153  * @param name The name of the discrete variable to be added
154  * @param card The cardinality of the variable
155  * @return The \c NodeId of the variable in the network
156  */
157  NodeId addVariable(const std::string& name, const Size& card);
158 
159  /**
160  * @brief Adds an arc between two nodes.
161  * @param tail The \c NodeId of the tail node
162  * @param head The \c NodeId of the head node
163  */
164  void addArc(const NodeId& tail, const NodeId& head);
165 
166  /**
167  * @brief %Set the vertices of the credal sets ( all of the conditionals )
168  *of a
169  *given node
170  * @param id The \c NodeId of the node
171  * @param cpt The vertices of every credal set ( for each instantiation of
172  *the
173  *parents )
174  *
175  * @warning : Does not change the \c BayesNet (s) associated to this
176  *credal net
177  *!
178  *
179  * First dimension is instantiation position ( from 0 to K - 1 ).
180  * Second is the credal set vertice index
181  * Third is the vertex
182  */
183  void setCPTs(
184  const NodeId& id,
185  const std::vector< std::vector< std::vector< GUM_SCALAR > > >& cpt);
186 
187  /**
188  * @brief %Set the vertices of one credal set of a given node ( any
189  *instantiation index )
190  * @param id The \c NodeId of the node
191  * @param entry The index of the instantiation ( from 0 to K - 1 )
192  *excluding
193  *the given node ( only the parents are used to compute the index of the
194  *credal
195  *set )
196  * @param cpt The vertices of every credal set ( for each instantiation of
197  *the
198  *parents )
199  *
200  * Use this with either \c LRSWrapper or \c LpInterface to get the
201  *vertices of
202  *a credal set represented by linear constraints.
203  * @warning : Does not change the \c BayesNet (s) associated to this
204  *credal net
205  *!
206  */
207  void setCPT(const NodeId& id,
208  Size& entry,
209  const std::vector< std::vector< GUM_SCALAR > >& cpt);
210 
211  /**
212  * @brief %Set the vertices of one credal set of a given node ( any
213  *instantiation )
214  * @param id The \c NodeId of the node
215  * @param ins The \c Instantiation ( only the parents matter to find the
216  *credal
217  *set index )
218  * @param cpt The vertices of every credal set ( for each instantiation of
219  *the
220  *parents )
221  *
222  * Use this with either \c LRSWrapper or \c LpInterface to get the
223  *vertices of a credal set represented by linear constraints.
224  * @warning : Does not change the \c BayesNet (s) associated to this
225  *credal net
226  *!
227  *
228  * @note we forget the master ref of \c ins to check variable order in the
229  *instantiation ( to get index ), therefor we pass it by value
230  */
231  void setCPT(const NodeId& id,
232  Instantiation ins,
233  const std::vector< std::vector< GUM_SCALAR > >& cpt);
234 
235  /**
236  * @brief %Set the interval constraints of the credal sets of a given node
237  *(all instantiations )
238  * @param id The \c NodeId of the node
239  * @param lower The lower value for each probability in correct order
240  * @param upper The upper value for each probability in correct order
241  *
242  * You need to call intervalToCredal when done filling all constraints.
243  *
244  * @warning : DOES change the \c BayesNet (s) associated to this credal
245  *net !
246  * @note we forget the master ref of \c ins to check variable order in the
247  *instantiation ( to get index ), therefore we pass it by value
248  */
249  void fillConstraints(const NodeId& id,
250  const std::vector< GUM_SCALAR >& lower,
251  const std::vector< GUM_SCALAR >& upper);
252 
253  /**
254  * @brief %Set the interval constraints of a credal set of a given node (
255  *from an instantiation index )
256  * @param id The \c NodeId of the node
257  * @param entry The index of the instantiation excluding the given node (
258  * only the parents are used to compute the index of the credal set )
259  * @param lower The lower value for each probability in correct order
260  * @param upper The upper value for each probability in correct order
261  *
262  * You need to call intervalToCredal when done filling all constraints.
263  *
264  * @warning : DOES change the \c BayesNet (s) associated to this credal
265  *net !
266  * @note we forget the master ref of \c ins to check variable order in the
267  *instantiation ( to get index ), therefore we pass it by value
268  */
269  void fillConstraint(const NodeId& id,
270  const Idx& entry,
271  const std::vector< GUM_SCALAR >& lower,
272  const std::vector< GUM_SCALAR >& upper);
273 
274  /**
275  * @brief %Set the interval constraints of a credal sets of a given node (
276  *from
277  *an instantiation )
278  * @param id The \c NodeId of the node
279  * @param ins The \c Instantiation
280  * @param lower The lower value for each probability in correct order
281  * @param upper The upper value for each probability in correct order
282  *
283  * You need to call intervalToCredal when done filling all constraints.
284  *
285  * @warning : DOES change the \c BayesNet (s) associated to this credal
286  *net !
287  * @note we forget the master ref of \c ins to check variable order in the
288  *instantiation ( to get index ), therefor we pass it by value
289  */
290  void fillConstraint(const NodeId& id,
291  Instantiation ins,
292  const std::vector< GUM_SCALAR >& lower,
293  const std::vector< GUM_SCALAR >& upper);
294 
295  /**
296  * @brief %Get an \c Instantiation from a node id, usefull to fill the
297  * constraints of the network
298  * @param id The \c NodeId we want an instantiation from
299  * @return The instantiation
300  */
301  Instantiation instantiation(const NodeId& id);
302 
303  /**
304  * @brief %Get the cardinality of a node
305  * @param id The \c NodeId of the node
306  * @return The cardinality of the node
307  */
308  Size domainSize(const NodeId& id);
309 
310  /// @}
311 
312  /// @name Public manipulation methods
313  /// @{
314 
315  /**
316  * Perturbates the BayesNet provided as input for this CredalNet by
317  *generating intervals instead of point probabilities and then computes each
318  *vertex of each credal set.
319  *
320  * The perturbations are done according to the number of cases met for
321  *each node and each of it's parent instantiation, i.e. \f$ \epsilon =
322  *\beta^{ln(N_{pa(X) = j} + 1)} \f$ is the imprecision introduced which
323  *leads to \f$ \underline{p}(X = i \mid pa(X) = j) = (1 - \epsilon) p(X = i
324  *\mid pa(X) = j) \f$ and \f$ \overline{p}(X = i \mid pa(X) = j)
325  *=\underline{p}(X =i \mid pa(X) = j) + \epsilon \f$. Use this method when
326  *using a single BayesNet storing counts of events with \c oneNet set to \c
327  *TRUE or when using two BayesNet, one with lower probabilities and one with
328  *upper probabilities, with \c oneNet set to \c FALSE.
329  *
330  * @param beta The beta used to perturbate the network. \f$ 0 \leq \beta
331  *\leq 1 \f$.
332  * @param oneNet Boolean used as a flag. %Set to \c TRUE if one BayesNet
333  * if provided with counts, to \c FALSE if two BayesNet are provided; one
334  *with probabilities (the lower net) and one with denominators over the first
335  *modalities (the upper net).
336  * @param keepZeroes Boolean used as a flag as whether or not -
337  *respectively \c TRUE or \c FALSE - we keep zeroes as zeroes. Default is \c
338  *FALSE, i.e. zeroes are not kept.
339  */
340  void bnToCredal(const GUM_SCALAR beta,
341  const bool oneNet,
342  const bool keepZeroes = false);
343 
344  /**
345  * @deprecated Use intervalToCredal ( lrsWrapper with no input / output
346  *files needed ).
347  *
348  * Computes the vertices of each credal set according to their interval
349  *definition (uses lrs).
350  *
351  * Use this method when using a single BayesNet storing counts of events.
352  */
353  void intervalToCredalWithFiles();
354 
355  /**
356  * Computes the vertices of each credal set according to their interval
357  *definition (uses lrs).
358  *
359  * Use this method when using two BayesNet, one with lower probabilities
360  *and one with upper probabilities.
361  */
362  void intervalToCredal();
363 
364  /**
365  * Normalize counts of a BayesNet storing counts of each events such that
366  *no probability is 0.
367  *
368  * Use this method when using a single BayesNet storing counts of events.
369  * Lagrange normalization. This call is irreversible and modify counts
370  *stored by \c src_bn__.
371  *
372  * Doest not performs computations of the parameters but keeps normalized
373  *counts of events only. Call \c idmLearning to compute the probabilities
374  *(with any parameter value).
375  */
376  void lagrangeNormalization();
377 
378  /**
379  * Learns parameters from a BayesNet storing counts of events.
380  *
381  * Use this method when using a single BayesNet storing counts of events.
382  * IDM model if \c s > 0, standard point probability if \c s = 0 (default
383  *value if none precised).
384  * @param s The IDM parameter.
385  * @param keepZeroes Boolean used as a flag as whether or not -
386  *respectively \c TRUE or \c FALSE - we keep zeroes as zeroes. Default is \c
387  *FALSE, i.e. zeroes are not kept.
388  */
389  void idmLearning(const Idx s = 0, const bool keepZeroes = false);
390 
391  /**
392  * Approximate binarization. Each bit has a lower and upper probability
393  * which is the lowest - resp. highest - over all vertices of the credal set.
394  * Enlarge the original credal sets and may induce huge imprecision.
395  *
396  * @warning Enlarge the original credal sets and therefore induce huge
397  *imprecision by propagation. Not recommended, use MCSampling or something
398  *else
399  *instead.
400  */
401  void approximatedBinarization();
402 
403  /// @}
404 
405  // other utility member methods
406  // PH void saveCNet ( const std::string &cn_path ) const;
407  // PH void loadCNet ( const std::string &src_cn_path );
408 
409  /**
410  * If this CredalNet was built over a perturbed BayesNet, one can save the
411  *intervals as two BayesNet.
412  *
413  * @param min_path The path to save the BayesNet which contains the lower
414  *probabilities of each node X, i.e. \f$ \underline{p}(X = i \mid pa(X) =
415  *j)
416  *\f$.
417  * @param max_path The path to save the BayesNet which contains the upper
418  *probabilities of each node X, i.e. \f$ \overline{p}(X = i \mid pa(X) =
419  *j)
420  *\f$.
421  */
422  void saveBNsMinMax(const std::string& min_path,
423  const std::string& max_path) const;
424 
425  // PH void vacants ( int &result ) const;
426  // PH void notVacants ( int &result ) const;
427  // PH void averageVertices ( GUM_SCALAR &result ) const;
428 
429  /**
430  * @return Returns the string representation of this CredalNet, i.e. it's
431  * CPTs
432  * (which also represent arcs).
433  */
434  std::string toString() const;
435  // PH void toPNG ( const std::string &png_path ) const;
436 
437  /**
438  * Used with binary networks to speed-up L2U inference.
439  *
440  * Store the lower and upper probabilities of each node X over the "true"
441  *modality, i.e. respectively \f$ \underline{p}(X = 1 \mid pa(X) = j) \f$
442  *and
443  *\f$ \overline{p}(X = 1 \mid pa(X) = j) \f$.
444  */
445  void computeBinaryCPTMinMax(); // REDO THIS IN PRIVATE !!!
446 
447  /// @name Getters and setters
448  /// @{
449  /**
450  * @return Returns a constant reference to the original BayesNet (used as
451  * a
452  * DAG, it's CPTs does not matter).
453  */
454  const BayesNet< GUM_SCALAR >& src_bn() const;
455 
456  /**
457  * @return Returs a constant reference to the actual BayesNet (used as a
458  * DAG,
459  * it's CPTs does not matter).
460  */
461  const BayesNet< GUM_SCALAR >& current_bn() const;
462 
463  /**
464  * @return Returns a constant reference to the ( up-to-date ) CredalNet
465  * CPTs.
466  */
467  const NodeProperty<
468  std::vector< std::vector< std::vector< GUM_SCALAR > > > >&
469  credalNet_currentCpt() const;
470 
471  /**
472  * @return Returns a constant reference to the ( up-to-date ) CredalNet
473  * CPTs.
474  */
475  const NodeProperty<
476  std::vector< std::vector< std::vector< GUM_SCALAR > > > >&
477  credalNet_srcCpt() const;
478 
479  /**
480  * @param id The constant reference to the choosen NodeId
481  * @return Returns the type of the choosen node in the ( up-to-date )
482  * CredalNet
483  * current_bn__ if any, src_bn__ otherwise.
484  */
485  NodeType currentNodeType(const NodeId& id) const;
486 
487  /**
488  * @param id The constant reference to the choosen NodeId
489  * @return Returns the type of the choosen node in the ( up-to-date )
490  * CredalNet
491  * in src_bn__.
492  */
493  NodeType nodeType(const NodeId& id) const;
494 
495  /**
496  * @return Returns a constant reference to the lowest perturbation of the
497  * BayesNet provided as input for this CredalNet.
498  */
499  const GUM_SCALAR& epsilonMin() const;
500 
501  /**
502  * @return Returns a constant reference to the highest perturbation of the
503  * BayesNet provided as input for this CredalNet.
504  */
505  const GUM_SCALAR& epsilonMax() const;
506 
507  /**
508  * @return Returns a constant reference to the average perturbation of the
509  * BayesNet provided as input for this CredalNet.
510  */
511  const GUM_SCALAR& epsilonMean() const;
512 
513  /**
514  * @return Returns \c TRUE if this CredalNet is separately and interval
515  * specified, \c FALSE otherwise.
516  */
517  const bool isSeparatelySpecified() const;
518 
519  /**
520  * @return Returns \c TRUE if this CredalNet has called
521  * computeBinaryCPTMinMax() to speed-up inference with binary networks and
522  * L2U. This needs to be reworked as it is too easy to forget to call it and
523  * it can't be called within the inference engine (constness).
524  */
525  const bool hasComputedBinaryCPTMinMax() const;
526 
527  /**
528  * Used with binary networks to speed-up L2U inference.
529  *
530  * @return Returns a constant reference to the lower probabilities of each
531  *node
532  *X over the "true" modality, i.e. \f$ \underline{p}(X = 1 \mid pa(X) = j)
533  *\f$.
534  */
535  const std::vector< std::vector< GUM_SCALAR > >& get_binaryCPT_min() const;
536 
537  /**
538  * Used with binary networks to speed-up L2U inference.
539  *
540  * @return Returns a constant reference to the upper probabilities of each
541  *node
542  *X over the "true" modality, i.e. \f$ \overline{p}(X = 1 \mid pa(X) = j)
543  *\f$.
544  */
545  const std::vector< std::vector< GUM_SCALAR > >& get_binaryCPT_max() const;
546 
547  // PH const std::vector< std::vector< NodeId > > & var_bits() const;
548 
549  /// @}
550 
551  protected:
552  private:
553  /** @brief 1e6 by default, used by fracC__ as precision. */
554  GUM_SCALAR precisionC__; // = 1e6;
555  /** @brief 5 by default, used by fracC__ as number of decimals. */
556  GUM_SCALAR deltaC__; // = 5;
557 
558  /** @brief The lowest perturbation of the BayesNet provided as input for
559  * this
560  * CredalNet. */
561  GUM_SCALAR epsilonMin__;
562  /** @brief The highest perturbation of the BayesNet provided as input for
563  * this
564  * CredalNet. */
565  GUM_SCALAR epsilonMax__;
566  /** @brief The average perturbation of the BayesNet provided as input for
567  * this
568  * CredalNet. */
569  GUM_SCALAR epsilonMoy__;
570 
571  /** @brief Value under which a decimal number is considered to be zero
572  * when
573  * computing redundant vertices. */
574  GUM_SCALAR epsRedund__; //= 1e-6;
575 
576  /** @brief Value under which a decimal number is considered to be zero
577  * when
578  * using farey__. */
579  GUM_SCALAR epsF__; // = 1e-6;
580  /** @brief Highest possible denominator allowed when using farey__. A
581  * value too
582  * high may lead to lrs being unable to find vertices. */
583  GUM_SCALAR denMax__; // = 1e6; // beware LRS
584 
585  /** @brief Precision used by frac__. */
586  GUM_SCALAR precision__; // = 1e6; // beware LRS
587 
588  /** @brief \c TRUE if this CredalNet is separately and interval specified,
589  * \c
590  * FALSE otherwise. */
591  bool separatelySpecified__;
592 
593  /** @brief Original BayesNet (used as a DAG). Is never modified. */
594  BayesNet< GUM_SCALAR > src_bn__;
595 
596  /** @brief BayesNet used to store lower probabilities. */
597  BayesNet< GUM_SCALAR > src_bn_min__;
598  /** @brief BayesNet used to store upper probabilities. */
599  BayesNet< GUM_SCALAR > src_bn_max__;
600 
601  /** @brief Up-to-date BayesNet (used as a DAG). */
602  BayesNet< GUM_SCALAR >* current_bn__; // = nullptr;
603 
604  /** @brief This CredalNet original CPTs. */
605  NodeProperty< std::vector< std::vector< std::vector< GUM_SCALAR > > > >
606  credalNet_src_cpt__;
607 
608  /** @brief This CredalNet up-to-date CPTs. */
609  NodeProperty< std::vector< std::vector< std::vector< GUM_SCALAR > > > >*
610  credalNet_current_cpt__; // = nullptr;
611 
612  /** @deprecated @brief Corresponding bits of each variable. */
613  NodeProperty< std::vector< NodeId > > var_bits__;
614 
615  /** @brief The NodeType of each node from the ORIGINAL network. */
616  NodeProperty< NodeType > original_nodeType__;
617  /** @brief The NodeType of each node from the up-to-date network. */
618  NodeProperty< NodeType >* current_nodeType__; // = nullptr;
619 
620  /** @brief Used by L2U, to know if lower and upper probabilities over the
621  * second modality has been stored in order to speed-up the algorithm. */
622  bool hasComputedBinaryCPTMinMax__;
623  /**
624  * @brief Used with binary networks to speed-up L2U inference. Store the
625  * lower
626  * probabilities of each node X over the "true" modality, i.e. \f$
627  * \underline{p}(X = 1 \mid pa(X) = j) \f$.
628  */
629  typename std::vector< std::vector< GUM_SCALAR > > binCptMin__;
630 
631  /**
632  * @brief Used with binary networks to speed-up L2U inference. Store the
633  * upper
634  * probabilities of each node X over the "true" modality, i.e. \f$
635  * \overline{p}(X = 1 \mid pa(X) = j) \f$.
636  */
637  typename std::vector< std::vector< GUM_SCALAR > > binCptMax__;
638 
639  /** @brief %Set the NodeType of each node */
640  void sort_varType__();
641 
642  /**
643  * @deprecated
644  * @param var_cpt The reference to a node CPT which may need a Decision
645  * Node.
646  * @return Returns the cardinality of the Decision Node.
647  */
648  int find_dNode_card__(
649  const std::vector< std::vector< std::vector< GUM_SCALAR > > >& var_cpt)
650  const;
651 
652  /**
653  * Computes the vertices of each credal set according to their interval
654  *definition (does not use lrs). Only works with credal sets defined such
655  *that
656  *when one modality reach it's upper probability, all others are at their
657  *lowest.
658  *
659  * Called by bnToCredal and idmLearning.
660  */
661  void intervalToCredal__();
662 
663  /** @brief Initialize private constant variables after the Constructor has
664  * been
665  * called */
666  void initParams__();
667 
668  /** @brief Initialize private BayesNet variables after the Constructor has
669  * been
670  * called */
671  void initCNNets__(const std::string& src_min_num,
672  const std::string& src_max_den);
673 
674  /** @brief Initialize private BayesNet variables after the Constructor has
675  * been
676  * called */
677  void initCNNets__(const BayesNet< GUM_SCALAR >& src_min_num,
678  const BayesNet< GUM_SCALAR >& src_max_den);
679 
680  /**
681  * @deprecated
682  * @warning May be useless since the BayesNet copy constructor seems to
683  *now
684  *work well (parent order is preserved).
685  *
686  * Copy the up-to-date BayesNet associated with this CredalNet. Since all
687  *we
688  *care about is the DAG, only arcs are copied. Because the order with
689  *which
690  *arcs are created is important, the function iterates over the CPTs
691  *variables
692  *to be sure parent order stays the same from a net to it's copy.
693  *
694  * @param bn_dest The reference to the new copy
695  */
696  void bnCopy__(BayesNet< GUM_SCALAR >& bn_dest);
697 
698  // void H2Vcdd__ ( const std::vector< std::vector< GUM_SCALAR > > & h_rep,
699  // std::vector< std::vector< GUM_SCALAR > > & v_rep ) const;
700  /**
701  * @deprecated one should use the LrsWrapper class
702  * Computes the V-representation of a credal set, i.e. it's vertices, from
703  *it's
704  *H-representation, i.e. the hyper-plan inequalities. Uses lrs.
705  *
706  * @param h_rep A constant reference to the H-representation of a credal
707  *set.
708  * @param v_rep A reference to the V-representation of the same credal
709  *set.
710  */
711  void H2Vlrs__(const std::vector< std::vector< GUM_SCALAR > >& h_rep,
712  std::vector< std::vector< GUM_SCALAR > >& v_rep) const;
713 
714  }; // CredalNet
715 
716 
717 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
718  extern template class CredalNet< double >;
719 #endif
720 
721  } // namespace credal
722 } // namespace gum
723 
724 #include <agrum/CN/credalNet_tpl.h>
725 
726 #endif // __CREDAL_NET__H__