aGrUM 3.0.0
a C++ library for (probabilistic) graphical models
gum::DefaultPartialOrderedEliminationSequenceStrategy Class Reference

An Elimination sequence algorithm that imposes a given partial ordering on the nodes elimination sequence. More...

#include <defaultPartialOrderedEliminationSequenceStrategy.h>

Inheritance diagram for gum::DefaultPartialOrderedEliminationSequenceStrategy:
Collaboration diagram for gum::DefaultPartialOrderedEliminationSequenceStrategy:

Public Member Functions

Constructors / Destructors
 DefaultPartialOrderedEliminationSequenceStrategy (double theRatio=GUM_QUASI_RATIO, double theThreshold=GUM_WEIGHT_THRESHOLD)
 default constructor (uses an empty graph)
 DefaultPartialOrderedEliminationSequenceStrategy (UndiGraph *graph, const NodeProperty< Size > *dom_sizes, const List< NodeSet > *subsets, double ratio=GUM_QUASI_RATIO, double threshold=GUM_WEIGHT_THRESHOLD)
 constructor for a (tensorly) non empty graph
 DefaultPartialOrderedEliminationSequenceStrategy (const DefaultPartialOrderedEliminationSequenceStrategy &from)
 copy constructor
 DefaultPartialOrderedEliminationSequenceStrategy (DefaultPartialOrderedEliminationSequenceStrategy &&from)
 move constructor
 ~DefaultPartialOrderedEliminationSequenceStrategy () override
 destructor
DefaultPartialOrderedEliminationSequenceStrategynewFactory () const final
 creates a new elimination sequence of the same type as the current object, but this sequence contains only an empty graph
DefaultPartialOrderedEliminationSequenceStrategycopyFactory () const final
 virtual copy constructor
Accessors / Modifiers
bool setGraph (UndiGraph *graph, const NodeProperty< Size > *dom_sizes) final
 sets a new graph to be triangulated
void clear () final
 clears the sequence (to prepare, for instance, a new elimination sequence)
NodeId nextNodeToEliminate () final
 returns the new node to be eliminated within the triangulation algorithm
void askFillIns (bool do_it) final
 if the elimination sequence is able to compute fill-ins, we indicate whether we want this feature to be activated
bool providesFillIns () const final
 indicates whether the fill-ins generated by the eliminated nodes, if needed, will be computed by the elimination sequence, or need be computed by the triangulation itself.
bool providesGraphUpdate () const final
 indicates whether the elimination sequence updates by itself the graph after a node has been eliminated
void eliminationUpdate (const NodeId node) final
 performs all the graph/fill-ins updates provided (if any)
const EdgeSetfillIns () final
 in case fill-ins are provided, this function returns the fill-ins due to all the nodes eliminated so far
Accessors / Modifiers
virtual bool setPartialOrder (const List< NodeSet > *subsets)
 sets a new partial ordering constraint on the elimination sequence
const List< NodeSet > * partialOrder () const noexcept
 returns the current partial ordering
bool isPartialOrderNeeded () const noexcept
 indicates if a new partial ordering is needed
Accessors / Modifiers
UndiGraphgraph () const noexcept
 returns the current graph
const NodeProperty< Size > * domainSizes () const noexcept
 returns the current domain sizes

Protected Member Functions

bool isPartialOrderNeeded_ (const List< NodeSet > *subsets) const
 indicate whether a partial ordering is compatible with the current graph

Protected Attributes

const List< NodeSet > * subsets_ {nullptr}
 the subsets constituting the partial ordering
List< NodeSet >::const_iterator subset_iter_
 the iterator indicating which is the current subset on which we work
NodeSet nodeset_
 the nodes which can be currently eliminated
bool partial_order_needed_ {true}
 indicate whether a new partial ordering is necessary for the elimination
UndiGraphgraph_ {nullptr}
 the graph to be triangulated
const NodeProperty< Size > * domain_sizes_ {nullptr}
 the domain sizes of the variables/nodes
NodeProperty< doublelog_domain_sizes_
 the log of the domain sizes of the variables/nodes

Private Member Functions

NodeId _nodeToEliminate_ (const PriorityQueue< NodeId, double > &possibleNodes)
 returns the best possible node to be eliminated
void _createSimplicialSet_ ()
 create a new simplicial set suited for the current graph

