aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
orderedTriangulation.h
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 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 #ifndef GUM_ORDERED_TRIANGULATION_H
29 #define GUM_ORDERED_TRIANGULATION_H
30 
31 #include <vector>
32 
33 #include <agrum/tools/graphs/algorithms/triangulations/eliminationStrategies/orderedEliminationSequenceStrategy.h>
34 #include <agrum/tools/graphs/algorithms/triangulations/junctionTreeStrategies/defaultJunctionTreeStrategy.h>
35 #include <agrum/tools/graphs/algorithms/triangulations/staticTriangulation.h>
36 
37 namespace gum {
38 
39 
40  /** @class OrderedTriangulation
41  * @brief class for graph triangulations for which we enforce a given complete
42  * ordering on the nodes eliminations.
43  *
44  * \ingroup graph_group
45  *
46  */
48  public:
49  // ############################################################################
50  /// @name Constructors / Destructors
51  // ############################################################################
52  /// @{
53 
54  /// default constructor
55  /** @param elimSeq the elimination sequence used to triangulate the graph
56  * @param JTStrategy the junction tree strategy used to create junction
57  * trees
58  * @param minimality a Boolean indicating whether we should enforce that
59  * the triangulation is minimal w.r.t. inclusion */
60  OrderedTriangulation(const OrderedEliminationSequenceStrategy& elimSeq
62  const JunctionTreeStrategy& JTStrategy
64  bool minimality = false);
65 
66  /// constructor with a given graph
67  /** @param graph the graph to be triangulated, i.e., the nodes of which will
68  * be eliminated
69  * @param domsizes the domain sizes of the nodes to be eliminated
70  * @param sequence the order in which the nodes should be eliminated
71  * @param elimSeq the elimination sequence used to triangulate the graph.
72  * Only a reference/pointer to the sequence passed in argument is kept in
73  * the current class.
74  * @param JTStrategy the junction tree strategy used to create junction
75  * trees
76  * @param minimality a Boolean indicating whether we should enforce that
77  * the triangulation is minimal w.r.t. inclusion
78  * @warning Note that we allow dom_sizes to be defined over nodes/variables
79  * that do not belong to graph. These sizes will simply be ignored. However,
80  * it is compulsory that all the nodes of graph belong to dom_sizes
81  * @warning note that, by aGrUM's rule, the graph, the domain sizes and the
82  * elimination sequence are not copied but only referenced by the
83  * triangulation algorithm. */
84  OrderedTriangulation(const UndiGraph* graph,
85  const NodeProperty< Size >* domsizes,
86  const std::vector< NodeId >* sequence,
87  const OrderedEliminationSequenceStrategy& elimSeq
89  const JunctionTreeStrategy& JTStrategy
91  bool minimality = false);
92 
93  /// copy constructor
95 
96  /// move constructor
98 
99  /** @brief returns a fresh triangulation over the same graph and of the same
100  * type as the current object (using the same sequence, etc.)
101  *
102  * note that we return a pointer as it enables subclasses to return
103  * pointers to their types, not Triangulation pointers. See item 25 of the
104  * more effective C++.*/
105  virtual OrderedTriangulation* newFactory() const final;
106 
107  /// virtual copy constructor
108  virtual OrderedTriangulation* copyFactory() const final;
109 
110  /// destructor
111  virtual ~OrderedTriangulation();
112 
113  /// @}
114 
115  // ############################################################################
116  /// @name Accessors / Modifiers
117  // ############################################################################
118  /// @{
119 
120  /// initialize the triangulation data structures for a new graph
121  /** @param graph the graph to be triangulated, i.e., the nodes of which will
122  * be eliminated
123  * @param domsizes the domain sizes of the nodes to be eliminated
124  * @param sequence the order in which the nodes should be eliminated
125  * @warning note that, by aGrUM's rule, the graph and the domain sizes are
126  * not
127  * notcopied but only referenced by the triangulation algorithm. */
128  virtual void setGraph(const UndiGraph* graph,
129  const NodeProperty< Size >* domsizes) final;
130 
131  /// sets the sequence of elimination (only the reference is stored)
132  /** The elimination sequence is kept outside this class for efficiency
133  * reasons. */
134  virtual void setOrder(const std::vector< NodeId >* order) final;
135 
136  /// @}
137 
138  protected:
139  /// the function called to initialize the triangulation process
140  /** This function is called when the triangulation process starts and is
141  * used to initialize the elimination sequence strategy. Actually, the
142  * graph that is modified by the triangulation algorithm is a copy of
143  * the original graph, and this copy need be known by the elimination
144  * sequence strategy. initTriangulation_ is used to transmit this
145  * knowledge to the elimination sequence (through method setGraph of the
146  * elimination sequence class).
147  * @param graph the very graph that is triangulated (this is a copy of
148  * original_graph_) */
149  virtual void initTriangulation_(UndiGraph& graph) final;
150 
151 
152  /// the elimination sequence to apply
153  /** @warning order__ is not owned by the orderedTriangulation class */
154  const std::vector< NodeId >* order__{nullptr};
155 
156  /// @}
157 
158  private:
159  /// forbid copy operator
161  };
162 
163 } /* namespace gum */
164 
165 #endif /* GUM_ORDERED_TRIANGULATION_H */
virtual ~OrderedTriangulation()
destructor
OrderedTriangulation(const OrderedTriangulation &from)
copy constructor
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:669
OrderedTriangulation(const UndiGraph *graph, const NodeProperty< Size > *domsizes, const std::vector< NodeId > *sequence, const OrderedEliminationSequenceStrategy &elimSeq=OrderedEliminationSequenceStrategy(), const JunctionTreeStrategy &JTStrategy=DefaultJunctionTreeStrategy(), bool minimality=false)
constructor with a given graph
OrderedTriangulation(const OrderedEliminationSequenceStrategy &elimSeq=OrderedEliminationSequenceStrategy(), const JunctionTreeStrategy &JTStrategy=DefaultJunctionTreeStrategy(), bool minimality=false)
default constructor
OrderedTriangulation(OrderedTriangulation &&from)
move constructor
virtual OrderedTriangulation * copyFactory() const final
virtual copy constructor
virtual void initTriangulation_(UndiGraph &graph) final
the function called to initialize the triangulation process
virtual void setOrder(const std::vector< NodeId > *order) final
sets the sequence of elimination (only the reference is stored)
OrderedTriangulation & operator=(const OrderedTriangulation &)
forbid copy operator
virtual OrderedTriangulation * newFactory() const final
returns a fresh triangulation over the same graph and of the same type as the current object (using t...
class for graph triangulations for which we enforce a given complete ordering on the nodes eliminatio...
const std::vector< NodeId > * order__
the elimination sequence to apply
virtual void setGraph(const UndiGraph *graph, const NodeProperty< Size > *domsizes) final
initialize the triangulation data structures for a new graph