aGrUM  0.14.2
maxParentsMCBayesNetGenerator_tpl.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Pierre-Henri WUILLEMIN & Ariele-Paolo MAESANO *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
28 
29 namespace gum {
30 
31 #ifdef _MSC_VER
32 # define MCBG MCBayesNetGenerator
33 #else
34 # define MCBG MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >
35 #endif
36 
37  // Default constructor.
38  // Use the SimpleCPTGenerator for generating the BNs CPT.
39  template < typename GUM_SCALAR,
40  template < class >
41  class ICPTGenerator,
42  template < class >
43  class ICPTDisturber >
44  INLINE
47  Size maxArcs,
48  Size maxModality,
49  Size maxParents,
50  Idx iteration,
51  Idx p,
52  Idx q) :
53  MCBG(nbrNodes, maxArcs, maxModality, iteration, p, q) {
54  if (maxParents == 0)
56  "maxParents must be at least equal to 1 to have a connexe graph");
57 
59  GUM_CONSTRUCTOR(MaxParentsMCBayesNetGenerator);
60  }
61 
62  template < typename GUM_SCALAR,
63  template < class >
64  class ICPTGenerator,
65  template < class >
66  class ICPTDisturber >
67  INLINE
71  Idx iteration,
72  Idx p,
73  Idx q) :
74  MCBG(bayesNet, iteration, p, q) {
76  GUM_CONSTRUCTOR(MaxParentsMCBayesNetGenerator);
77  }
78 
79  // Destructor.
80  template < typename GUM_SCALAR,
81  template < class >
82  class ICPTGenerator,
83  template < class >
84  class ICPTDisturber >
85  INLINE
88  GUM_DESTRUCTOR(MaxParentsMCBayesNetGenerator);
89  }
90 
91  template < typename GUM_SCALAR,
92  template < class >
93  class ICPTGenerator,
94  template < class >
95  class ICPTDisturber >
98  for (auto node : this->_bayesNet.nodes())
99  if (this->_bayesNet.parents(node).size() > _maxParents) return false;
100 
101  return MCBG::__checkConditions();
102  }
103 
104  template < typename GUM_SCALAR,
105  template < class >
106  class ICPTGenerator,
107  template < class >
108  class ICPTDisturber >
109  INLINE Size MaxParentsMCBayesNetGenerator< GUM_SCALAR,
110  ICPTGenerator,
111  ICPTDisturber >::maxParents() const {
112  return _maxParents;
113  }
114  template < typename GUM_SCALAR,
115  template < class >
116  class ICPTGenerator,
117  template < class >
118  class ICPTDisturber >
119  INLINE void
122  if (maxParents == 0)
124  "maxParents must be at least equal to 1 to have a connexe graph");
125 
127  }
128 } /* namespace gum */
Class representing a Bayesian Network.
Definition: BayesNet.h:76
<agrum/BN/generator/SimpleMCayesNetGenerator.h>
Idx q() const
Return a constant reference to the probabilité imposed on the Markov Chain BayesNetGenerator.
void setMaxParents(Size maxParents)
Modifies the value of the number of maximum parents imposed on the BayesNetGenerator.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
BayesNet< GUM_SCALAR > _bayesNet
bool __checkConditions() final
function to holding the the specification wanted for the Bayesian markov.
MaxParentsMCBayesNetGenerator(Size nbrNodes, Size maxArcs, Size maxModality=2, Size maxParents=1, Idx iteration=5000, Idx p=30, Idx q=40)
Constructor.
Size maxParents() const
Return a constant reference to the number of maximum parents imposed on the Markov Chain BayesNetGene...
Size Idx
Type for indexes.
Definition: types.h:50
Size iteration() const
Return a constant reference to the number of iteration imposed on the Markov Chain BayesNetGenerator...
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
Class for generating bayesian networks using MC algorithm cf.
Idx p() const
Return a constant reference to the probabilité p imposed on the Markov Chain BayesNetGenerator.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52