Static Private Member Functions

static const EdgeSet_empty_fill_ins_ ()
 an empty fill-ins set used by default

Private Attributes

NodeProperty< double_log_weights_
 for each node, the weight of the clique created by the node's elimination
SimplicialSet_simplicial_set_ {nullptr}
 the simplicial set used for determining the best nodes to eliminate
double _simplicial_ratio_
 the ratio used by simplicial_set for its quasi-simplicial nodes
double _simplicial_threshold_
 the threshold used by simplicial_set to determine small cliques
bool _provide_fill_ins_ {false}
 indicates whether we compute new fill-ins

Detailed Description

An Elimination sequence algorithm that imposes a given partial ordering on the nodes elimination sequence.

Class DefaultPartialOrderedEliminationSequenceStrategy implements an elimination sequence algorithm that satisfies a partial ordering, that is, the set of all the nodes is divided into several subsets. All the nodes of the first subset must be eliminated before the nodes of the second, which must be eliminated before those of the third subset, and so on. Within a subset, the ordering is determined as follows:

the nodes that are simplicial (i.e., those that already form a clique

with their neighbors) are eliminated first

then the nodes that are almost simplicial (i.e. if we remove one of their

neighbors, they become simplicial) and that create small cliques, are eliminated (see Bodlaender's safe reductions)

the quasi simplicial nodes (i.e., the nodes that do not require many

fill-ins to create cliques) that would create small cliques, are eliminated

finally, the heuristic proposed by Kjaerulff(90) is used to compute the

last nodes to be eliminated.

Definition at line 99 of file defaultPartialOrderedEliminationSequenceStrategy.h.

Constructor & Destructor Documentation

◆ DefaultPartialOrderedEliminationSequenceStrategy() [1/4]

gum::DefaultPartialOrderedEliminationSequenceStrategy::DefaultPartialOrderedEliminationSequenceStrategy ( double theRatio = GUM_QUASI_RATIO,
double theThreshold = GUM_WEIGHT_THRESHOLD )

default constructor (uses an empty graph)

Parameters
theRatiothe ratio used by the SimplicialSet included in the DefaultEliminationSequenceStrategy
theThresholdthe weight threshhold of the SimplicialSet included in the DefaultEliminationSequenceStrategy

Definition at line 58 of file defaultPartialOrderedEliminationSequenceStrategy.cpp.

59 :
60 _simplicial_ratio_(theRatio), _simplicial_threshold_(theThreshold) {
61 // for debugging purposes
63 }
double _simplicial_threshold_
the threshold used by simplicial_set to determine small cliques
double _simplicial_ratio_
the ratio used by simplicial_set for its quasi-simplicial nodes
DefaultPartialOrderedEliminationSequenceStrategy(double theRatio=GUM_QUASI_RATIO, double theThreshold=GUM_WEIGHT_THRESHOLD)
default constructor (uses an empty graph)

References DefaultPartialOrderedEliminationSequenceStrategy(), _simplicial_ratio_, and _simplicial_threshold_.

Referenced by DefaultPartialOrderedEliminationSequenceStrategy(), DefaultPartialOrderedEliminationSequenceStrategy(), DefaultPartialOrderedEliminationSequenceStrategy(), DefaultPartialOrderedEliminationSequenceStrategy(), ~DefaultPartialOrderedEliminationSequenceStrategy(), copyFactory(), and newFactory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DefaultPartialOrderedEliminationSequenceStrategy() [2/4]

gum::DefaultPartialOrderedEliminationSequenceStrategy::DefaultPartialOrderedEliminationSequenceStrategy ( UndiGraph * graph,
const NodeProperty< Size > * dom_sizes,
const List< NodeSet > * subsets,
double ratio = GUM_QUASI_RATIO,
double threshold = GUM_WEIGHT_THRESHOLD )

constructor for a (tensorly) non empty graph

Parameters
graphthe graph to be triangulated, i.e., the nodes of which will be eliminated
dom_sizesthedomain sizes of the nodes/variables
subsetsthe list of the subsets constituting the partial ordering
ratiothe ratio used by the SimplicialSet included in the DefaultEliminationSequenceStrategy
thresholdthe weight threshhold of the SimplicialSet included in the DefaultEliminationSequenceStrategy
Warning
Note that we allow dom_sizes to be defined over nodes/variables that do not belong to graph. These sizes will simply be ignored. However, it is compulsory that all the nodes of graph belong to dom_sizes
the graph is altered during the triangulation.
note that, by aGrUM's rule, the graph, the domain sizes and the sequence are not copied but only referenced by the elimination sequence algorithm.

Definition at line 66 of file defaultPartialOrderedEliminationSequenceStrategy.cpp.

71 :
73 setGraph(graph, dom_sizes);
74 setPartialOrder(subsets);
75
76 // for debugging purposes
78 }
bool setGraph(UndiGraph *graph, const NodeProperty< Size > *dom_sizes) final
sets a new graph to be triangulated
UndiGraph * graph() const noexcept
returns the current graph
virtual bool setPartialOrder(const List< NodeSet > *subsets)
sets a new partial ordering constraint on the elimination sequence

