aGrUM  0.16.0
gum::PartialOrderedEliminationSequenceStrategy Class Referenceabstract

Base class for all elimination sequence algorithm that impose a given partial ordering on the nodes elimination sequence, that is, the set of all the nodes is divided into several subsets. More...

#include <partialOrderedEliminationSequenceStrategy.h>

+ Inheritance diagram for gum::PartialOrderedEliminationSequenceStrategy:
+ Collaboration diagram for gum::PartialOrderedEliminationSequenceStrategy:

Public Member Functions

Accessors / Modifiers
virtual bool setGraph (UndiGraph *graph, const NodeProperty< Size > *dom_sizes)
 sets a new graph to be triangulated More...
 
virtual bool setPartialOrder (const List< NodeSet > *subsets)
 sets a new partial ordering constraint on the elimination sequence More...
 
virtual void clear ()
 clears the sequence (to prepare, for instance, a new elimination sequence) More...
 
const List< NodeSet > * partialOrder () const noexcept
 returns the current partial ordering More...
 
bool isPartialOrderNeeded () const noexcept
 indicates if a new partial ordering is needed More...
 
Accessors / Modifiers
virtual NodeId nextNodeToEliminate ()=0
 returns the new node to be eliminated within the triangulation algorithm More...
 
virtual void askFillIns (bool do_it)=0
 if the elimination sequence is able to compute fill-ins, we indicate whether we want this feature to be activated More...
 
virtual bool providesFillIns () const =0
 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. More...
 
virtual bool providesGraphUpdate () const =0
 indicates whether the elimination sequence updates by itself the graph after a node has been eliminated More...
 
virtual void eliminationUpdate (const NodeId node)
 performs all the graph/fill-ins updates provided (if any) More...
 
virtual const EdgeSetfillIns ()
 in case fill-ins are provided, this function returns the fill-ins due to all the nodes eliminated so far More...
 
UndiGraphgraph () const noexcept
 returns the current graph More...
 
const NodeProperty< Size > * domainSizes () const noexcept
 returns the current domain sizes More...
 

Protected Attributes

const List< NodeSet > * _subsets {nullptr}
 the subsets constituting the partial ordering More...
 
List< NodeSet >::const_iterator _subset_iter
 the iterator indicating which is the current subset on which we work More...
 
NodeSet _nodeset
 the nodes which can be currently eliminated More...
 
bool _partial_order_needed {true}
 indicate whether a new partial ordering is necessary for the elimination More...
 
UndiGraph_graph {nullptr}
 the graph to be triangulated More...
 
const NodeProperty< Size > * _domain_sizes {nullptr}
 the domain sizes of the variables/nodes More...
 
NodeProperty< double_log_domain_sizes
 the log of the domain sizes of the variables/nodes More...
 

Protected Member Functions

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

Constructors / Destructors

virtual ~PartialOrderedEliminationSequenceStrategy ()
 destructor More...
 
virtual PartialOrderedEliminationSequenceStrategynewFactory () const =0
 creates a new elimination sequence of the same type as the current object, but this sequence contains only an empty graph More...
 
virtual PartialOrderedEliminationSequenceStrategycopyFactory () const =0
 virtual copy constructor More...
 
 PartialOrderedEliminationSequenceStrategy ()
 default constructor (uses an empty graph) More...
 
 PartialOrderedEliminationSequenceStrategy (UndiGraph *graph, const NodeProperty< Size > *dom_sizes, const List< NodeSet > *subsets)
 constructor for an a priori non empty graph More...
 
 PartialOrderedEliminationSequenceStrategy (const PartialOrderedEliminationSequenceStrategy &)
 copy constructor More...
 
 PartialOrderedEliminationSequenceStrategy (PartialOrderedEliminationSequenceStrategy &&)
 move constructor More...
 

Detailed Description

Base class for all elimination sequence algorithm that impose a given partial ordering on the nodes elimination sequence, that is, the set of all the nodes is divided into several subsets.

Within each subset, any ordering can be chosen. But 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.

