aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
structuralConstraintSliceOrder.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 structural constraint imposing a partial order over nodes
24
*
25
* In DBNs, it is forbidden to add arcs from nodes at time slice t to nodes at
26
* time slice s, where s < t. This class allows for taking this kind of
27
*constraint
28
* into account by imposing a partial order over the nodes: arcs (X,Y) can then
29
* only be added if X <= Y in the partial order.
30
* @warning: there may exist free variables, that is variables whose order
31
* w.r.t. the other variables is unspecified. In this case, arcs adjacent
32
* to them can be constructed. The partial order is specified by assigning
33
* numbers to nodes (through a NodeProperty). Nodes without number (i.e., that
34
* do not belong to the property) are free.
35
*
36
* @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
37
*/
38
39
#
include
<
agrum
/
BN
/
learning
/
constraints
/
structuralConstraintSliceOrder
.
h
>
40
41
/// include the inlined functions if necessary
42
#
ifdef
GUM_NO_INLINE
43
#
include
<
agrum
/
BN
/
learning
/
constraints
/
structuralConstraintSliceOrder_inl
.
h
>
44
#
endif
/* GUM_NO_INLINE */
45
46
namespace
gum
{
47
48
namespace
learning
{
49
50
/// default constructor
51
StructuralConstraintSliceOrder
::
StructuralConstraintSliceOrder
() {
52
GUM_CONSTRUCTOR
(
StructuralConstraintSliceOrder
);
53
}
54
55
/// constructor starting with an empty graph with a given number of nodes
56
StructuralConstraintSliceOrder
::
StructuralConstraintSliceOrder
(
57
const
NodeProperty
<
NodeId
>&
order
) {
58
for
(
auto
iter
=
order
.
cbegin
();
iter
!=
order
.
cend
(); ++
iter
) {
59
_DiGraph_graph_
.
addNodeWithId
(
iter
.
key
());
60
}
61
_SliceOrder_order_
=
order
;
62
63
GUM_CONSTRUCTOR
(
StructuralConstraintSliceOrder
);
64
}
65
66
/// constructor starting with a given graph
67
StructuralConstraintSliceOrder
::
StructuralConstraintSliceOrder
(
68
const
DiGraph
&
graph
,
69
const
NodeProperty
<
NodeId
>&
order
) :
70
StructuralConstraintDiGraph
(
graph
),
71
_SliceOrder_order_
(
order
) {
72
GUM_CONSTRUCTOR
(
StructuralConstraintSliceOrder
);
73
}
74
75
/// copy constructor
76
StructuralConstraintSliceOrder
::
StructuralConstraintSliceOrder
(
77
const
StructuralConstraintSliceOrder
&
from
) :
78
StructuralConstraintDiGraph
(
from
),
79
_SliceOrder_order_
(
from
.
_SliceOrder_order_
) {
80
GUM_CONS_CPY
(
StructuralConstraintSliceOrder
);
81
}
82
83
/// move constructor
84
StructuralConstraintSliceOrder
::
StructuralConstraintSliceOrder
(
85
StructuralConstraintSliceOrder
&&
from
) :
86
StructuralConstraintDiGraph
(
std
::
move
(
from
)),
87
_SliceOrder_order_
(
std
::
move
(
from
.
_SliceOrder_order_
)) {
88
GUM_CONS_MOV
(
StructuralConstraintSliceOrder
);
89
}
90
91
/// destructor
92
StructuralConstraintSliceOrder
::~
StructuralConstraintSliceOrder
() {
93
GUM_DESTRUCTOR
(
StructuralConstraintSliceOrder
);
94
}
95
96
/// copy operator
97
StructuralConstraintSliceOrder
&
98
StructuralConstraintSliceOrder
::
operator
=(
const
StructuralConstraintSliceOrder
&
from
) {
99
if
(
this
!= &
from
) {
100
StructuralConstraintDiGraph
::
operator
=(
from
);
101
_SliceOrder_order_
=
from
.
_SliceOrder_order_
;
102
}
103
return
*
this
;
104
}
105
106
/// move operator
107
StructuralConstraintSliceOrder
&
108
StructuralConstraintSliceOrder
::
operator
=(
StructuralConstraintSliceOrder
&&
from
) {
109
if
(
this
!= &
from
) {
110
StructuralConstraintDiGraph
::
operator
=(
std
::
move
(
from
));
111
_SliceOrder_order_
=
std
::
move
(
from
.
_SliceOrder_order_
);
112
}
113
return
*
this
;
114
}
115
116
}
/* namespace learning */
117
118
}
/* 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