24 template <
class GRAPH>
37 typedef FastVector<boost::shared_ptr<Cluster> > Children;
51 const Cluster& operator[](
size_t i)
const {
56 template <
class CONTAINER>
63 template <
class CONTAINER>
66 factors.push_back(factorsToAdd);
71 void addChild(
const boost::shared_ptr<Cluster>& cluster) {
73 problemSize_ = std::max(problemSize_, cluster->problemSize_);
76 size_t nrChildren()
const {
80 size_t nrFactors()
const {
84 size_t nrFrontals()
const {
88 int problemSize()
const {
93 virtual void print(
const std::string& s =
"",
94 const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const;
100 void merge(
const boost::shared_ptr<Cluster>& cluster);
109 typedef Cluster Node;
116 FastVector<sharedNode> roots_;
138 void print(
const std::string& s =
"",
139 const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const;
146 void addRoot(
const boost::shared_ptr<Cluster>& cluster) {
147 roots_.push_back(cluster);
150 void addChildrenAsRoots(
const boost::shared_ptr<Cluster>& cluster) {
151 for (
auto child : cluster->children)
152 this->addRoot(child);
155 size_t nrRoots()
const {
156 return roots_.size();
160 const FastVector<sharedNode>&
roots()
const {
164 const Cluster& operator[](
size_t i)
const {
183 template <
class BAYESTREE,
class GRAPH>
184 class EliminatableClusterTree :
public ClusterTree<GRAPH> {
192 typedef boost::shared_ptr<ConditionalType>
200 FastVector<sharedFactor> remainingFactors_;
222 std::pair<boost::shared_ptr<BayesTreeType>, boost::shared_ptr<FactorGraphType> >
eliminate(
232 return remainingFactors_;
251 #include <gtsam/inference/ClusterTree-inst.h> const FastVector< sharedFactor > & remainingFactors() const
Return the remaining factors that are not pulled into elimination.
Definition: ClusterTree.h:231
boost::shared_ptr< FactorType > sharedFactor
Shared pointer to a factor.
Definition: ClusterTree.h:197
boost::shared_ptr< Cluster > sharedCluster
Shared pointer to Cluster.
Definition: ClusterTree.h:106
This & operator=(const This &other)
Assignment operator - makes a deep copy of the tree structure, but only pointers to factors are copie...
Definition: ClusterTree-inst.h:100
boost::shared_ptr< This > shared_ptr
Shared pointer to this class.
Definition: ClusterTree.h:29
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
Print the cluster tree.
Definition: ClusterTree-inst.h:94
boost::shared_ptr< ConditionalType > sharedConditional
Shared pointer to a conditional.
Definition: ClusterTree.h:193
GRAPH::Eliminate Eliminate
Typedef for an eliminate subroutine.
Definition: ClusterTree.h:195
A thin wrapper around std::vector that uses a custom allocator.
EliminatableClusterTree< BAYESTREE, GRAPH > This
This class.
Definition: ClusterTree.h:188
Children children
sub-trees
Definition: ClusterTree.h:38
GRAPH::FactorType FactorType
The type of factors.
Definition: ClusterTree.h:31
EliminatableClusterTree(const This &other)
Copy constructor - makes a deep copy of the tree structure, but only pointers to factors are copied,...
Definition: ClusterTree.h:207
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:57
ClusterTree< GRAPH > This
This class.
Definition: ClusterTree.h:28
boost::shared_ptr< FactorType > sharedFactor
Shared pointer to a factor.
Definition: ClusterTree.h:32
A cluster-tree that eliminates to a Bayes tree.
Definition: BayesTree.h:33
std::pair< boost::shared_ptr< BayesTreeType >, boost::shared_ptr< FactorGraphType > > eliminate(const Eliminate &function) const
Eliminate the factors to a Bayes tree and remaining factor graph.
Definition: ClusterTree-inst.h:221
A cluster-tree is associated with a factor graph and is defined as in Koller-Friedman: each node k re...
Definition: ClusterTree.h:25
Variable ordering for the elimination algorithm.
This & operator=(const This &other)
Assignment operator - makes a deep copy of the tree structure, but only pointers to factors are copie...
Definition: ClusterTree-inst.h:207
FactorGraphType factors
Factors associated with this node.
Definition: ClusterTree.h:43
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:33
void addFactors(Key key, const CONTAINER &factorsToAdd)
Add factors associated with a single key.
Definition: ClusterTree.h:64
Keys orderedFrontalKeys
Frontal keys of this node.
Definition: ClusterTree.h:41
EliminatableClusterTree()
Default constructor to be used in derived classes.
Definition: ClusterTree.h:245
void addChild(const boost::shared_ptr< Cluster > &cluster)
Add a child cluster.
Definition: ClusterTree.h:71
const FastVector< sharedNode > & roots() const
Return the set of roots (one for a tree, multiple for a forest)
Definition: ClusterTree.h:160
GRAPH FactorGraphType
The factor graph type.
Definition: ClusterTree.h:27
ClusterTree(const This &other)
Copy constructor - makes a deep copy of the tree structure, but only pointers to factors are copied,...
Definition: ClusterTree.h:123
GRAPH::FactorType FactorType
The type of factors.
Definition: ClusterTree.h:196
BAYESTREE BayesTreeType
The BayesTree type produced by elimination.
Definition: ClusterTree.h:186
std::vector< size_t > nrFrontalsOfChildren() const
Return a vector with nrFrontal keys for each child.
Definition: ClusterTree-inst.h:30
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
Cluster(Key key, const CONTAINER &factorsToAdd)
Construct from factors associated with a single key.
Definition: ClusterTree.h:57
Concept check for values that can be used in unit tests.
GRAPH FactorGraphType
The factor graph type.
Definition: ClusterTree.h:187
boost::shared_ptr< This > shared_ptr
Shared pointer to this class.
Definition: ClusterTree.h:189
BAYESTREE::ConditionalType ConditionalType
The type of conditionals.
Definition: ClusterTree.h:191
Definition: Ordering.h:34
void mergeChildren(const std::vector< bool > &merge)
Merge all children for which bit is set into this node.
Definition: ClusterTree-inst.h:52
ClusterTree()
Default constructor.
Definition: ClusterTree.h:132
virtual void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
print this node
Definition: ClusterTree-inst.h:22
A Cluster is just a collection of factors.
Definition: ClusterTree.h:36
void merge(const boost::shared_ptr< Cluster > &cluster)
Merge in given cluster.
Definition: ClusterTree-inst.h:40
GTSAM_CONCEPT_TESTABLE_TYPE(FactorType)
concept check