Definition at line 55 of file partialOrderedEliminationSequenceStrategy.h.

Constructor & Destructor Documentation

◆ ~PartialOrderedEliminationSequenceStrategy()

gum::PartialOrderedEliminationSequenceStrategy::~PartialOrderedEliminationSequenceStrategy ( )
virtual

destructor

Definition at line 89 of file partialOrderedEliminationSequenceStrategy.cpp.

Referenced by PartialOrderedEliminationSequenceStrategy().

89  {
90  // for debugging purposes
92  }
PartialOrderedEliminationSequenceStrategy()
default constructor (uses an empty graph)
+ Here is the caller graph for this function:

◆ PartialOrderedEliminationSequenceStrategy() [1/4]

gum::PartialOrderedEliminationSequenceStrategy::PartialOrderedEliminationSequenceStrategy ( )
protected

default constructor (uses an empty graph)

default constructor

Definition at line 44 of file partialOrderedEliminationSequenceStrategy.cpp.

Referenced by PartialOrderedEliminationSequenceStrategy().

44  {
45  // for debugging purposes
47  }
PartialOrderedEliminationSequenceStrategy()
default constructor (uses an empty graph)
+ Here is the caller graph for this function:

◆ PartialOrderedEliminationSequenceStrategy() [2/4]

gum::PartialOrderedEliminationSequenceStrategy::PartialOrderedEliminationSequenceStrategy ( UndiGraph graph,
const NodeProperty< Size > *  dom_sizes,
const List< NodeSet > *  subsets 
)
protected

constructor for an a priori 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
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 51 of file partialOrderedEliminationSequenceStrategy.cpp.

References PartialOrderedEliminationSequenceStrategy(), setGraph(), and setPartialOrder().

54  {
55  setGraph(graph, dom_sizes);
56  setPartialOrder(subsets);
57 
58  // for debugging purposes
60  }
virtual bool setPartialOrder(const List< NodeSet > *subsets)
sets a new partial ordering constraint on the elimination sequence
UndiGraph * graph() const noexcept
returns the current graph
PartialOrderedEliminationSequenceStrategy()
default constructor (uses an empty graph)
virtual bool setGraph(UndiGraph *graph, const NodeProperty< Size > *dom_sizes)
sets a new graph to be triangulated
+ Here is the call graph for this function:

◆ PartialOrderedEliminationSequenceStrategy() [3/4]

gum::PartialOrderedEliminationSequenceStrategy::PartialOrderedEliminationSequenceStrategy ( const PartialOrderedEliminationSequenceStrategy from)
protected

copy constructor

Definition at line 64 of file partialOrderedEliminationSequenceStrategy.cpp.

References PartialOrderedEliminationSequenceStrategy().

65  :
67  _subsets(from._subsets), _subset_iter(from._subset_iter),
68  _nodeset(from._nodeset), _partial_order_needed(from._partial_order_needed) {
69  // for debugging purposes
71  }
PartialOrderedEliminationSequenceStrategy()
default constructor (uses an empty graph)
NodeSet _nodeset
the nodes which can be currently eliminated
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
bool _partial_order_needed
indicate whether a new partial ordering is necessary for the elimination
+ Here is the call graph for this function:

◆ PartialOrderedEliminationSequenceStrategy() [4/4]

gum::PartialOrderedEliminationSequenceStrategy::PartialOrderedEliminationSequenceStrategy ( PartialOrderedEliminationSequenceStrategy &&  from)
protected

move constructor

Definition at line 75 of file partialOrderedEliminationSequenceStrategy.cpp.

References ~PartialOrderedEliminationSequenceStrategy().

76  :
77  EliminationSequenceStrategy(std::move(from)),
78  _subsets(from._subsets), _subset_iter(from._subset_iter),
79  _nodeset(std::move(from._nodeset)),
80  _partial_order_needed(from._partial_order_needed) {
81  from._partial_order_needed = true;
82 
83  // for debugging purposes
85  }
PartialOrderedEliminationSequenceStrategy()
default constructor (uses an empty graph)
NodeSet _nodeset
the nodes which can be currently eliminated
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
bool _partial_order_needed
indicate whether a new partial ordering is necessary for the elimination
+ Here is the call graph for this function:

Member Function Documentation

◆ _isPartialOrderNeeded()

bool gum::PartialOrderedEliminationSequenceStrategy::_isPartialOrderNeeded ( const List< NodeSet > *  subsets) const
protected

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 105 of file partialOrderedEliminationSequenceStrategy.cpp.

References gum::EliminationSequenceStrategy::_graph, gum::NodeGraphPart::existsNode(), gum::Set< Key, Alloc >::insert(), and gum::NodeGraphPart::size().

Referenced by setPartialOrder().

106  {
107  if ((_graph == nullptr) || (subsets == nullptr)) return true;
108 
109  // determine the set of nodes in the subsets that belong to the graph
110  NodeSet nodes_found(_graph->size() / 2);
111  for (const auto& nodes : *subsets) {
112  for (const auto node : nodes) {
113  if (_graph->existsNode(node)) { nodes_found.insert(node); }
114  }
115  }
116 
117  // check that the size of nodes_found is equal to that of the graph
118  return nodes_found.size() != _graph->size();
119  }
UndiGraph * _graph
the graph to be triangulated
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
Size size() const
alias for sizeNodes
bool existsNode(const NodeId id) const
returns true iff the NodeGraphPart contains the given nodeId
void insert(const Key &k)
Inserts a new element into the set.
Definition: set_tpl.h:613
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ askFillIns()

virtual void gum::EliminationSequenceStrategy::askFillIns ( bool  do_it)
pure virtualinherited

if the elimination sequence is able to compute fill-ins, we indicate whether 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.

Implemented in gum::DefaultPartialOrderedEliminationSequenceStrategy, gum::DefaultEliminationSequenceStrategy, and gum::OrderedEliminationSequenceStrategy.

Referenced by gum::StaticTriangulation::__triangulate().

+ Here is the caller graph for this function:

◆ clear()

void gum::PartialOrderedEliminationSequenceStrategy::clear ( )
virtual

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

Reimplemented from gum::EliminationSequenceStrategy.

Reimplemented in gum::DefaultPartialOrderedEliminationSequenceStrategy.

Definition at line 146 of file partialOrderedEliminationSequenceStrategy.cpp.

References _nodeset, _partial_order_needed, _subsets, gum::EliminationSequenceStrategy::clear(), and gum::Set< Key, Alloc >::clear().

Referenced by gum::DefaultPartialOrderedEliminationSequenceStrategy::clear().

146  {
148  _subsets = nullptr;
149  _nodeset.clear();
150  _partial_order_needed = true;
151  }
virtual void clear()
clears the sequence (to prepare, for instance, a new elimination sequence)
NodeSet _nodeset
the nodes which can be currently eliminated
const List< NodeSet > * _subsets
the subsets constituting the partial ordering
bool _partial_order_needed
indicate whether a new partial ordering is necessary for the elimination
void clear()
Removes all the elements, if any, from the set.
Definition: set_tpl.h:375
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyFactory()

virtual PartialOrderedEliminationSequenceStrategy* gum::PartialOrderedEliminationSequenceStrategy::copyFactory ( ) const
pure virtual

◆ domainSizes()

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

returns the current domain sizes

Definition at line 44 of file eliminationSequenceStrategy_inl.h.

References gum::EliminationSequenceStrategy::_domain_sizes.

44  {
45  return _domain_sizes;
46  }
const NodeProperty< Size > * _domain_sizes
the domain sizes of the variables/nodes

◆ eliminationUpdate()

void gum::EliminationSequenceStrategy::eliminationUpdate ( const NodeId  node)
virtualinherited

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

Parameters
nodethe node the elimination of which requires the graph update

Reimplemented in gum::DefaultPartialOrderedEliminationSequenceStrategy, gum::DefaultEliminationSequenceStrategy, and gum::OrderedEliminationSequenceStrategy.

Definition at line 97 of file eliminationSequenceStrategy.cpp.