References DefaultPartialOrderedEliminationSequenceStrategy(), _simplicial_ratio_, _simplicial_threshold_, setGraph(), and gum::PartialOrderedEliminationSequenceStrategy::setPartialOrder().

Here is the call graph for this function:

◆ DefaultPartialOrderedEliminationSequenceStrategy() [3/4]

gum::DefaultPartialOrderedEliminationSequenceStrategy::DefaultPartialOrderedEliminationSequenceStrategy ( const DefaultPartialOrderedEliminationSequenceStrategy & from)

copy constructor

Warning
The newly created elimination sequence strategy points toward the same undirected graph as the one contained in from but each strategy possesses its own simplicial set. As a result, if both elimination strategies are used at the same time, they will probably result in a mess because their simplicial sets won't be synchronized correctly with the changing undirected graph. So, whenever using this copy constructor, be sure that either from or the newly created strategy is used for a triangulation but not both. This will necessarily be OK in DefaultTriangulations.

Definition at line 81 of file defaultPartialOrderedEliminationSequenceStrategy.cpp.

83 :
85 // no need to set _log_weights_ because the copy of the simplicial set
86 // will set it properly
87 _simplicial_set_(new SimplicialSet(*from._simplicial_set_,
88 graph_,
91 false)),
92 _simplicial_ratio_(from._simplicial_ratio_),
93 _simplicial_threshold_(from._simplicial_threshold_),
94 _provide_fill_ins_(from._provide_fill_ins_) {
95 // for debugging purposes
97 }
NodeProperty< double > _log_weights_
for each node, the weight of the clique created by the node's elimination
SimplicialSet * _simplicial_set_
the simplicial set used for determining the best nodes to eliminate
NodeProperty< double > log_domain_sizes_
the log of the domain sizes of the variables/nodes
UndiGraph * graph_
the graph to be triangulated
PartialOrderedEliminationSequenceStrategy()
default constructor (uses an empty graph)

References DefaultPartialOrderedEliminationSequenceStrategy(), gum::PartialOrderedEliminationSequenceStrategy::PartialOrderedEliminationSequenceStrategy(), _log_weights_, _provide_fill_ins_, _simplicial_ratio_, _simplicial_set_, _simplicial_threshold_, gum::EliminationSequenceStrategy::graph_, and gum::EliminationSequenceStrategy::log_domain_sizes_.

Here is the call graph for this function:

◆ DefaultPartialOrderedEliminationSequenceStrategy() [4/4]

gum::DefaultPartialOrderedEliminationSequenceStrategy::DefaultPartialOrderedEliminationSequenceStrategy ( DefaultPartialOrderedEliminationSequenceStrategy && from)

move constructor

Definition at line 100 of file defaultPartialOrderedEliminationSequenceStrategy.cpp.

102 :
104 _log_weights_(std::move(from._log_weights_)), _simplicial_set_(from._simplicial_set_),
105 _simplicial_ratio_(from._simplicial_ratio_),
106 _simplicial_threshold_(from._simplicial_threshold_),
107 _provide_fill_ins_(from._provide_fill_ins_) {
108 _simplicial_set_->replaceLogWeights(&from._log_weights_, &_log_weights_);
109 from._simplicial_set_ = nullptr;
110
111 // for debugging purposes
113 }

