aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
maxParentsMCBayesNetGenerator_tpl.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 Source implementation of MaxParentsMCBayesNetGenerator
24  *
25  * @author Pierre-Henri WUILLEMIN(@LIP6) and Ariele Maesano
26  *
27  */
28 
29 #include <agrum/BN/generator/maxParentsMCBayesNetGenerator.h>
30 
31 namespace gum {
32 
33 #ifdef _MSC_VER
34 # define MCBG MCBayesNetGenerator
35 #else
36 # define MCBG MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >
37 #endif
38 
39  // Default constructor.
40  // Use the SimpleCPTGenerator for generating the BNs CPT.
41  template < typename GUM_SCALAR,
42  template < class >
43  class ICPTGenerator,
44  template < class >
45  class ICPTDisturber >
46  INLINE
47  MaxParentsMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::
49  Size maxArcs,
52  Idx iteration,
53  Idx p,
54  Idx q) :
56  if (maxParents == 0)
58  "maxParents must be at least equal to 1 to have a connexe graph");
59 
62  }
63 
64  template < typename GUM_SCALAR,
65  template < class >
66  class ICPTGenerator,
67  template < class >
68  class ICPTDisturber >
69  INLINE
73  Idx iteration,
74  Idx p,
75  Idx q) :
76  MCBG(bayesNet, iteration, p, q) {
79  }
80 
81  // Destructor.
82  template < typename GUM_SCALAR,
83  template < class >
84  class ICPTGenerator,
85  template < class >
86  class ICPTDisturber >
87  INLINE
91  }
92 
93  template < typename GUM_SCALAR,
94  template < class >
95  class ICPTGenerator,
96  template < class >
97  class ICPTDisturber >
100  for (auto node: this->bayesNet_.nodes())
101  if (this->bayesNet_.parents(node).size() > maxParents_) return false;
102 
103  return MCBG::checkConditions__();
104  }
105 
106  template < typename GUM_SCALAR,
107  template < class >
108  class ICPTGenerator,
109  template < class >
110  class ICPTDisturber >
114  return maxParents_;
115  }
116  template < typename GUM_SCALAR,
117  template < class >
118  class ICPTGenerator,
119  template < class >
120  class ICPTDisturber >
121  INLINE void
124  if (maxParents == 0)
126  "maxParents must be at least equal to 1 to have a connexe graph");
127 
129  }
130 } /* namespace gum */
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:669