aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
maxParentsMCBayesNetGenerator_tpl.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 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 MaxParentsMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::
48  Size maxArcs,
51  Idx iteration,
52  Idx p,
53  Idx q) :
55  if (maxParents == 0)
57  "maxParents must be at least equal to 1 to have a connexe graph")
58 
61  }
62 
63  template < typename GUM_SCALAR,
64  template < class >
65  class ICPTGenerator,
66  template < class >
67  class ICPTDisturber >
71  Idx iteration,
72  Idx p,
73  Idx q) :
74  MCBG(bayesNet, iteration, p, q) {
77  }
78 
79  // Destructor.
80  template < typename GUM_SCALAR,
81  template < class >
82  class ICPTGenerator,
83  template < class >
84  class ICPTDisturber >
88  }
89 
90  template < typename GUM_SCALAR,
91  template < class >
92  class ICPTGenerator,
93  template < class >
94  class ICPTDisturber >
97  for (auto node: this->bayesNet_.nodes())
98  if (this->bayesNet_.parents(node).size() > maxParents_) return false;
99 
100  return MCBG::_checkConditions_();
101  }
102 
103  template < typename GUM_SCALAR,
104  template < class >
105  class ICPTGenerator,
106  template < class >
107  class ICPTDisturber >
108  INLINE Size
110  return maxParents_;
111  }
112  template < typename GUM_SCALAR,
113  template < class >
114  class ICPTGenerator,
115  template < class >
116  class ICPTDisturber >
117  INLINE void
119  Size maxParents) {
120  if (maxParents == 0)
122  "maxParents must be at least equal to 1 to have a connexe graph")
123 
125  }
126 } /* namespace gum */
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643