References DefaultPartialOrderedEliminationSequenceStrategy(), gum::PartialOrderedEliminationSequenceStrategy::PartialOrderedEliminationSequenceStrategy(), _log_weights_, _provide_fill_ins_, _simplicial_ratio_, _simplicial_set_, and _simplicial_threshold_.

Here is the call graph for this function:

◆ ~DefaultPartialOrderedEliminationSequenceStrategy()

gum::DefaultPartialOrderedEliminationSequenceStrategy::~DefaultPartialOrderedEliminationSequenceStrategy ( )
override

destructor

Definition at line 116 of file defaultPartialOrderedEliminationSequenceStrategy.cpp.

117 {
118 // for debugging purposes
120
122 }

References DefaultPartialOrderedEliminationSequenceStrategy(), and _simplicial_set_.

Here is the call graph for this function:

Member Function Documentation

◆ _createSimplicialSet_()

void gum::DefaultPartialOrderedEliminationSequenceStrategy::_createSimplicialSet_ ( )
private

create a new simplicial set suited for the current graph

Definition at line 125 of file defaultPartialOrderedEliminationSequenceStrategy.cpp.

125 {
126 // remove the old simplicial set, if any
127 if (_simplicial_set_ != nullptr) {
128 delete _simplicial_set_;
129 _simplicial_set_ = nullptr;
130 }
131
132 if (graph_ != nullptr) {
133 // create a simplicial set suited for the graph
134 _simplicial_set_ = new SimplicialSet(graph_,
139
141 }
142 }

References _log_weights_, _provide_fill_ins_, _simplicial_ratio_, _simplicial_set_, _simplicial_threshold_, gum::EliminationSequenceStrategy::graph_, and gum::EliminationSequenceStrategy::log_domain_sizes_.

Referenced by setGraph().

Here is the caller graph for this function:

◆ _empty_fill_ins_()

const EdgeSet & gum::EliminationSequenceStrategy::_empty_fill_ins_ ( )
staticprivateinherited

an empty fill-ins set used by default

Definition at line 60 of file eliminationSequenceStrategy.cpp.

60 {
61#ifdef GUM_DEBUG_MODE
62 static bool first_use = true;
63 if (first_use) {
64 first_use = false;
65 __debug__::_dec_creation_("Set", " __empty_edge_set", 0, "static variable correction", 0);
66 __debug__::_dec_creation_("HashTable",
67 " __empty_edge_set",
68 0,
69 "static variable correction",
70 0);
71 }
72#endif
73 static EdgeSet empty_fill_ins;
74 return empty_fill_ins;
75 }
Set< Edge > EdgeSet
Some typdefs and define for shortcuts ...

Referenced by fillIns().

Here is the caller graph for this function:

◆ _nodeToEliminate_()

NodeId gum::DefaultPartialOrderedEliminationSequenceStrategy::_nodeToEliminate_ ( const PriorityQueue< NodeId, double > & possibleNodes)
private

returns the best possible node to be eliminated

this function is used by method nextNodeToEliminate

Definition at line 168 of file defaultPartialOrderedEliminationSequenceStrategy.cpp.

169 {
170 bool found = false;
171 double min_score = 0;
172 NodeId best_node = 0;
173
174 for (const auto node: nodeset_) {
175 if (possibleNodes.contains(node)) {
176 double score = possibleNodes.priority(node);
177
178 if (!found || (score < min_score)) {
179 found = true;
180 min_score = score;
181 best_node = node;
182 }
183 }
184 }
185
186 if (!found) { GUM_ERROR(NotFound, "no possible node to eliminate") }
187
188 return best_node;
189 }
NodeSet nodeset_
the nodes which can be currently eliminated
#define GUM_ERROR(type, msg)
Definition exceptions.h:76
Size NodeId
Type for node ids.

References gum::PriorityQueueImplementation< Val, int, std::less< int >, std::is_scalar< Val >::value >::contains(), GUM_ERROR, gum::PartialOrderedEliminationSequenceStrategy::nodeset_, and gum::PriorityQueueImplementation< Val, int, std::less< int >, std::is_scalar< Val >::value >::priority().

Referenced by nextNodeToEliminate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ askFillIns()

void gum::DefaultPartialOrderedEliminationSequenceStrategy::askFillIns ( bool do_it)
finalvirtual

if the elimination sequence is able to compute fill-ins, we indicate whether we want this feature to be activated

if the elimination sequence is able to compute fill-ins, we indicatewhether we want this feature to be activated

Parameters
do_itwhen true and the elimination sequence has the ability to compute fill-ins, the elimination sequence will actually compute them (for the triangulation to use them), else they will not be available.

Implements gum::EliminationSequenceStrategy.

Definition at line 243 of file defaultPartialOrderedEliminationSequenceStrategy.cpp.

243 {
244 _provide_fill_ins_ = do_it;
245
247 }

References _provide_fill_ins_, and _simplicial_set_.

◆ clear()

void gum::DefaultPartialOrderedEliminationSequenceStrategy::clear ( )
finalvirtual

clears the sequence (to prepare, for instance, a new elimination sequence)

Reimplemented from gum::EliminationSequenceStrategy.

Definition at line 157 of file defaultPartialOrderedEliminationSequenceStrategy.cpp.

157 {
159 _log_weights_.clear();
160
161 if (_simplicial_set_ != nullptr) {
162 delete _simplicial_set_;
163 _simplicial_set_ = nullptr;
164 }
165 }
void clear() override
clears the sequence (to prepare, for instance, a new elimination sequence)

References _log_weights_, _simplicial_set_, and gum::PartialOrderedEliminationSequenceStrategy::clear().

Here is the call graph for this function:

◆ copyFactory()

DefaultPartialOrderedEliminationSequenceStrategy * gum::DefaultPartialOrderedEliminationSequenceStrategy::copyFactory ( ) const
nodiscardfinalvirtual

virtual copy constructor

Warning
The newly created elimination sequence strategy points toward the same undirected graph as the one contained in the current strategy but each strategy possesses its own simplicial set. As a result, if both elimination strategies are used at the same time, they will probably result in a mess because their simplicial sets won't be synchronized correctly with the changing undirected graph. So, whenever using this virtual copy constructor, be sure that either the current or the newly created strategy is used for a triangulation but not both. This will necessarily be OK in DefaultTriangulations.

Implements gum::PartialOrderedEliminationSequenceStrategy.

Definition at line 304 of file defaultPartialOrderedEliminationSequenceStrategy.cpp.

304 {
306 }

References DefaultPartialOrderedEliminationSequenceStrategy().

Here is the call graph for this function:

◆ domainSizes()

INLINE const NodeProperty< Size > * gum::EliminationSequenceStrategy::domainSizes ( ) const
noexceptinherited

returns the current domain sizes

Definition at line 62 of file eliminationSequenceStrategy_inl.h.

62 {
63 return domain_sizes_;
64 }
const NodeProperty< Size > * domain_sizes_
the domain sizes of the variables/nodes

References domain_sizes_.

Referenced by providesGraphUpdate().

Here is the caller graph for this function:

◆ eliminationUpdate()

void gum::DefaultPartialOrderedEliminationSequenceStrategy::eliminationUpdate ( const NodeId node)
finalvirtual

performs all the graph/fill-ins updates provided (if any)

performs all the graph/fill-ins updates provided

Parameters
nodethe node the elimination of which requires the graph update

Reimplemented from gum::EliminationSequenceStrategy.

Definition at line 263 of file defaultPartialOrderedEliminationSequenceStrategy.cpp.

263 {
264 // check whether we can do something
265 if (_simplicial_set_ != nullptr) {
266 _simplicial_set_->makeClique(id);
267 _simplicial_set_->eraseClique(id);
268
270 // remove the node from nodeset_
271 nodeset_.erase(id);
272
273 if (nodeset_.empty()) {
274 // go to the next non-empty subset
275 for (++subset_iter_; subset_iter_ != subsets_->cend(); ++subset_iter_) {
276 for (const auto node: *subset_iter_) {
277 if (graph_->existsNode(node)) { nodeset_.insert(node); }
278 }
279 if (!nodeset_.empty()) break;
280 }
281 }
282 }
283 }
284 }
bool partial_order_needed_
indicate whether a new partial ordering is necessary for the elimination
const List< NodeSet > * subsets_
the subsets constituting the partial ordering
List< NodeSet >::const_iterator subset_iter_
the iterator indicating which is the current subset on which we work

