aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
simpleBayesNetGenerator.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 /** @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, template < typename > class ICPTGenerator = SimpleCPTGenerator >
57  class SimpleBayesNetGenerator: public IBayesNetGenerator< GUM_SCALAR, ICPTGenerator > {
58  public:
59  // ############################################################################
60  /// @name Constructors / Destructor
61  // ############################################################################
62  /// @{
63 
64  /**
65  * Constructor.
66  * Use by default the SimpleCPTGenerator for generating the BNs CPT.
67  * @param nbrNodes The number of nodes imposed on the generator.
68  * @param maxArcs The number of maximum arcs imposed on the generator.
69  * @param maxModality Each DRV has from 2 to maxModality modalities
70  */
71  SimpleBayesNetGenerator(Size nbrNodes, Size maxArcs, Size maxModality = 2);
72 
73  /**
74  * Destructor.
75  */
76  ~SimpleBayesNetGenerator() override;
77  /// @}
78 
79  // ############################################################################
80  /// @name BN generation methods
81  // ############################################################################
82  /// @{
83  /**
84  * function that generates a Bayesian networks.
85  * @param bayesNet Bayesian network to be completed after initialisation
86  * @return null but modify inputed Bayesian network
87  */
88  void generateBN(BayesNet< GUM_SCALAR >& bayesNet) override;
89 
90  /// @}
91  }; /* class SimpleBayesNetGenerator */
92 
93 
94 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
95  extern template class SimpleBayesNetGenerator< double >;
96 #endif
97 
98 } /* namespace gum */
99 
100 #include <agrum/BN/generator/simpleBayesNetGenerator_tpl.h>
101 
102 #endif /* GUM_SIMPLE_BAYES_NET_GENERATOR_H */