aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
structuralConstraintIndegree.cpp
Go to the documentation of this file.
1
/**
2
*
3
* Copyright (c) 2005-2021 by 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
,
Size
max_indegree
) :
47
StructuralConstraintDiGraph
(
nb_nodes
),
_Indegree_max_indegree_
(
max_indegree
) {
48
for
(
NodeId
i
= 0;
i
<
nb_nodes
; ++
i
) {
49
_Indegree_max_parents_
.
insert
(
i
,
max_indegree
);
50
}
51
GUM_CONSTRUCTOR
(
StructuralConstraintIndegree
);
52
}
53
54
/// constructor starting with a given graph
55
StructuralConstraintIndegree
::
StructuralConstraintIndegree
(
const
DiGraph
&
graph
,
56
Size
max_indegree
) :
57
StructuralConstraintDiGraph
(
graph
),
58
_Indegree_max_indegree_
(
max_indegree
) {
59
for
(
const
auto
id
:
graph
) {
60
_Indegree_max_parents_
.
insert
(
id
,
max_indegree
);
61
}
62
GUM_CONSTRUCTOR
(
StructuralConstraintIndegree
);
63
}
64
65
/// copy constructor
66
StructuralConstraintIndegree
::
StructuralConstraintIndegree
(
67
const
StructuralConstraintIndegree
&
from
) :
68
StructuralConstraintDiGraph
(
from
),
69
_Indegree_max_parents_
(
from
.
_Indegree_max_parents_
),
70
_Indegree_max_indegree_
(
from
.
_Indegree_max_indegree_
) {
71
GUM_CONS_CPY
(
StructuralConstraintIndegree
);
72
}
73
74
/// move constructor
75
StructuralConstraintIndegree
::
StructuralConstraintIndegree
(
76
StructuralConstraintIndegree
&&
from
) :
77
StructuralConstraintDiGraph
(
std
::
move
(
from
)),
78
_Indegree_max_parents_
(
std
::
move
(
from
.
_Indegree_max_parents_
)),
79
_Indegree_max_indegree_
(
std
::
move
(
from
.
_Indegree_max_indegree_
)) {
80
GUM_CONS_MOV
(
StructuralConstraintIndegree
);
81
}
82
83
/// destructor
84
StructuralConstraintIndegree
::~
StructuralConstraintIndegree
() {
85
GUM_DESTRUCTOR
(
StructuralConstraintIndegree
);
86
}
87
88
/// copy operator
89
StructuralConstraintIndegree
&
90
StructuralConstraintIndegree
::
operator
=(
const
StructuralConstraintIndegree
&
from
) {
91
if
(
this
!= &
from
) {
92
StructuralConstraintDiGraph
::
operator
=(
from
);
93
_Indegree_max_parents_
=
from
.
_Indegree_max_parents_
;
94
_Indegree_max_indegree_
=
from
.
_Indegree_max_indegree_
;
95
}
96
97
return
*
this
;
98
}
99
100
/// move operator
101
StructuralConstraintIndegree
&
102
StructuralConstraintIndegree
::
operator
=(
StructuralConstraintIndegree
&&
from
) {
103
if
(
this
!= &
from
) {
104
StructuralConstraintDiGraph
::
operator
=(
std
::
move
(
from
));
105
_Indegree_max_parents_
=
std
::
move
(
from
.
_Indegree_max_parents_
);
106
_Indegree_max_indegree_
=
std
::
move
(
from
.
_Indegree_max_indegree_
);
107
}
108
109
return
*
this
;
110
}
111
112
}
/* namespace learning */
113
114
}
/* namespace gum */
gum::Set::emplace
INLINE void emplace(Args &&... args)
Definition:
set_tpl.h:643
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