References _simplicial_set_, gum::EliminationSequenceStrategy::graph_, gum::PartialOrderedEliminationSequenceStrategy::nodeset_, gum::PartialOrderedEliminationSequenceStrategy::partial_order_needed_, gum::PartialOrderedEliminationSequenceStrategy::subset_iter_, and gum::PartialOrderedEliminationSequenceStrategy::subsets_.

◆ fillIns()

const EdgeSet & gum::DefaultPartialOrderedEliminationSequenceStrategy::fillIns ( )
finalvirtual

in case fill-ins are provided, this function returns the fill-ins due to all the nodes eliminated so far

in case fill-ins are provided, this function returns the fill-ins generated after the last node elimination

Reimplemented from gum::EliminationSequenceStrategy.

Definition at line 288 of file defaultPartialOrderedEliminationSequenceStrategy.cpp.

288 {
289 if (!_provide_fill_ins_ || (_simplicial_set_ == nullptr))
291 else return _simplicial_set_->fillIns();
292 }
virtual const EdgeSet & fillIns()
in case fill-ins are provided, this function returns the fill-ins due to all the nodes eliminated so ...

References _provide_fill_ins_, _simplicial_set_, and gum::EliminationSequenceStrategy::fillIns().

Here is the call graph for this function:

◆ graph()

