aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
maxParentsMCBayesNetGenerator_tpl.h
Go to the documentation of this file.
1
/****************************************************************************
2
* This file is part of the aGrUM/pyAgrum library. *
3
* *
4
* Copyright (c) 2005-2026 by *
5
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
6
* - Christophe GONZALES(_at_AMU) *
7
* *
8
* The aGrUM/pyAgrum library is free software; you can redistribute it *
9
* and/or modify it under the terms of either : *
10
* *
11
* - the GNU Lesser General Public License as published by *
12
* the Free Software Foundation, either version 3 of the License, *
13
* or (at your option) any later version, *
14
* - the MIT license (MIT), *
15
* - or both in dual license, as here. *
16
* *
17
* (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18
* *
19
* This aGrUM/pyAgrum library is distributed in the hope that it will be *
20
* useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26
* OTHER DEALINGS IN THE SOFTWARE. *
27
* *
28
* See LICENCES for more details. *
29
* *
30
* SPDX-FileCopyrightText: Copyright 2005-2026 *
31
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
32
* - Christophe GONZALES(_at_AMU) *
33
* SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34
* *
35
* Contact : info_at_agrum_dot_org *
36
* homepage : http://agrum.gitlab.io *
37
* gitlab : https://gitlab.com/agrumery/agrum *
38
* *
39
****************************************************************************/
40
41
#pragma once
42
43
50
51
#include <
agrum/BN/generator/maxParentsMCBayesNetGenerator.h
>
52
53
namespace
gum
{
54
55
// Default constructor.
56
// Use the SimpleCPTGenerator for generating the BNs CPT.
57
template
<
GUM_Numeric
GUM_SCALAR,
58
template
<
class
>
class
ICPTGenerator,
59
template
<
class
>
class
ICPTDisturber >
60
MaxParentsMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::
61
MaxParentsMCBayesNetGenerator
(
Size
nbrNodes
,
62
Size
maxArcs
,
63
Size
maxModality
,
64
Size
maxParents
,
65
Idx
iteration
,
66
Idx
p
,
67
Idx
q
) :
68
MCBayesNetGenerator
< GUM_SCALAR, ICPTGenerator, ICPTDisturber >(
nbrNodes
,
69
maxArcs
,
70
maxModality
,
71
iteration
,
72
p
,
73
q
) {
74
if
(
maxParents
== 0)
75
GUM_ERROR
(
OperationNotAllowed
,
76
"maxParents must be at least equal to 1 to have a connexe graph"
)
77
78
maxParents_
=
maxParents
;
79
GUM_CONSTRUCTOR(
MaxParentsMCBayesNetGenerator
);
80
}
81
82
template
<
GUM_Numeric
GUM_SCALAR,
83
template
<
class
>
class
ICPTGenerator,
84
template
<
class
>
class
ICPTDisturber >
85
MaxParentsMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::
86
MaxParentsMCBayesNetGenerator
(BayesNet< GUM_SCALAR > bayesNet,
87
Size
maxParents
,
88
Idx
iteration
,
89
Idx
p
,
90
Idx
q
) :
91
MCBayesNetGenerator
< GUM_SCALAR, ICPTGenerator, ICPTDisturber >(bayesNet,
iteration
,
p
,
q
) {
92
maxParents_
=
maxParents
;
93
GUM_CONSTRUCTOR(
MaxParentsMCBayesNetGenerator
);
94
}
95
96
// Destructor.
97
template
<
GUM_Numeric
GUM_SCALAR,
98
template
<
class
>
class
ICPTGenerator,
99
template
<
class
>
class
ICPTDisturber >
100
MaxParentsMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::
101
~MaxParentsMCBayesNetGenerator
() {
102
GUM_DESTRUCTOR(
MaxParentsMCBayesNetGenerator
);
103
}
104
105
template
<
GUM_Numeric
GUM_SCALAR,
106
template
<
class
>
class
ICPTGenerator,
107
template
<
class
>
class
ICPTDisturber >
108
bool
MaxParentsMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::
109
_checkConditions_
() {
110
for
(
auto
node: this->
dag_
.nodes())
111
if
(this->
dag_
.parents(node).size() >
maxParents_
)
return
false
;
112
113
return
MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_checkConditions_
();
114
}
115
116
template
<
GUM_Numeric
GUM_SCALAR,
117
template
<
class
>
class
ICPTGenerator,
118
template
<
class
>
class
ICPTDisturber >
119
Size
MaxParentsMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::maxParents
()
120
const
{
121
return
maxParents_
;
122
}
123
124
template
<
GUM_Numeric
GUM_SCALAR,
125
template
<
class
>
class
ICPTGenerator,
126
template
<
class
>
class
ICPTDisturber >
127
void
MaxParentsMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::setMaxParents
(
128
Size
maxParents
) {
129
if
(
maxParents
== 0)
130
GUM_ERROR
(
OperationNotAllowed
,
131
"maxParents must be at least equal to 1 to have a connexe graph"
)
132
133
maxParents_
=
maxParents
;
134
}
135
}
/* namespace gum */
gum::MCBayesNetGenerator< GUM_SCALAR, SimpleCPTGenerator, SimpleCPTDisturber >::nbrNodes
Size nbrNodes() const
Definition
IBayesNetGenerator_tpl.h:93
gum::MCBayesNetGenerator< GUM_SCALAR, SimpleCPTGenerator, SimpleCPTDisturber >::dag_
DAG dag_
Definition
IBayesNetGenerator.h:187
gum::MCBayesNetGenerator< GUM_SCALAR, SimpleCPTGenerator, SimpleCPTDisturber >::maxArcs
Size maxArcs() const
Definition
IBayesNetGenerator_tpl.h:98
gum::MCBayesNetGenerator< GUM_SCALAR, SimpleCPTGenerator, SimpleCPTDisturber >::maxModality
Size maxModality() const
Definition
IBayesNetGenerator_tpl.h:88
gum::MCBayesNetGenerator< GUM_SCALAR, SimpleCPTGenerator, SimpleCPTDisturber >::p
Idx p() const
Definition
MCBayesNetGenerator_tpl.h:603
gum::MCBayesNetGenerator< GUM_SCALAR, SimpleCPTGenerator, SimpleCPTDisturber >::MCBayesNetGenerator
MCBayesNetGenerator(Size nbrNodes, Size maxArcs, Idx maxModality=2, Size iteration=NB_INIT_ITERATIONS, Idx p=30, Idx q=40)
Definition
MCBayesNetGenerator_tpl.h:71
gum::MCBayesNetGenerator< GUM_SCALAR, SimpleCPTGenerator, SimpleCPTDisturber >::q
Idx q() const
Definition
MCBayesNetGenerator_tpl.h:610
gum::MCBayesNetGenerator::_checkConditions_
virtual bool _checkConditions_()
The boolean function that will assert the respect of the constraint.
Definition
MCBayesNetGenerator_tpl.h:183
gum::MCBayesNetGenerator< GUM_SCALAR, SimpleCPTGenerator, SimpleCPTDisturber >::iteration
Size iteration() const
Definition
MCBayesNetGenerator_tpl.h:596
gum::MaxParentsMCBayesNetGenerator::MaxParentsMCBayesNetGenerator
MaxParentsMCBayesNetGenerator(Size nbrNodes, Size maxArcs, Size maxModality=2, Size maxParents=1, Idx iteration=NB_INIT_ITERATIONS, Idx p=30, Idx q=40)
Constructor.
Definition
maxParentsMCBayesNetGenerator_tpl.h:61
gum::MaxParentsMCBayesNetGenerator::setMaxParents
void setMaxParents(Size maxParents)
Modifies the value of the number of maximum parents imposed on the BayesNetGenerator.
Definition
maxParentsMCBayesNetGenerator_tpl.h:127
gum::MaxParentsMCBayesNetGenerator::maxParents_
Size maxParents_
Definition
maxParentsMCBayesNetGenerator.h:187
gum::MaxParentsMCBayesNetGenerator::~MaxParentsMCBayesNetGenerator
~MaxParentsMCBayesNetGenerator() override
Destructor.
Definition
maxParentsMCBayesNetGenerator_tpl.h:101
gum::MaxParentsMCBayesNetGenerator::_checkConditions_
bool _checkConditions_() final
function to holding the specification wanted for the Bayesian network.
Definition
maxParentsMCBayesNetGenerator_tpl.h:109
gum::MaxParentsMCBayesNetGenerator::maxParents
Size maxParents() const
Return a constant reference to the number of maximum parents imposed on the Markov Chain BayesNetGene...
Definition
maxParentsMCBayesNetGenerator_tpl.h:119
OperationNotAllowed
Exception : operation not allowed.
gum::GUM_Numeric
Complete concept for GUM_SCALAR template parameter.
Definition
concepts.h:148
GUM_ERROR
#define GUM_ERROR(type, msg)
Definition
exceptions.h:76
gum::Size
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition
types.h:74
gum::Idx
Size Idx
Type for indexes.
Definition
types.h:79
maxParentsMCBayesNetGenerator.h
Class for generating Bayesian networks using MC algorithm cf.
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0