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