◆ isPartialOrderNeeded()

INLINE bool gum::PartialOrderedEliminationSequenceStrategy::isPartialOrderNeeded ( ) const
noexceptinherited

indicates if a new partial ordering is needed

if the current partial ordering does not contain all the nodes of the graph or if the graph itself is not defined (nullptr) a new partial ordering will be needed for the next triangulation

Definition at line 66 of file partialOrderedEliminationSequenceStrategy_inl.h.

66 {
68 }

References partial_order_needed_.

Referenced by copyFactory().

Here is the caller graph for this function:

◆ isPartialOrderNeeded_()

bool gum::PartialOrderedEliminationSequenceStrategy::isPartialOrderNeeded_ ( const List< NodeSet > * subsets) const
protectedinherited

indicate whether a partial ordering is compatible with the current graph

The method checks whether all the nodes of the graph belong to the partial ordering.

Returns
true if some nodes in graph_ do not belong to subsets or if graph_ is not defnined (nullptr)

Definition at line 118 of file partialOrderedEliminationSequenceStrategy.cpp.

119 {
120 if ((graph_ == nullptr) || (subsets == nullptr)) return true;
121
122 // determine the set of nodes in the subsets that belong to the graph
123 NodeSet nodes_found(graph_->size() / 2);
124 for (const auto& nodes: *subsets) {
125 for (const auto node: nodes) {
126 if (graph_->existsNode(node)) { nodes_found.insert(node); }
127 }
128 }
129
130 // check that the size of nodes_found is equal to that of the graph
131 return nodes_found.size() != graph_->size();
132 }
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...

References gum::EliminationSequenceStrategy::graph_, gum::Set< Key >::insert(), and gum::Set< Key >::size().

Referenced by setPartialOrder().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ newFactory()

DefaultPartialOrderedEliminationSequenceStrategy * gum::DefaultPartialOrderedEliminationSequenceStrategy::newFactory ( ) const
nodiscardfinalvirtual

creates a new elimination sequence of the same type as the current object, but this sequence contains only an empty graph

Warning
you must deallocate by yourself the object returned
Returns
an empty clone of the current object with the same type

Implements gum::PartialOrderedEliminationSequenceStrategy.

Definition at line 297 of file defaultPartialOrderedEliminationSequenceStrategy.cpp.

References DefaultPartialOrderedEliminationSequenceStrategy(), _simplicial_ratio_, and _simplicial_threshold_.

Here is the call graph for this function:

◆ nextNodeToEliminate()

NodeId gum::DefaultPartialOrderedEliminationSequenceStrategy::nextNodeToEliminate ( )
finalvirtual

returns the new node to be eliminated within the triangulation algorithm

Exceptions
NotFoundexception is thrown if there is no more node to eliminate in the graph

Implements gum::EliminationSequenceStrategy.

Definition at line 192 of file defaultPartialOrderedEliminationSequenceStrategy.cpp.

