aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
orderedTriangulation.cpp
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
48
49
#include <
agrum/agrum.h
>
50
51
#include <
agrum/base/graphs/algorithms/triangulations/orderedTriangulation.h
>
52
53
namespace
gum
{
54
56
OrderedTriangulation::OrderedTriangulation
(
const
OrderedEliminationSequenceStrategy
& elimSeq,
57
const
JunctionTreeStrategy
& JTStrategy,
58
bool
minimality) :
59
StaticTriangulation
(elimSeq, JTStrategy, minimality) {
60
// for debugging purposes
61
GUM_CONSTRUCTOR(
OrderedTriangulation
);
62
}
63
65
OrderedTriangulation::OrderedTriangulation
(
const
UndiGraph
* theGraph,
66
const
NodeProperty< Size >
* dom,
67
const
std::vector< NodeId >* order,
68
const
OrderedEliminationSequenceStrategy
& elimSeq,
69
const
JunctionTreeStrategy
& JTStrategy,
70
bool
minimality) :
71
StaticTriangulation
(theGraph, dom, elimSeq, JTStrategy, minimality),
_order_
(order) {
72
static_cast<
OrderedEliminationSequenceStrategy
*
>
(
elimination_sequence_strategy_
)
73
->
setOrder
(
_order_
);
74
75
// for debugging purposes
76
GUM_CONSTRUCTOR(
OrderedTriangulation
);
77
}
78
79
// copy constructor
80
OrderedTriangulation::OrderedTriangulation
(
const
OrderedTriangulation
& from) :
81
StaticTriangulation
(from),
_order_
(from.
_order_
) {
// for debugging purposes
82
GUM_CONS_CPY(
OrderedTriangulation
);
83
}
84
85
// move constructor
86
OrderedTriangulation::OrderedTriangulation
(
OrderedTriangulation
&& from) :
87
StaticTriangulation
(
std
::move(from)),
_order_
(from.
_order_
) {
88
// for debugging purposes
89
GUM_CONS_MOV(
OrderedTriangulation
);
90
}
91
93
OrderedTriangulation
*
OrderedTriangulation::newFactory
()
const
{
94
return
new
OrderedTriangulation
(
95
static_cast<
const
OrderedEliminationSequenceStrategy
&
>
(*
elimination_sequence_strategy_
),
96
*
junction_tree_strategy_
);
97
}
98
100
OrderedTriangulation
*
OrderedTriangulation::copyFactory
()
const
{
101
return
new
OrderedTriangulation
(*
this
);
102
}
103
105
OrderedTriangulation::~OrderedTriangulation
() {
106
// for debugging purposes
107
GUM_DESTRUCTOR(
OrderedTriangulation
);
108
}
109
111
void
OrderedTriangulation::setGraph
(
const
UndiGraph
*
graph
,
112
const
NodeProperty< Size >
* domsizes) {
113
StaticTriangulation::setGraph
(
graph
, domsizes);
114
static_cast<
OrderedEliminationSequenceStrategy
*
>
(
elimination_sequence_strategy_
)
115
->
setOrder
(
_order_
);
116
}
117
119
void
OrderedTriangulation::setOrder
(
const
std::vector< NodeId >* order) {
120
_order_
= order;
121
static_cast<
OrderedEliminationSequenceStrategy
*
>
(
elimination_sequence_strategy_
)
122
->
setOrder
(
_order_
);
123
}
124
126
void
OrderedTriangulation::initTriangulation_
(
UndiGraph
&
graph
) {
127
OrderedEliminationSequenceStrategy
* elim
128
=
static_cast<
OrderedEliminationSequenceStrategy
*
>
(
elimination_sequence_strategy_
);
129
elim->
setGraph
(&
graph
,
domain_sizes_
);
130
elim->
setOrder
(
_order_
);
131
}
132
133
}
/* namespace gum */
agrum.h
gum::JunctionTreeStrategy
Base Class for all the algorithms producing a junction given a set of cliques/subcliques resulting fr...
Definition
junctionTreeStrategy.h:66
gum::OrderedEliminationSequenceStrategy
An Elimination sequence algorithm that imposes a given complete ordering on the nodes elimination seq...
Definition
orderedEliminationSequenceStrategy.h:65
gum::OrderedEliminationSequenceStrategy::setGraph
bool setGraph(UndiGraph *graph, const NodeProperty< Size > *dom_sizes) final
sets a new graph to be triangulated
Definition
orderedEliminationSequenceStrategy.cpp:115
gum::OrderedEliminationSequenceStrategy::setOrder
virtual bool setOrder(const std::vector< NodeId > *order) final
sets the sequence of elimination
Definition
orderedEliminationSequenceStrategy.cpp:141
gum::OrderedTriangulation::~OrderedTriangulation
~OrderedTriangulation() override
destructor
Definition
orderedTriangulation.cpp:105
gum::OrderedTriangulation::setOrder
virtual void setOrder(const std::vector< NodeId > *order) final
sets the sequence of elimination (only the reference is stored)
Definition
orderedTriangulation.cpp:119
gum::OrderedTriangulation::_order_
const std::vector< NodeId > * _order_
the elimination sequence to apply
Definition
orderedTriangulation.h:171
gum::OrderedTriangulation::initTriangulation_
void initTriangulation_(UndiGraph &graph) final
the function called to initialize the triangulation process
Definition
orderedTriangulation.cpp:126
gum::OrderedTriangulation::OrderedTriangulation
OrderedTriangulation(const OrderedEliminationSequenceStrategy &elimSeq=OrderedEliminationSequenceStrategy(), const JunctionTreeStrategy &JTStrategy=DefaultJunctionTreeStrategy(), bool minimality=false)
default constructor
Definition
orderedTriangulation.cpp:56
gum::OrderedTriangulation::newFactory
OrderedTriangulation * newFactory() const final
returns a fresh triangulation over the same graph and of the same type as the current object (using t...
Definition
orderedTriangulation.cpp:93
gum::OrderedTriangulation::setGraph
void setGraph(const UndiGraph *graph, const NodeProperty< Size > *domsizes) final
initialize the triangulation data structures for a new graph
Definition
orderedTriangulation.cpp:111
gum::OrderedTriangulation::copyFactory
OrderedTriangulation * copyFactory() const final
virtual copy constructor
Definition
orderedTriangulation.cpp:100
gum::StaticTriangulation::junction_tree_strategy_
JunctionTreeStrategy * junction_tree_strategy_
the junction tree strategy used by the triangulation
Definition
staticTriangulation.h:250
gum::StaticTriangulation::StaticTriangulation
StaticTriangulation(const EliminationSequenceStrategy &elimSeq, const JunctionTreeStrategy &JTStrategy, bool minimality=false)
default constructor: without any graph
Definition
staticTriangulation.cpp:86
gum::StaticTriangulation::elimination_sequence_strategy_
EliminationSequenceStrategy * elimination_sequence_strategy_
the elimination sequence strategy used by the triangulation
Definition
staticTriangulation.h:247
gum::StaticTriangulation::setGraph
void setGraph(const UndiGraph *graph, const NodeProperty< Size > *domsizes) override
initialize the triangulation data structures for a new graph
Definition
staticTriangulation.cpp:524
gum::Triangulation::domain_sizes_
const NodeProperty< Size > * domain_sizes_
the domain sizes of the variables/nodes of the graph
Definition
triangulation.h:170
gum::UndiGraph
Base class for undirected graphs.
Definition
undiGraph.h:130
gum::NodeProperty
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
Definition
graphElements.h:407
gum::graph
Definition
bayesBall.h:79
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
std
STL namespace.
orderedTriangulation.h
class for graph triangulations for which we enforce a given complete ordering on the nodes eliminatio...
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0