aGrUM
0.20.2
a C++ library for (probabilistic) graphical models
structuralConstraintIndegree.cpp
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 the class for structural constraints limiting the number of parents
24
* of nodes in a directed graph
25
*
26
* @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
27
*/
28
29
#
include
<
agrum
/
BN
/
learning
/
constraints
/
structuralConstraintIndegree
.
h
>
30
31
/// include the inlined functions if necessary
32
#
ifdef
GUM_NO_INLINE
33
#
include
<
agrum
/
BN
/
learning
/
constraints
/
structuralConstraintIndegree_inl
.
h
>
34
#
endif
/* GUM_NO_INLINE */
35
36
namespace
gum
{
37
38
namespace
learning
{
39
40
/// default constructor
41
StructuralConstraintIndegree
::
StructuralConstraintIndegree
() {
42
GUM_CONSTRUCTOR
(
StructuralConstraintIndegree
);
43
}
44
45
/// constructor starting with an empty graph with a given number of nodes
46
StructuralConstraintIndegree
::
StructuralConstraintIndegree
(
Size
nb_nodes
,
47
Size
max_indegree
) :
48
StructuralConstraintDiGraph
(
nb_nodes
),
49
Indegree__max_indegree_
(
max_indegree
) {
50
for
(
NodeId
i
= 0;
i
<
nb_nodes
; ++
i
) {
51
Indegree__max_parents_
.
insert
(
i
,
max_indegree
);
52
}
53
GUM_CONSTRUCTOR
(
StructuralConstraintIndegree
);
54
}
55
56
/// constructor starting with a given graph
57
StructuralConstraintIndegree
::
StructuralConstraintIndegree
(
58
const
DiGraph
&
graph
,
59
Size
max_indegree
) :
60
StructuralConstraintDiGraph
(
graph
),
61
Indegree__max_indegree_
(
max_indegree
) {
62
for
(
const
auto
id
:
graph
) {
63
Indegree__max_parents_
.
insert
(
id
,
max_indegree
);
64
}
65
GUM_CONSTRUCTOR
(
StructuralConstraintIndegree
);
66
}
67
68
/// copy constructor
69
StructuralConstraintIndegree
::
StructuralConstraintIndegree
(
70
const
StructuralConstraintIndegree
&
from
) :
71
StructuralConstraintDiGraph
(
from
),
72
Indegree__max_parents_
(
from
.
Indegree__max_parents_
),
73
Indegree__max_indegree_
(
from
.
Indegree__max_indegree_
) {
74
GUM_CONS_CPY
(
StructuralConstraintIndegree
);
75
}
76
77
/// move constructor
78
StructuralConstraintIndegree
::
StructuralConstraintIndegree
(
79
StructuralConstraintIndegree
&&
from
) :
80
StructuralConstraintDiGraph
(
std
::
move
(
from
)),
81
Indegree__max_parents_
(
std
::
move
(
from
.
Indegree__max_parents_
)),
82
Indegree__max_indegree_
(
std
::
move
(
from
.
Indegree__max_indegree_
)) {
83
GUM_CONS_MOV
(
StructuralConstraintIndegree
);
84
}
85
86
/// destructor
87
StructuralConstraintIndegree
::~
StructuralConstraintIndegree
() {
88
GUM_DESTRUCTOR
(
StructuralConstraintIndegree
);
89
}
90
91
/// copy operator
92
StructuralConstraintIndegree
&
StructuralConstraintIndegree
::
operator
=(
93
const
StructuralConstraintIndegree
&
from
) {
94
if
(
this
!= &
from
) {
95
StructuralConstraintDiGraph
::
operator
=(
from
);
96
Indegree__max_parents_
=
from
.
Indegree__max_parents_
;
97
Indegree__max_indegree_
=
from
.
Indegree__max_indegree_
;
98
}
99
100
return
*
this
;
101
}
102
103
/// move operator
104
StructuralConstraintIndegree
&
StructuralConstraintIndegree
::
operator
=(
105
StructuralConstraintIndegree
&&
from
) {
106
if
(
this
!= &
from
) {
107
StructuralConstraintDiGraph
::
operator
=(
std
::
move
(
from
));
108
Indegree__max_parents_
=
std
::
move
(
from
.
Indegree__max_parents_
);
109
Indegree__max_indegree_
=
std
::
move
(
from
.
Indegree__max_indegree_
);
110
}
111
112
return
*
this
;
113
}
114
115
}
/* namespace learning */
116
117
}
/* namespace gum */
gum::Set::emplace
INLINE void emplace(Args &&... args)
Definition:
set_tpl.h:669
gum::learning::genericBNLearner::Database::Database
Database(const std::string &filename, const BayesNet< GUM_SCALAR > &bn, const std::vector< std::string > &missing_symbols)
Definition:
genericBNLearner_tpl.h:31