192 {
193 // if there is no simplicial set, send an exception
194 if (graph_ == nullptr) GUM_ERROR(NotFound, "the graph is empty")
195
197 GUM_ERROR(NotFound,
198 "the partial order does not cover all the nodes "
199 "of the graph");
200
201 if (nodeset_.empty()) { GUM_ERROR(NotFound, "no node is admissible") }
202
203 // select a node to be eliminated: try simplicial nodes, then almost
204 // simplicial nodes, then quasi-simplicial nodes
205 // note that if graph_ != nullptr, _simplicial_set_ has been allocated
206 if (!_simplicial_set_->allSimplicialNodes().empty()) {
207 try {
208 return _nodeToEliminate_(_simplicial_set_->allSimplicialNodes());
209 } catch (NotFound const&) {}
210 }
211
212 if (!_simplicial_set_->allAlmostSimplicialNodes().empty()) {
213 try {
214 return _nodeToEliminate_(_simplicial_set_->allAlmostSimplicialNodes());
215 } catch (NotFound const&) {}
216 }
217
218 if (!_simplicial_set_->allQuasiSimplicialNodes().empty()) {
219 try {
220 return _nodeToEliminate_(_simplicial_set_->allQuasiSimplicialNodes());
221 } catch (NotFound const&) {}
222 }
223
224 // here: select the node through Kjaerulff's heuristic
225 auto iter = nodeset_.cbegin();
226 double min_score = _log_weights_[*iter];
227 NodeId best_node = *iter;
228
229 for (++iter; iter != nodeset_.cend(); ++iter) {
230 double score = _log_weights_[*iter];
231
232 if (score < min_score) {
233 min_score = score;
234 best_node = *iter;
235 }
236 }
237
238 return best_node;
239 }
NodeId _nodeToEliminate_(const PriorityQueue< NodeId, double > &possibleNodes)
returns the best possible node to be eliminated

References _log_weights_, _nodeToEliminate_(), _simplicial_set_, gum::EliminationSequenceStrategy::graph_, GUM_ERROR, gum::PartialOrderedEliminationSequenceStrategy::nodeset_, and gum::PartialOrderedEliminationSequenceStrategy::partial_order_needed_.

Here is the call graph for this function:

◆ partialOrder()

INLINE const List< NodeSet > * gum::PartialOrderedEliminationSequenceStrategy::partialOrder ( ) const
noexceptinherited

returns the current partial ordering

Definition at line 61 of file partialOrderedEliminationSequenceStrategy_inl.h.

61 {
62 return subsets_;
63 }

References subsets_.

◆ providesFillIns()

bool gum::DefaultPartialOrderedEliminationSequenceStrategy::providesFillIns ( ) const
finalvirtual

indicates whether the fill-ins generated by the eliminated nodes, if needed, will be computed by the elimination sequence, or need be computed by the triangulation itself.

indicates whether the new fill-ins generated by a new eliminated node, if needed, will be computed by the elimination sequence, or need be computed by the triangulation itself.

An elimination sequence provides fill-ins to its triangulation if and only if it has the ability to compute them and it has been asked to do so (by method askFillIns)

Implements gum::EliminationSequenceStrategy.

Definition at line 252 of file defaultPartialOrderedEliminationSequenceStrategy.cpp.

252 {
253 return _provide_fill_ins_;
254 }

References _provide_fill_ins_.

◆ providesGraphUpdate()

bool gum::DefaultPartialOrderedEliminationSequenceStrategy::providesGraphUpdate ( ) const
finalvirtual

indicates whether the elimination sequence updates by itself the graph after a node has been eliminated

Implements gum::EliminationSequenceStrategy.

Definition at line 258 of file defaultPartialOrderedEliminationSequenceStrategy.cpp.

258 {
259 return true;
260 }

◆ setGraph()

bool gum::DefaultPartialOrderedEliminationSequenceStrategy::setGraph ( UndiGraph * graph,
const NodeProperty< Size > * dom_sizes )
finalvirtual

sets a new graph to be triangulated

The elimination sequence algorithms reinitializes its data to start a new triangulation with graph Graph and a new partial ordrering

Parameters
graphthe new graph to be triangulated
dom_sizesthe domain sizes of the nodes/variables
Warning
Note that we allow dom_sizes to be defined over nodes/variables that do not belong to graph. These sizes will simply be ignored. However, it is compulsory that all the nodes of graph belong to dom_sizes
the graph is altered during the triangulation.
note that, by aGrUM's rule, the graph and the domain sizes are not copied but only referenced by the elimination sequence algorithm.

