24 template <
class GRAPH>
51 const Cluster& operator[](
size_t i)
const {
52 return *(children[i]);
56 template <
class CONTAINER>
63 template <
class CONTAINER>
65 orderedFrontalKeys.push_back(key);
66 factors.push_back(factorsToAdd);
67 problemSize_ += factors.size();
71 void addChild(
const std::shared_ptr<Cluster>& cluster) {
72 children.push_back(cluster);
73 problemSize_ = std::max(problemSize_, cluster->problemSize_);
76 size_t nrChildren()
const {
77 return children.size();
80 size_t nrFactors()
const {
81 return factors.size();
84 size_t nrFrontals()
const {
85 return orderedFrontalKeys.size();
88 int problemSize()
const {
93 virtual void print(
const std::string& s =
"",
94 const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const;
100 void merge(
const std::shared_ptr<Cluster>& cluster);
109 typedef Cluster Node;
110 typedef sharedCluster sharedNode;
113 GTSAM_CONCEPT_TESTABLE_TYPE(FactorType)
138 void print(
const std::string& s =
"",
139 const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const;
145 void addRoot(
const std::shared_ptr<Cluster>& cluster) {
146 roots_.push_back(cluster);
149 void addChildrenAsRoots(
const std::shared_ptr<Cluster>& cluster) {
150 for (
auto child : cluster->children)
151 this->addRoot(child);
154 size_t nrRoots()
const {
155 return roots_.size();
163 const Cluster& operator[](
size_t i)
const {
185 template <
class BAYESTREE,
class GRAPH>
194 typedef std::shared_ptr<ConditionalType>
224 std::pair<std::shared_ptr<BayesTreeType>, std::shared_ptr<FactorGraphType> > eliminate(
225 const Eliminate&
function)
const;
234 return remainingFactors_;
EliminatableClusterTree(const This &other)
Definition: ClusterTree.h:209
ClusterTree()
Default constructor.
Definition: ClusterTree.h:132
GRAPH FactorGraphType
The factor graph type.
Definition: ClusterTree.h:189
FactorGraphType factors
Factors associated with this node.
Definition: ClusterTree.h:43
Concept check for values that can be used in unit tests.
FastVector< sharedNode > roots_
Definition: ClusterTree.h:116
BAYESTREE::ConditionalType ConditionalType
The type of conditionals.
Definition: ClusterTree.h:193
std::vector< T, typename internal::FastDefaultVectorAllocator< T >::type > FastVector
Definition: FastVector.h:34
GRAPH::FactorType FactorType
The type of factors.
Definition: ClusterTree.h:198
std::shared_ptr< This > shared_ptr
Shared pointer to this class.
Definition: ClusterTree.h:191
void merge(const std::shared_ptr< Cluster > &cluster)
Merge in given cluster.
Definition: ClusterTree-inst.h:45
void addChild(const std::shared_ptr< Cluster > &cluster)
Add a child cluster.
Definition: ClusterTree.h:71
Variable ordering for the elimination algorithm.
EliminatableClusterTree< BAYESTREE, GRAPH > This
This class.
Definition: ClusterTree.h:190
Definition: Ordering.h:37
GRAPH::FactorType FactorType
The type of factors.
Definition: ClusterTree.h:31
This & operator=(const This &other)
Definition: ClusterTree-inst.h:140
std::shared_ptr< This > shared_ptr
Shared pointer to this class.
Definition: ClusterTree.h:29
EliminatableClusterTree()
Default constructor to be used in derived classes.
Definition: ClusterTree.h:248
const FastVector< sharedNode > & roots() const
Definition: ClusterTree.h:159
Collects factorgraph fragments defined on variable clusters, arranged in a tree.
Definition: BayesTree.h:35
std::shared_ptr< Cluster > sharedCluster
Shared pointer to Cluster.
Definition: ClusterTree.h:106
const FastVector< sharedFactor > & remainingFactors() const
Definition: ClusterTree.h:233
ClusterTree(const This &other)
Definition: ClusterTree.h:123
std::vector< size_t > nrFrontalsOfChildren() const
Return a vector with nrFrontal keys for each child.
Definition: ClusterTree-inst.h:35
BAYESTREE BayesTreeType
The BayesTree type produced by elimination.
Definition: ClusterTree.h:188
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:35
A thin wrapper around std::vector that uses a custom allocator.
Keys orderedFrontalKeys
Frontal keys of this node.
Definition: ClusterTree.h:41
Definition: chartTesting.h:28
A Cluster is just a collection of factors.
Definition: ClusterTree.h:36
void addFactors(Key key, const CONTAINER &factorsToAdd)
Add factors associated with a single key.
Definition: ClusterTree.h:64
Children children
sub-trees
Definition: ClusterTree.h:38
std::shared_ptr< FactorType > sharedFactor
Shared pointer to a factor.
Definition: ClusterTree.h:32
GRAPH::Eliminate Eliminate
Typedef for an eliminate subroutine.
Definition: ClusterTree.h:197
ClusterTree< GRAPH > This
This class.
Definition: ClusterTree.h:28
void mergeChildren(const std::vector< bool > &merge)
Merge all children for which bit is set into this node.
Definition: ClusterTree-inst.h:57
std::shared_ptr< FactorType > sharedFactor
Shared pointer to a factor.
Definition: ClusterTree.h:199
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102
Definition: ClusterTree.h:25
GRAPH FactorGraphType
The factor graph type.
Definition: ClusterTree.h:27
Cluster(Key key, const CONTAINER &factorsToAdd)
Construct from factors associated with a single key.
Definition: ClusterTree.h:57
virtual void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
print this node
Definition: ClusterTree-inst.h:27
std::shared_ptr< ConditionalType > sharedConditional
Shared pointer to a conditional.
Definition: ClusterTree.h:195