Referenced by gum::StaticTriangulation::__triangulate().

97 {}
+ Here is the caller graph for this function:

◆ fillIns()

const EdgeSet & gum::EliminationSequenceStrategy::fillIns ( )
virtualinherited

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

Reimplemented in gum::DefaultPartialOrderedEliminationSequenceStrategy, gum::DefaultEliminationSequenceStrategy, and gum::OrderedEliminationSequenceStrategy.

Definition at line 101 of file eliminationSequenceStrategy.cpp.

References gum::EliminationSequenceStrategy::__empty_fill_ins().

Referenced by gum::StaticTriangulation::fillIns(), gum::OrderedEliminationSequenceStrategy::fillIns(), gum::DefaultEliminationSequenceStrategy::fillIns(), and gum::DefaultPartialOrderedEliminationSequenceStrategy::fillIns().

101  {
102  return __empty_fill_ins();
103  }
static const EdgeSet & __empty_fill_ins()
an empty fill-ins set used by default
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ graph()

INLINE UndiGraph * gum::EliminationSequenceStrategy::graph ( ) const
noexceptinherited

returns the current graph

Definition at line 37 of file eliminationSequenceStrategy_inl.h.

References gum::EliminationSequenceStrategy::_graph.

Referenced by gum::EliminationSequenceStrategy::setGraph().

37  {
38  return _graph;
39  }
UndiGraph * _graph
the graph to be triangulated
+ Here is the caller graph for this function:

◆ isPartialOrderNeeded()

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

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 46 of file partialOrderedEliminationSequenceStrategy_inl.h.

References _partial_order_needed.

47  {
48  return _partial_order_needed;
49  }
bool _partial_order_needed
indicate whether a new partial ordering is necessary for the elimination

◆ newFactory()

virtual PartialOrderedEliminationSequenceStrategy* gum::PartialOrderedEliminationSequenceStrategy::newFactory ( ) const
pure virtual

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::EliminationSequenceStrategy.

Implemented in gum::DefaultPartialOrderedEliminationSequenceStrategy.

◆ nextNodeToEliminate()

virtual NodeId gum::EliminationSequenceStrategy::nextNodeToEliminate ( )
pure virtualinherited

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

Implemented in gum::DefaultPartialOrderedEliminationSequenceStrategy, gum::DefaultEliminationSequenceStrategy, and gum::OrderedEliminationSequenceStrategy.

Referenced by gum::StaticTriangulation::__triangulate().

+ Here is the caller graph for this function:

◆ partialOrder()

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

returns the current partial ordering

Definition at line 39 of file partialOrderedEliminationSequenceStrategy_inl.h.

References _subsets.

39  {
40  return _subsets;
41  }
const List< NodeSet > * _subsets
the subsets constituting the partial ordering

◆ providesFillIns()

virtual bool gum::EliminationSequenceStrategy::providesFillIns ( ) const
pure virtualinherited

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.

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)

Implemented in gum::DefaultPartialOrderedEliminationSequenceStrategy, gum::DefaultEliminationSequenceStrategy, and gum::OrderedEliminationSequenceStrategy.

Referenced by gum::StaticTriangulation::__triangulate(), and gum::StaticTriangulation::fillIns().

+ Here is the caller graph for this function:

◆ providesGraphUpdate()

virtual bool gum::EliminationSequenceStrategy::providesGraphUpdate ( ) const
pure virtualinherited

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

Some algorithms have more informations than the triangulation algorithm to update the graph after a node has been eliminated. They can thus exploit these informations to update the graph faster than the triangulation itself. Hence the latter should delegate this operation to the elimination sequence. This is the case, for instance, for the defaultEliminationSequenceStrategy, which uses a SimplicialSet that knows that some eliminated nodes do not require any fill-in.

Implemented in gum::DefaultPartialOrderedEliminationSequenceStrategy, gum::DefaultEliminationSequenceStrategy, and gum::OrderedEliminationSequenceStrategy.

Referenced by gum::StaticTriangulation::__triangulate().