Reimplemented from gum::EliminationSequenceStrategy.

Definition at line 145 of file defaultPartialOrderedEliminationSequenceStrategy.cpp.

147 {
150 return true;
151 }
152
153 return false;
154 }
void _createSimplicialSet_()
create a new simplicial set suited for the current graph
bool setGraph(UndiGraph *graph, const NodeProperty< Size > *dom_sizes) override
sets a new graph to be triangulated

References _createSimplicialSet_(), and gum::PartialOrderedEliminationSequenceStrategy::setGraph().

Referenced by DefaultPartialOrderedEliminationSequenceStrategy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPartialOrder()

bool gum::PartialOrderedEliminationSequenceStrategy::setPartialOrder ( const List< NodeSet > * subsets)
virtualinherited

sets a new partial ordering constraint on the elimination sequence

sets a new partial order

Parameters
subsetsthe list of the subsets constituting the partial ordering
Returns
true if the new partial order has been successfully assigned (i.e., if all the nodes of the graph belong to one of the subsets)
Warning
if the subsets contain some nodes that do not belong to the graph, then these nodes are simply ignored.
note that, by aGrUM's rule, the partial ordering is not copied but only referenced by the elimination sequence algorithm.

Definition at line 135 of file partialOrderedEliminationSequenceStrategy.cpp.

135 {
136 // check that the partial order contains all the nodes of the graph
138
140 subsets_ = subsets;
141
142 // initialize properly the set of nodes that can be currently eliminated:
143 // find the first subset that contains some node(s) of the graph
144 nodeset_.clear();
145 for (subset_iter_ = subsets_->cbegin(); subset_iter_ != subsets_->cend(); ++subset_iter_) {
146 for (const auto node: *subset_iter_) {
147 if (graph_->existsNode(node)) { nodeset_.insert(node); }
148 }
149 if (!nodeset_.empty()) return true;
150 }
151 }
152
153 return false;
154 }
bool isPartialOrderNeeded_(const List< NodeSet > *subsets) const
indicate whether a partial ordering is compatible with the current graph

References gum::EliminationSequenceStrategy::graph_, isPartialOrderNeeded_(), nodeset_, partial_order_needed_, subset_iter_, and subsets_.

Referenced by gum::DefaultPartialOrderedEliminationSequenceStrategy::DefaultPartialOrderedEliminationSequenceStrategy(), PartialOrderedEliminationSequenceStrategy(), gum::PartialOrderedTriangulation::PartialOrderedTriangulation(), gum::PartialOrderedTriangulation::initTriangulation_(), and setGraph().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _log_weights_

NodeProperty< double > gum::DefaultPartialOrderedEliminationSequenceStrategy::_log_weights_
private

◆ _provide_fill_ins_

bool gum::DefaultPartialOrderedEliminationSequenceStrategy::_provide_fill_ins_ {false}
private

◆ _simplicial_ratio_

double gum::DefaultPartialOrderedEliminationSequenceStrategy::_simplicial_ratio_
private

◆ _simplicial_set_

SimplicialSet* gum::DefaultPartialOrderedEliminationSequenceStrategy::_simplicial_set_ {nullptr}
private

◆ _simplicial_threshold_

double gum::DefaultPartialOrderedEliminationSequenceStrategy::_simplicial_threshold_
private

◆ domain_sizes_

const NodeProperty< Size >* gum::EliminationSequenceStrategy::domain_sizes_ {nullptr}
protectedinherited

the domain sizes of the variables/nodes

Definition at line 177 of file eliminationSequenceStrategy.h.

177{nullptr};

Referenced by EliminationSequenceStrategy(), EliminationSequenceStrategy(), clear(), domainSizes(), and setGraph().

◆ graph_

◆ log_domain_sizes_

◆ nodeset_

◆ partial_order_needed_

bool gum::PartialOrderedEliminationSequenceStrategy::partial_order_needed_ {true}
protectedinherited

◆ subset_iter_

List<NodeSet>::const_iterator gum::PartialOrderedEliminationSequenceStrategy::subset_iter_
protectedinherited

◆ subsets_

const List< NodeSet >* gum::PartialOrderedEliminationSequenceStrategy::subsets_ {nullptr}
protectedinherited

The documentation for this class was generated from the following files: