aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
orderedTriangulation.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 class for graph triangulations for which we enforce a given complete
24
* ordering on the nodes eliminations.
25
*
26
* @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
27
*/
28
29
#
include
<
agrum
/
agrum
.
h
>
30
31
#
include
<
agrum
/
tools
/
graphs
/
algorithms
/
triangulations
/
orderedTriangulation
.
h
>
32
33
namespace
gum
{
34
35
/// default constructor
36
OrderedTriangulation
::
OrderedTriangulation
(
const
OrderedEliminationSequenceStrategy
&
elimSeq
,
37
const
JunctionTreeStrategy
&
JTStrategy
,
38
bool
minimality
) :
39
StaticTriangulation
(
elimSeq
,
JTStrategy
,
minimality
) {
40
// for debugging purposes
41
GUM_CONSTRUCTOR
(
OrderedTriangulation
);
42
}
43
44
/// constructor with a given graph
45
OrderedTriangulation
::
OrderedTriangulation
(
const
UndiGraph
*
theGraph
,
46
const
NodeProperty
<
Size
>*
dom
,
47
const
std
::
vector
<
NodeId
>*
order
,
48
const
OrderedEliminationSequenceStrategy
&
elimSeq
,
49
const
JunctionTreeStrategy
&
JTStrategy
,
50
bool
minimality
) :
51
StaticTriangulation
(
theGraph
,
dom
,
elimSeq
,
JTStrategy
,
minimality
),
52
_order_
(
order
) {
53
static_cast
<
OrderedEliminationSequenceStrategy
* >(
elimination_sequence_strategy_
)
54
->
setOrder
(
_order_
);
55
56
// for debugging purposes
57
GUM_CONSTRUCTOR
(
OrderedTriangulation
);
58
}
59
60
// copy constructor
61
OrderedTriangulation
::
OrderedTriangulation
(
const
OrderedTriangulation
&
from
) :
62
StaticTriangulation
(
from
),
_order_
(
from
.
_order_
) {
// for debugging purposes
63
GUM_CONS_CPY
(
OrderedTriangulation
);
64
}
65
66
// move constructor
67
OrderedTriangulation
::
OrderedTriangulation
(
OrderedTriangulation
&&
from
) :
68
StaticTriangulation
(
std
::
move
(
from
)),
_order_
(
from
.
_order_
) {
69
// for debugging purposes
70
GUM_CONS_MOV
(
OrderedTriangulation
);
71
}
72
73
/// virtual copy constructor
74
OrderedTriangulation
*
OrderedTriangulation
::
newFactory
()
const
{
75
return
new
OrderedTriangulation
(
76
static_cast
<
const
OrderedEliminationSequenceStrategy
& >(*
elimination_sequence_strategy_
),
77
*
junction_tree_strategy_
);
78
}
79
80
/// virtual copy constructor
81
OrderedTriangulation
*
OrderedTriangulation
::
copyFactory
()
const
{
82
return
new
OrderedTriangulation
(*
this
);
83
}
84
85
/// destructor
86
OrderedTriangulation
::~
OrderedTriangulation
() {
87
// for debugging purposes
88
GUM_DESTRUCTOR
(
OrderedTriangulation
);
89
}
90
91
/// initialize the triangulation data structures for a new graph
92
void
OrderedTriangulation
::
setGraph
(
const
UndiGraph
*
graph
,
93
const
NodeProperty
<
Size
>*
domsizes
) {
94
StaticTriangulation
::
setGraph
(
graph
,
domsizes
);
95
static_cast
<
OrderedEliminationSequenceStrategy
* >(
elimination_sequence_strategy_
)
96
->
setOrder
(
_order_
);
97
}
98
99
/// sets the sequence of elimination
100
void
OrderedTriangulation
::
setOrder
(
const
std
::
vector
<
NodeId
>*
order
) {
101
_order_
=
order
;
102
static_cast
<
OrderedEliminationSequenceStrategy
* >(
elimination_sequence_strategy_
)
103
->
setOrder
(
_order_
);
104
}
105
106
/// the function called to initialize the triangulation process
107
void
OrderedTriangulation
::
initTriangulation_
(
UndiGraph
&
graph
) {
108
OrderedEliminationSequenceStrategy
*
elim
109
=
static_cast
<
OrderedEliminationSequenceStrategy
* >(
elimination_sequence_strategy_
);
110
elim
->
setGraph
(&
graph
,
domain_sizes_
);
111
elim
->
setOrder
(
_order_
);
112
}
113
114
}
/* namespace gum */
gum::Set::emplace
INLINE void emplace(Args &&... args)
Definition:
set_tpl.h:643