+ Here is the caller graph for this function:

◆ setGraph()

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

sets a new graph to be triangulated

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

Parameters
graphthe new graph to be triangulated
dom_sizesthe domain sizes of the nodes/variables
Returns
true if the data structures were modified (if the graph or the domain sizes did not change, then there is no need to update the data structures).
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 sequence are not copied but only referenced by the elimination sequence algorithm.

Reimplemented from gum::EliminationSequenceStrategy.

Reimplemented in gum::DefaultPartialOrderedEliminationSequenceStrategy.

Definition at line 95 of file partialOrderedEliminationSequenceStrategy.cpp.

References _subsets, gum::EliminationSequenceStrategy::setGraph(), and setPartialOrder().

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

96  {
97  if (EliminationSequenceStrategy::setGraph(graph, domain_sizes)) {
99  return true;
100  }
101  return false;
102  }
virtual bool setPartialOrder(const List< NodeSet > *subsets)
sets a new partial ordering constraint on the elimination sequence
UndiGraph * graph() const noexcept
returns the current graph
const List< NodeSet > * _subsets
the subsets constituting the partial ordering
virtual bool setGraph(UndiGraph *graph, const NodeProperty< Size > *dom_sizes)
sets a new graph to be triangulated
+ 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)
virtual

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 122 of file partialOrderedEliminationSequenceStrategy.cpp.

References gum::EliminationSequenceStrategy::_graph, _isPartialOrderNeeded(), _nodeset, _partial_order_needed, _subset_iter, _subsets, gum::Set< Key, Alloc >::clear(), gum::Set< Key, Alloc >::empty(), gum::NodeGraphPart::existsNode(), and gum::Set< Key, Alloc >::insert().

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

123  {
124  // check that the partial order contains all the nodes of the graph
126 
127  if (!_partial_order_needed) {
128  _subsets = subsets;
129 
130  // initialize properly the set of nodes that can be currently eliminated:
131  // find the first subset that contains some node(s) of the graph
132  _nodeset.clear();
133  for (_subset_iter = _subsets->cbegin(); _subset_iter != _subsets->cend();
134  ++_subset_iter) {
135  for (const auto node : *_subset_iter) {
136  if (_graph->existsNode(node)) { _nodeset.insert(node); }
137  }
138  if (!_nodeset.empty()) return true;
139  }
140  }
141 
142  return false;
143  }
bool empty() const noexcept
Indicates whether the set is the empty set.
Definition: set_tpl.h:707
UndiGraph * _graph
the graph to be triangulated
bool _isPartialOrderNeeded(const List< NodeSet > *subsets) const
indicate whether a partial ordering is compatible with the current graph
NodeSet _nodeset
the nodes which can be currently eliminated
const List< NodeSet > * _subsets
the subsets constituting the partial ordering
bool existsNode(const NodeId id) const
returns true iff the NodeGraphPart contains the given nodeId
List< NodeSet >::const_iterator _subset_iter
the iterator indicating which is the current subset on which we work
bool _partial_order_needed
indicate whether a new partial ordering is necessary for the elimination
void clear()
Removes all the elements, if any, from the set.
Definition: set_tpl.h:375
void insert(const Key &k)
Inserts a new element into the set.
Definition: set_tpl.h:613
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ _domain_sizes

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

◆ _graph

◆ _log_domain_sizes

◆ _nodeset

◆ _partial_order_needed

bool gum::PartialOrderedEliminationSequenceStrategy::_partial_order_needed {true}
protected

◆ _subset_iter

List< NodeSet >::const_iterator gum::PartialOrderedEliminationSequenceStrategy::_subset_iter
protected

the iterator indicating which is the current subset on which we work

Definition at line 132 of file partialOrderedEliminationSequenceStrategy.h.

Referenced by gum::DefaultPartialOrderedEliminationSequenceStrategy::eliminationUpdate(), and setPartialOrder().

◆ _subsets

const List< NodeSet >* gum::PartialOrderedEliminationSequenceStrategy::_subsets {nullptr}
protected

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