aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
simpleBayesNetGenerator.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 /** @file
23  * @brief Class for generating Bayesian networks.
24  *
25  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6) and
26  *Ariele-Paolo MAESANO
27  */
28 #ifndef GUM_SIMPLE_BAYES_NET_GENERATOR_H
29 #define GUM_SIMPLE_BAYES_NET_GENERATOR_H
30 
31 #include <climits>
32 #include <cstdio>
33 #include <cstdlib>
34 #include <iostream>
35 #include <vector>
36 
37 #include <agrum/BN/generator/IBayesNetGenerator.h>
38 #include <agrum/agrum.h>
39 
40 namespace gum {
41 
42  /**
43  * @class SimpleBayesNetGenerator simpleBayesNetGenerator.h
44  *<agrum/BN/generator/simpleBayesNetGenerator.h>
45  * @brief Class for generating Bayesian networks.
46  * @ingroup bn_generator
47  *
48  * This class randomly generates a Bayesian network given three parameters:
49  * the number of nodes and the max number of arcs and the number of maximum
50  *modality for each nodes.
51  * @warning Be Careful when entering the parameters, high Values may cause
52  *the
53  *density of the Bayesian network to be too high
54  * resulting in the failure of most of the inference Methods.
55  */
56  template < typename GUM_SCALAR,
57  template < typename > class ICPTGenerator = SimpleCPTGenerator >
58  class SimpleBayesNetGenerator:
59  public IBayesNetGenerator< GUM_SCALAR, ICPTGenerator > {
60  public:
61  // ############################################################################
62  /// @name Constructors / Destructor
63  // ############################################################################
64  /// @{
65 
66  /**
67  * Constructor.
68  * Use by default the SimpleCPTGenerator for generating the BNs CPT.
69  * @param nbrNodes The number of nodes imposed on the generator.
70  * @param maxArcs The number of maximum arcs imposed on the generator.
71  * @param maxModality Each DRV has from 2 to maxModality modalities
72  */
73  SimpleBayesNetGenerator(Size nbrNodes, Size maxArcs, Size maxModality = 2);
74 
75  /**
76  * Destructor.
77  */
78  ~SimpleBayesNetGenerator() override;
79  /// @}
80 
81  // ############################################################################
82  /// @name BN generation methods
83  // ############################################################################
84  /// @{
85  /**
86  * function that generates a Bayesian networks.
87  * @param bayesNet Bayesian network to be completed after initialisation
88  * @return null but modify inputed Bayesian network
89  */
90  void generateBN(BayesNet< GUM_SCALAR >& bayesNet) override;
91 
92  /// @}
93  }; /* class SimpleBayesNetGenerator */
94 
95 
96 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
97  extern template class SimpleBayesNetGenerator< double >;
98 #endif
99 
100 } /* namespace gum */
101 
102 #include <agrum/BN/generator/simpleBayesNetGenerator_tpl.h>
103 
104 #endif /* GUM_SIMPLE_BAYES_NET_GENERATOR_H */