aGrUM  0.13.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 > class ICPTGenerator,
41  template < class > class ICPTDisturber >
42  INLINE
45  Size maxArcs,
46  Size maxModality,
47  Size maxParents,
48  Idx iteration,
49  Idx p,
50  Idx q) :
51  MCBG(nbrNodes, maxArcs, maxModality, iteration, p, q) {
52  if (maxParents == 0)
54  "maxParents must be at least equal to 1 to have a connexe graph");
55 
57  GUM_CONSTRUCTOR(MaxParentsMCBayesNetGenerator);
58  }
59 
60  template < typename GUM_SCALAR,
61  template < class > class ICPTGenerator,
62  template < class > class ICPTDisturber >
63  INLINE
67  Idx iteration,
68  Idx p,
69  Idx q) :
70  MCBG(bayesNet, iteration, p, q) {
72  GUM_CONSTRUCTOR(MaxParentsMCBayesNetGenerator);
73  }
74 
75  // Destructor.
76  template < typename GUM_SCALAR,
77  template < class > class ICPTGenerator,
78  template < class > class ICPTDisturber >
79  INLINE
82  GUM_DESTRUCTOR(MaxParentsMCBayesNetGenerator);
83  }
84 
85  template < typename GUM_SCALAR,
86  template < class > class ICPTGenerator,
87  template < class > class ICPTDisturber >
90  for (auto node : this->_bayesNet.nodes())
91  if (this->_bayesNet.parents(node).size() > _maxParents) return false;
92 
93  return MCBG::__checkConditions();
94  }
95 
96  template < typename GUM_SCALAR,
97  template < class > class ICPTGenerator,
98  template < class > class ICPTDisturber >
99  INLINE Size MaxParentsMCBayesNetGenerator< GUM_SCALAR,
100  ICPTGenerator,
101  ICPTDisturber >::maxParents() const {
102  return _maxParents;
103  }
104  template < typename GUM_SCALAR,
105  template < class > class ICPTGenerator,
106  template < class > class ICPTDisturber >
107  INLINE void
110  if (maxParents == 0)
112  "maxParents must be at least equal to 1 to have a connexe graph");
113 
115  }
116 } /* namespace gum */
Class representing a Bayesian Network.
Definition: BayesNet.h:76
unsigned long Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:50
<agrum/BN/generator/SimpleMCayesNetGenerator.h>
void setMaxParents(Size maxParents)
Modifies the value of the number of maximum parents imposed on the BayesNetGenerator.
Size maxParents() const
Return a constant reference to the number of maximum parents imposed on the Markov Chain BayesNetGene...
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.
Idx p() const
Return a constant reference to the probabilité p imposed on the Markov Chain BayesNetGenerator.
Size iteration() const
Return a constant reference to the number of iteration imposed on the Markov Chain BayesNetGenerator...
MaxParentsMCBayesNetGenerator(Size nbrNodes, Size maxArcs, Size maxModality=2, Size maxParents=1, Idx iteration=5000, Idx p=30, Idx q=40)
Constructor.
unsigned long Idx
Type for indexes.
Definition: types.h:43
Idx q() const
Return a constant reference to the probabilité imposed on the Markov Chain BayesNetGenerator.
Class for generating bayesian networks using MC algorithm cf.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66