aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
partialOrderedEliminationSequenceStrategy.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 Base class for all elimination sequence algorithm that impose a given
24  * partial ordering on the nodes elimination sequence, that is, the set of all
25  * the nodes is divided into several subsets. Within each subset, any ordering
26  * can be chosen. But all the nodes of the first subset must be eliminated
27  * before the nodes of the second, which must be eliminated before those of the
28  * third subset, and so on.
29  *
30  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
31  */
32 
33 #include <agrum/tools/graphs/algorithms/triangulations/eliminationStrategies/partialOrderedEliminationSequenceStrategy.h>
34 
35 #ifdef GUM_NO_INLINE
36 # include <agrum/tools/graphs/algorithms/triangulations/eliminationStrategies/partialOrderedEliminationSequenceStrategy_inl.h>
37 #endif // GUM_NOINLINE
38 
39 namespace gum {
40 
41  /// default constructor
43  // for debugging purposes
45  }
46 
47  /// constructor for an a priori non empty graph
50  const NodeProperty< Size >* dom_sizes,
51  const List< NodeSet >* subsets) {
54 
55  // for debugging purposes
57  }
58 
59  /// copy constructor
65  // for debugging purposes
67  }
68 
69  /// move constructor
76 
77  // for debugging purposes
79  }
80 
81  /// destructor
83  // for debugging purposes
85  }
86 
87  /// sets a new graph to be triangulated
88  bool
90  const NodeProperty< Size >* domain_sizes) {
93  return true;
94  }
95  return false;
96  }
97 
98  /// indicate whether a partial ordering is compatible with the current graph
100  const List< NodeSet >* subsets) const {
101  if ((graph_ == nullptr) || (subsets == nullptr)) return true;
102 
103  // determine the set of nodes in the subsets that belong to the graph
104  NodeSet nodes_found(graph_->size() / 2);
105  for (const auto& nodes: *subsets) {
106  for (const auto node: nodes) {
108  }
109  }
110 
111  // check that the size of nodes_found is equal to that of the graph
112  return nodes_found.size() != graph_->size();
113  }
114 
115  /// sets a new partial order
117  // check that the partial order contains all the nodes of the graph
119 
120  if (!partial_order_needed_) {
121  subsets_ = subsets;
122 
123  // initialize properly the set of nodes that can be currently eliminated:
124  // find the first subset that contains some node(s) of the graph
125  nodeset_.clear();
127  for (const auto node: *subset_iter_) {
129  }
130  if (!nodeset_.empty()) return true;
131  }
132  }
133 
134  return false;
135  }
136 
137  /// clears the sequence (to prepare, for instance, a new elimination sequence)
140  subsets_ = nullptr;
141  nodeset_.clear();
142  partial_order_needed_ = true;
143  }
144 
145 } /* namespace gum */
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643