![]() |
aGrUM
0.16.0
|
base class for all non-incremental triangulation methods More...
#include <staticTriangulation.h>
Public Member Functions | |
Accessors / Modifiers | |
double | maxLog10CliqueDomainSize () |
returns the max of log10DomainSize of the cliques in the junction tree. More... | |
const NodeProperty< Size > * | domainSizes () const |
returns the domain sizes of the variables of the graph to be triangulated More... | |
Protected Attributes | |
EliminationSequenceStrategy * | _elimination_sequence_strategy {nullptr} |
the elimination sequence strategy used by the triangulation More... | |
JunctionTreeStrategy * | _junction_tree_strategy {nullptr} |
the junction tree strategy used by the triangulation More... | |
const NodeProperty< Size > * | _domain_sizes {nullptr} |
the domain sizes of the variables/nodes of the graph More... | |
Constructors / Destructors | |
virtual StaticTriangulation * | newFactory () const =0 |
returns a fresh triangulation of the same type as the current object but over an empty graph More... | |
virtual StaticTriangulation * | copyFactory () const =0 |
virtual copy constructor More... | |
virtual | ~StaticTriangulation () |
destructor More... | |
StaticTriangulation (const EliminationSequenceStrategy &elimSeq, const JunctionTreeStrategy &JTStrategy, bool minimality=false) | |
default constructor: without any graph More... | |
StaticTriangulation (const UndiGraph *graph, const NodeProperty< Size > *dom_sizes, const EliminationSequenceStrategy &elimSeq, const JunctionTreeStrategy &JTStrategy, bool minimality=false) | |
constructor with a given graph More... | |
StaticTriangulation (const StaticTriangulation &) | |
forbid copy constructor except in newfactory More... | |
StaticTriangulation (StaticTriangulation &&) | |
forbid move constructor except in children's constructors More... | |
Accessors / Modifiers | |
virtual void | setGraph (const UndiGraph *graph, const NodeProperty< Size > *domsizes) |
initialize the triangulation data structures for a new graph More... | |
const EdgeSet & | fillIns () |
returns the fill-ins added by the triangulation algorithm More... | |
const std::vector< NodeId > & | eliminationOrder () |
returns an elimination ordering compatible with the triangulated graph More... | |
Idx | eliminationOrder (const NodeId) |
returns the index of a given node in the elimination order (0 = first node eliminated) More... | |
const NodeProperty< NodeId > & | reverseEliminationOrder () |
returns a table indicating, for each node, at which step it was deleted by the triangulation process More... | |
const UndiGraph & | triangulatedGraph () |
returns the triangulated graph More... | |
const CliqueGraph & | eliminationTree () |
returns the elimination tree of a compatible ordering More... | |
const CliqueGraph & | junctionTree () |
returns a compatible junction tree More... | |
NodeId | createdJunctionTreeClique (const NodeId id) |
returns the Id of the clique of the junction tree created by the elimination of a given node during the triangulation process More... | |
const NodeProperty< NodeId > & | createdJunctionTreeCliques () |
returns the Ids of the cliques of the junction tree created by the elimination of the nodes More... | |
const CliqueGraph & | maxPrimeSubgraphTree () |
returns a junction tree of maximal prime subgraphs More... | |
NodeId | createdMaxPrimeSubgraph (const NodeId id) |
returns the Id of the maximal prime subgraph created by the elimination of a given node during the triangulation process More... | |
void | clear () |
reinitialize the graph to be triangulated to an empty graph More... | |
void | setMinimalRequirement (bool) |
sets/unset the minimality requirement More... | |
virtual bool | isMinimalityRequired () const final |
indicates wether minimality is required More... | |
void | setFillIns (bool) |
sets/unsets the record of the fill-ins in the standard triangulation procedure More... | |
const UndiGraph * | originalGraph () const |
returns the graph to be triangulated More... | |
EliminationSequenceStrategy & | eliminationSequenceStrategy () const |
returns the elimination sequence strategy used by the triangulation More... | |
JunctionTreeStrategy & | junctionTreeStrategy () const |
returns the junction tree strategy used by the triangulation More... | |
virtual void | _initTriangulation (UndiGraph &graph) |
the function called to initialize the triangulation process More... | |
base class for all non-incremental triangulation methods
Definition at line 50 of file staticTriangulation.h.
|
virtual |
destructor
Definition at line 153 of file staticTriangulation.cpp.
References _elimination_sequence_strategy, and _junction_tree_strategy.
|
protected |
default constructor: without any graph
elimSeq | the elimination sequence used to triangulate the graph |
JTStrategy | the junction tree strategy used to create junction trees from elimination trees |
minimality | a Boolean indicating whether we should enforce that the triangulation is minimal w.r.t. inclusion |
Definition at line 69 of file staticTriangulation.cpp.
References _junction_tree_strategy, and gum::JunctionTreeStrategy::setTriangulation().
|
protected |
constructor with a given graph
graph | the graph to be triangulated, i.e., the nodes of which will be eliminated |
dom_sizes | the domain sizes of the nodes to be eliminated |
elimSeq | the elimination sequence used to triangulate the graph |
JTStrategy | the junction tree strategy used to create junction trees |
minimality | a Boolean indicating whether we should enforce that the triangulation is minimal w.r.t. inclusion |
Definition at line 41 of file staticTriangulation.cpp.
References __added_fill_ins, __elim_cliques, __elim_order, __node_2_max_prime_clique, __reverse_elim_order, _junction_tree_strategy, gum::JunctionTreeStrategy::setTriangulation(), and gum::NodeGraphPart::size().
|
protected |
forbid copy constructor except in newfactory
Definition at line 84 of file staticTriangulation.cpp.
References __junction_tree, _elimination_sequence_strategy, _junction_tree_strategy, gum::JunctionTreeStrategy::copyFactory(), gum::EliminationSequenceStrategy::copyFactory(), and gum::JunctionTreeStrategy::junctionTree().
|
protected |
forbid move constructor except in children's constructors
Definition at line 116 of file staticTriangulation.cpp.
References __junction_tree, _junction_tree_strategy, gum::JunctionTreeStrategy::junctionTree(), and gum::JunctionTreeStrategy::moveTriangulation().
|
private |
returns an elimination tree from a triangulated graph
Definition at line 337 of file staticTriangulation.cpp.
References __elim_cliques, __elim_order, __elim_tree, __has_elimination_tree, __has_triangulation, __original_graph, __reverse_elim_order, __triangulate(), gum::CliqueGraph::addEdge(), gum::CliqueGraph::addNode(), gum::NodeGraphPart::bound(), and gum::CliqueGraph::clear().
|
private |
computes the junction tree of the maximal prime subgraphs
Definition at line 410 of file staticTriangulation.cpp.
References __computeMaxPrimeMergings(), __has_junction_tree, __has_max_prime_junction_tree, __junction_tree, __max_prime_junction_tree, __node_2_max_prime_clique, _junction_tree_strategy, gum::CliqueGraph::addEdge(), gum::CliqueGraph::addNode(), gum::CliqueGraph::addToClique(), gum::CliqueGraph::clique(), gum::Set< Key, Alloc >::contains(), gum::JunctionTreeStrategy::createdCliques(), gum::EdgeGraphPart::edges(), gum::HashTable< Key, Val, Alloc >::insert(), junctionTree(), gum::NodeGraphPart::nodes(), and gum::NodeGraphPart::size().
|
private |
used for computing the junction tree of the maximal prime subgraphs
Definition at line 376 of file staticTriangulation.cpp.
References __junction_tree, __original_graph, gum::Set< Key, Alloc >::begin(), gum::Set< Key, Alloc >::end(), gum::EdgeGraphPart::existsEdge(), gum::EdgeGraphPart::neighbours(), and gum::CliqueGraph::separator().
Referenced by __computeMaxPrimeJunctionTree().
|
private |
removes redondant fill-ins and compute proper elimination cliques and order
Definition at line 195 of file staticTriangulation.cpp.
References __added_fill_ins, __elim_cliques, __elim_order, __fill_ins, __has_fill_ins, __reverse_elim_order, __triangulated_graph, gum::Set< Key, Alloc >::erase(), gum::PriorityQueueImplementation< Val, Priority, Cmp, Alloc, Gen >::insert(), gum::Set< Key, Alloc >::insert(), gum::HashTable< Key, Val, Alloc >::insert(), and gum::NodeGraphPart::size().
Referenced by __triangulate().
|
private |
the function that performs the triangulation
Definition at line 554 of file staticTriangulation.cpp.
References __added_fill_ins, __computeRecursiveThinning(), __elim_cliques, __elim_order, __fill_ins, __has_fill_ins, __has_triangulated_graph, __has_triangulation, __minimality_required, __original_graph, __reverse_elim_order, __triangulated_graph, __we_want_fill_ins, _elimination_sequence_strategy, _initTriangulation(), gum::UndiGraph::addEdge(), gum::EliminationSequenceStrategy::askFillIns(), gum::Set< Key, Alloc >::begin(), gum::EliminationSequenceStrategy::eliminationUpdate(), gum::Set< Key, Alloc >::end(), gum::UndiGraph::eraseNode(), gum::EdgeGraphPart::existsEdge(), gum::Set< Key, Alloc >::insert(), gum::EdgeGraphPart::neighbours(), gum::EliminationSequenceStrategy::nextNodeToEliminate(), gum::EliminationSequenceStrategy::providesFillIns(), gum::EliminationSequenceStrategy::providesGraphUpdate(), gum::Set< Key, Alloc >::resize(), gum::NodeGraphPart::size(), and gum::Set< Key, Alloc >::size().
Referenced by __computeEliminationTree(), fillIns(), and triangulatedGraph().
|
protectedvirtual |
the function called to initialize the triangulation process
This function is called when the triangulation process starts and is used to initialize the elimination sequence strategy. Actually, the graph that is modified by the triangulation algorithm is a copy of the original graph, and this copy needs be known by the elimination sequence strategy. _initTriangulation is used to transmit this knowledge to the elimination sequence (through method setGraph of the elimination sequence class).
graph | the very graph that is triangulated (this is a copy of __original_graph) |
Reimplemented in gum::PartialOrderedTriangulation, and gum::OrderedTriangulation.
Definition at line 733 of file staticTriangulation.cpp.
References gum::Triangulation::_domain_sizes, _elimination_sequence_strategy, and gum::EliminationSequenceStrategy::setGraph().
Referenced by __triangulate().
|
virtual |
reinitialize the graph to be triangulated to an empty graph
Implements gum::Triangulation.
Definition at line 165 of file staticTriangulation.cpp.
References __added_fill_ins, __elim_cliques, __elim_order, __elim_tree, __fill_ins, __has_elimination_tree, __has_fill_ins, __has_junction_tree, __has_max_prime_junction_tree, __has_triangulated_graph, __has_triangulation, __junction_tree, __max_prime_junction_tree, __node_2_max_prime_clique, __original_graph, __reverse_elim_order, __triangulated_graph, _elimination_sequence_strategy, _junction_tree_strategy, gum::JunctionTreeStrategy::clear(), gum::CliqueGraph::clear(), gum::EliminationSequenceStrategy::clear(), gum::UndiGraph::clear(), and gum::Set< Key, Alloc >::clear().
Referenced by setGraph().
|
pure virtual |
virtual copy constructor
note that we return a pointer as it enables subclasses to return pointers to their types, not Triangulation pointers. See item 25 of the more effective C++.
Implements gum::Triangulation.
Implemented in gum::PartialOrderedTriangulation, gum::OrderedTriangulation, gum::DefaultTriangulation, and gum::UnconstrainedTriangulation.
returns the Id of the clique of the junction tree created by the elimination of a given node during the triangulation process
Implements gum::Triangulation.
|
virtual |
returns the Ids of the cliques of the junction tree created by the elimination of the nodes
Implements gum::Triangulation.
returns the Id of the maximal prime subgraph created by the elimination of a given node during the triangulation process
Implements gum::Triangulation.
|
inherited |
returns the domain sizes of the variables of the graph to be triangulated
|
virtual |
returns an elimination ordering compatible with the triangulated graph
Implements gum::Triangulation.
Referenced by gum::prm::StructuredInference< GUM_SCALAR >::__buildReduceGraph(), gum::DefaultJunctionTreeStrategy::__computeJunctionTree(), gum::prm::SVED< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVED< GUM_SCALAR >::__eliminateNodesWithEvidence(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodesWithEvidence(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::__elimination_cost(), gum::prm::SVE< GUM_SCALAR >::__initLiftedNodes(), gum::prm::StructuredInference< GUM_SCALAR >::__reduceAloneInstances(), and gum::prm::StructuredInference< GUM_SCALAR >::__reducePattern().
returns the index of a given node in the elimination order (0 = first node eliminated)
Implements gum::Triangulation.
EliminationSequenceStrategy& gum::StaticTriangulation::eliminationSequenceStrategy | ( | ) | const |
returns the elimination sequence strategy used by the triangulation
|
virtual |
returns the elimination tree of a compatible ordering
Implements gum::Triangulation.
Referenced by gum::DefaultJunctionTreeStrategy::__computeJunctionTree().
|
virtual |
returns the fill-ins added by the triangulation algorithm
Implements gum::Triangulation.
Definition at line 679 of file staticTriangulation.cpp.
References __fill_ins, __has_fill_ins, __has_junction_tree, __has_triangulation, __junction_tree, __original_graph, __triangulate(), __we_want_fill_ins, _elimination_sequence_strategy, gum::CliqueGraph::clique(), gum::EdgeGraphPart::existsEdge(), gum::EliminationSequenceStrategy::fillIns(), gum::Set< Key, Alloc >::insert(), junctionTree(), gum::NodeGraphPart::nodes(), gum::EliminationSequenceStrategy::providesFillIns(), and gum::Set< Key, Alloc >::size().
|
finalvirtual |
indicates wether minimality is required
|
virtual |
returns a compatible junction tree
Implements gum::Triangulation.
Referenced by __computeMaxPrimeJunctionTree(), fillIns(), and triangulatedGraph().
JunctionTreeStrategy& gum::StaticTriangulation::junctionTreeStrategy | ( | ) | const |
returns the junction tree strategy used by the triangulation
|
inherited |
returns the max of log10DomainSize of the cliques in the junction tree.
This is usefull for instance to estimate the complexity (both in space and in time) of the inference that will use the junction tree.
This method is not 'const' since it can be called before building any junction tree and hence it needs to build it...
Definition at line 70 of file triangulation.cpp.
References gum::Triangulation::_domain_sizes, and gum::Triangulation::junctionTree().
Referenced by gum::MaxInducedWidthMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__checkConditions().
|
virtual |
returns a junction tree of maximal prime subgraphs
Implements gum::Triangulation.
|
pure virtual |
returns a fresh triangulation of the same type as the current object but over an empty graph
note that we return a pointer as it enables subclasses to return pointers to their types, not Triangulation pointers. See item 25 of the more effective C++.
Implements gum::Triangulation.
Implemented in gum::PartialOrderedTriangulation, gum::OrderedTriangulation, gum::DefaultTriangulation, and gum::UnconstrainedTriangulation.
|
private |
forbid copy operator
const UndiGraph* gum::StaticTriangulation::originalGraph | ( | ) | const |
returns the graph to be triangulated
Referenced by gum::DefaultJunctionTreeStrategy::copyFactory().
const NodeProperty< NodeId >& gum::StaticTriangulation::reverseEliminationOrder | ( | ) |
returns a table indicating, for each node, at which step it was deleted by the triangulation process
void gum::StaticTriangulation::setFillIns | ( | bool | ) |
sets/unsets the record of the fill-ins in the standard triangulation procedure
|
virtual |
initialize the triangulation data structures for a new graph
graph | the graph to be triangulated, i.e., the nodes of which will be eliminated |
domsizes | the domain sizes of the nodes to be eliminated |
Implements gum::Triangulation.
Reimplemented in gum::PartialOrderedTriangulation, and gum::OrderedTriangulation.
Definition at line 526 of file staticTriangulation.cpp.
References __added_fill_ins, __elim_cliques, __elim_order, __has_elimination_tree, __has_fill_ins, __has_junction_tree, __has_max_prime_junction_tree, __has_triangulated_graph, __has_triangulation, __node_2_max_prime_clique, __original_graph, __reverse_elim_order, gum::Triangulation::_domain_sizes, clear(), and gum::NodeGraphPart::size().
Referenced by gum::OrderedTriangulation::setGraph(), and gum::PartialOrderedTriangulation::setGraph().
void gum::StaticTriangulation::setMinimalRequirement | ( | bool | ) |
sets/unset the minimality requirement
|
virtual |
returns the triangulated graph
Implements gum::Triangulation.
Definition at line 487 of file staticTriangulation.cpp.
References __has_junction_tree, __has_triangulated_graph, __has_triangulation, __junction_tree, __original_graph, __triangulate(), __triangulated_graph, gum::UndiGraph::addEdge(), junctionTree(), and gum::Set< Key, Alloc >::size().
|
private |
a vector containing the set of fill-ins added after each node elimination (used by recursive thinning)
Definition at line 296 of file staticTriangulation.h.
Referenced by __computeRecursiveThinning(), __triangulate(), clear(), setGraph(), and StaticTriangulation().
|
private |
the cliques formed by the elimination of the nodes
Definition at line 254 of file staticTriangulation.h.
Referenced by __computeEliminationTree(), __computeRecursiveThinning(), __triangulate(), clear(), setGraph(), and StaticTriangulation().
|
private |
the order in which nodes are eliminated by the algorithm
Definition at line 248 of file staticTriangulation.h.
Referenced by __computeEliminationTree(), __computeRecursiveThinning(), __triangulate(), clear(), setGraph(), and StaticTriangulation().
|
private |
the elimination tree computed by the algorithm
Definition at line 257 of file staticTriangulation.h.
Referenced by __computeEliminationTree(), and clear().
|
private |
the fill-ins added during the whole triangulation process
Definition at line 245 of file staticTriangulation.h.
Referenced by __computeRecursiveThinning(), __triangulate(), clear(), and fillIns().
|
private |
a boolean indicating whether the elimination tree has been computed
Definition at line 279 of file staticTriangulation.h.
Referenced by __computeEliminationTree(), clear(), and setGraph().
|
private |
indicates whether we actually computed fill-ins
Definition at line 289 of file staticTriangulation.h.
Referenced by __computeRecursiveThinning(), __triangulate(), clear(), fillIns(), and setGraph().
|
private |
a boolean indicating whether the junction tree has been constructed
Definition at line 282 of file staticTriangulation.h.
Referenced by __computeMaxPrimeJunctionTree(), clear(), fillIns(), setGraph(), and triangulatedGraph().
|
private |
indicates whether a maximal prime subgraph junction tree has been constructed
Definition at line 286 of file staticTriangulation.h.
Referenced by __computeMaxPrimeJunctionTree(), clear(), and setGraph().
|
private |
a boolean indicating whether we have constructed the triangulated graph
Definition at line 276 of file staticTriangulation.h.
Referenced by __triangulate(), clear(), setGraph(), and triangulatedGraph().
|
private |
a boolean indicating whether we have parformed a triangulation
Definition at line 273 of file staticTriangulation.h.
Referenced by __computeEliminationTree(), __triangulate(), clear(), fillIns(), setGraph(), and triangulatedGraph().
|
private |
the junction tree computed by the algorithm
note that the junction tree is owned by the junctionTreeStrategy and, therefore, its deletion from memory is not handled by the static triangulation class.
Definition at line 263 of file staticTriangulation.h.
Referenced by __computeMaxPrimeJunctionTree(), __computeMaxPrimeMergings(), clear(), fillIns(), StaticTriangulation(), and triangulatedGraph().
|
private |
the maximal prime subgraph junction tree computed from the junction tree
Definition at line 266 of file staticTriangulation.h.
Referenced by __computeMaxPrimeJunctionTree(), and clear().
|
private |
indicates whether the triangulation must be minimal
Definition at line 292 of file staticTriangulation.h.
Referenced by __triangulate().
|
private |
indicates which clique of the max prime junction tree was created by the elmination of a given node (the key of the table)
Definition at line 270 of file staticTriangulation.h.
Referenced by __computeMaxPrimeJunctionTree(), clear(), setGraph(), and StaticTriangulation().
|
private |
a pointer to the (external) original graph (which will be triangulated)
Definition at line 239 of file staticTriangulation.h.
Referenced by __computeEliminationTree(), __computeMaxPrimeMergings(), __triangulate(), clear(), fillIns(), setGraph(), and triangulatedGraph().
|
private |
the elimination order (access by NodeId)
Definition at line 251 of file staticTriangulation.h.
Referenced by __computeEliminationTree(), __computeRecursiveThinning(), __triangulate(), clear(), setGraph(), and StaticTriangulation().
|
private |
the triangulated graph
Definition at line 242 of file staticTriangulation.h.
Referenced by __computeRecursiveThinning(), __triangulate(), clear(), and triangulatedGraph().
|
private |
a boolean indicating if we want fill-ins list with the standard triangulation method
Definition at line 300 of file staticTriangulation.h.
Referenced by __triangulate(), and fillIns().
|
protectedinherited |
the domain sizes of the variables/nodes of the graph
Definition at line 152 of file triangulation.h.
Referenced by gum::OrderedTriangulation::_initTriangulation(), gum::PartialOrderedTriangulation::_initTriangulation(), _initTriangulation(), gum::Triangulation::maxLog10CliqueDomainSize(), and setGraph().
|
protected |
the elimination sequence strategy used by the triangulation
Definition at line 231 of file staticTriangulation.h.
Referenced by __triangulate(), gum::OrderedTriangulation::_initTriangulation(), gum::PartialOrderedTriangulation::_initTriangulation(), _initTriangulation(), clear(), fillIns(), gum::OrderedTriangulation::newFactory(), gum::PartialOrderedTriangulation::newFactory(), gum::OrderedTriangulation::OrderedTriangulation(), gum::PartialOrderedTriangulation::PartialOrderedTriangulation(), gum::OrderedTriangulation::setGraph(), gum::PartialOrderedTriangulation::setGraph(), gum::OrderedTriangulation::setOrder(), gum::PartialOrderedTriangulation::setPartialOrder(), StaticTriangulation(), and ~StaticTriangulation().
|
protected |
the junction tree strategy used by the triangulation
Definition at line 234 of file staticTriangulation.h.
Referenced by __computeMaxPrimeJunctionTree(), clear(), gum::OrderedTriangulation::newFactory(), gum::PartialOrderedTriangulation::newFactory(), StaticTriangulation(), and ~StaticTriangulation().