aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
maxInducedWidthMCBayesNetGenerator_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 MaxInducedWidthMCBayesNetGenerator
24  *
25  * @author Pierre-Henri WUILLEMIN(@LIP6) and Ariele Maesano
26  *
27  */
28 
29 #include <agrum/BN/generator/maxInducedWidthMCBayesNetGenerator.h>
30 
31 namespace gum {
32 #ifdef _MSC_VER
33 # define MCBG MCBayesNetGenerator
34 # define IBNG IBayesNetGenerator
35 #else
36 # define MCBG MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >
37 # define IBNG IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >
38 #endif
39  // Default constructor.
40  // Use the SimpleCPTGenerator for generating the BNs CPT.
41  template < typename GUM_SCALAR,
42  template < typename >
43  class ICPTGenerator,
44  template < typename >
45  class ICPTDisturber >
46  INLINE MaxInducedWidthMCBayesNetGenerator<
47  GUM_SCALAR,
50  Size maxArcs,
53  Idx iteration,
54  Idx p,
55  Idx q) :
57  if (maxInducedWidth == 0)
59  "maxInducedWidth must be at least equal "
60  "to 1 to have a connexe graph");
61 
64  }
65 
66  template < typename GUM_SCALAR,
67  template < typename >
68  class ICPTGenerator,
69  template < typename >
70  class ICPTDisturber >
73  ICPTDisturber >::
76  Idx iteration,
77  Idx p,
78  Idx q) :
79  MCBG(bayesNet, iteration, p, q) {
82  }
83 
84  // Use this constructor if you want to use a different policy for generating
85  // CPT than the default one.
86  // The cptGenerator will be erased when the destructor is called.
87  // @param cptGenerator The policy used to generate CPT.
88  /*template<typename GUM_SCALAR, template<class> class ICPTGenerator,
89  template<class> class ICPDisturber>
90  MaxInducedWidthMCBayesNetGenerator<GUM_SCALAR,ICPTGenerator,ICPTDisturber>::MaxInducedWidthMCBayesNetGenerator(
91  CPTGenerator* cptGenerator,Size nbrNodes, Idx p,Idx q,Idx iteration,float
92  maxDensity , Size max_modality, Size maxInducedWidth):
93  MCBG<GUM_SCALAR,ICPTGenerator,ICPTDisturber>(cptGenerator,
94  nbrNodes,p,q,iteration, maxDensity,max_modality, maxInducedWidth){
95  GUM_CONSTRUCTOR(MaxInducedWidthMCBayesNetGenerator);
96  }*/
97 
98  // Destructor.
99  template < typename GUM_SCALAR,
100  template < typename >
101  class ICPTGenerator,
102  template < typename >
103  class ICPTDisturber >
105  GUM_SCALAR,
109  // delete BayesNetGenerator<GUM_SCALAR>::cptGenerator_;
110  }
111 
112  template < typename GUM_SCALAR,
113  template < typename >
114  class ICPTGenerator,
115  template < typename >
116  class ICPTDisturber >
121 
122  for (auto node: this->bayesNet_.nodes())
124 
126 
127  if (tri.maxLog10CliqueDomainSize() > maxlog10InducedWidth_) return false;
128 
129  return MCBG::checkConditions__();
130  }
131 
132  template < typename GUM_SCALAR,
133  template < typename >
134  class ICPTGenerator,
135  template < typename >
136  class ICPTDisturber >
137  INLINE Size
141  const {
142  return maxlog10InducedWidth_;
143  }
144  template < typename GUM_SCALAR,
145  template < typename >
146  class ICPTGenerator,
147  template < typename >
148  class ICPTDisturber >
150  GUM_SCALAR,
153  if (maxlog10InducedWidth == 0)
155  "maxInducedWidth must be at least equal "
156  "to 1 to have a connexe graph");
157 
159  }
160 } /* namespace gum */
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:669