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
>::
48
MaxParentsMCBayesNetGenerator
(
Size
nbrNodes
,
49
Size
maxArcs
,
50
Size
maxModality
,
51
Size
maxParents
,
52
Idx
iteration
,
53
Idx
p
,
54
Idx
q
) :
55
MCBG
(
nbrNodes
,
maxArcs
,
maxModality
,
iteration
,
p
,
q
) {
56
if
(
maxParents
== 0)
57
GUM_ERROR
(
OperationNotAllowed
,
58
"maxParents must be at least equal to 1 to have a connexe graph"
);
59
60
maxParents_
=
maxParents
;
61
GUM_CONSTRUCTOR
(
MaxParentsMCBayesNetGenerator
);
62
}
63
64
template
<
typename
GUM_SCALAR
,
65
template
<
class
>
66
class
ICPTGenerator
,
67
template
<
class
>
68
class
ICPTDisturber
>
69
INLINE
70
MaxParentsMCBayesNetGenerator
<
GUM_SCALAR
,
ICPTGenerator
,
ICPTDisturber
>::
71
MaxParentsMCBayesNetGenerator
(
BayesNet
<
GUM_SCALAR
>
bayesNet
,
72
Size
maxParents
,
73
Idx
iteration
,
74
Idx
p
,
75
Idx
q
) :
76
MCBG
(
bayesNet
,
iteration
,
p
,
q
) {
77
maxParents_
=
maxParents
;
78
GUM_CONSTRUCTOR
(
MaxParentsMCBayesNetGenerator
);
79
}
80
81
// Destructor.
82
template
<
typename
GUM_SCALAR
,
83
template
<
class
>
84
class
ICPTGenerator
,
85
template
<
class
>
86
class
ICPTDisturber
>
87
INLINE
88
MaxParentsMCBayesNetGenerator
<
GUM_SCALAR
,
ICPTGenerator
,
ICPTDisturber
>::
89
~
MaxParentsMCBayesNetGenerator
() {
90
GUM_DESTRUCTOR
(
MaxParentsMCBayesNetGenerator
);
91
}
92
93
template
<
typename
GUM_SCALAR
,
94
template
<
class
>
95
class
ICPTGenerator
,
96
template
<
class
>
97
class
ICPTDisturber
>
98
bool
MaxParentsMCBayesNetGenerator
<
GUM_SCALAR
,
ICPTGenerator
,
ICPTDisturber
>::
99
checkConditions__
() {
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
>
111
INLINE
Size
MaxParentsMCBayesNetGenerator
<
GUM_SCALAR
,
112
ICPTGenerator
,
113
ICPTDisturber
>::
maxParents
()
const
{
114
return
maxParents_
;
115
}
116
template
<
typename
GUM_SCALAR
,
117
template
<
class
>
118
class
ICPTGenerator
,
119
template
<
class
>
120
class
ICPTDisturber
>
121
INLINE
void
122
MaxParentsMCBayesNetGenerator
<
GUM_SCALAR
,
ICPTGenerator
,
ICPTDisturber
>::
123
setMaxParents
(
Size
maxParents
) {
124
if
(
maxParents
== 0)
125
GUM_ERROR
(
OperationNotAllowed
,
126
"maxParents must be at least equal to 1 to have a connexe graph"
);
127
128
maxParents_
=
maxParents
;
129
}
130
}
/* namespace gum */
gum::Set::emplace
INLINE void emplace(Args &&... args)
Definition:
set_tpl.h:669
MCBG
#define MCBG
Definition:
maxInducedWidthMCBayesNetGenerator_tpl.h:36