24 template <
class GRAPH>
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_);
77 return children.size();
81 return factors.size();
85 return orderedFrontalKeys.size();
93 virtual void print(
const std::string&
s =
"",
100 void merge(
const std::shared_ptr<Cluster>& cluster);
138 void print(
const std::string&
s =
"",
145 void addRoot(
const std::shared_ptr<Cluster>& cluster) {
146 roots_.push_back(cluster);
150 for (
auto child : cluster->children)
155 return roots_.size();
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)
const gtsam::Symbol key('X', 0)
ClusterTree()
Default constructor.
GRAPH FactorGraphType
The factor graph type.
FactorGraphType factors
Factors associated with this node.
Concept check for values that can be used in unit tests.
FastVector< sharedNode > roots_
BAYESTREE::ConditionalType ConditionalType
The type of conditionals.
std::vector< T, typename internal::FastDefaultVectorAllocator< T >::type > FastVector
GRAPH::FactorType FactorType
The type of factors.
std::shared_ptr< This > shared_ptr
Shared pointer to this class.
void merge(const std::shared_ptr< Cluster > &cluster)
Merge in given cluster.
void addChild(const std::shared_ptr< Cluster > &cluster)
Add a child cluster.
const Cluster & operator[](size_t i) const
EliminatableClusterTree< BAYESTREE, GRAPH > This
This class.
GRAPH::FactorType FactorType
The type of factors.
This & operator=(const This &other)
#define GTSAM_CONCEPT_TESTABLE_TYPE(T)
size_t nrFrontals() const
std::shared_ptr< This > shared_ptr
Shared pointer to this class.
static const KeyFormatter DefaultKeyFormatter
EliminatableClusterTree()
Default constructor to be used in derived classes.
size_t nrChildren() const
const FastVector< sharedNode > & roots() const
void addChildrenAsRoots(const std::shared_ptr< Cluster > &cluster)
Collects factorgraph fragments defined on variable clusters, arranged in a tree.
std::shared_ptr< Cluster > sharedCluster
Shared pointer to Cluster.
const Cluster & operator[](size_t i) const
const FastVector< sharedFactor > & remainingFactors() const
ClusterTree(const This &other)
std::vector< size_t > nrFrontalsOfChildren() const
Return a vector with nrFrontal keys for each child.
BAYESTREE BayesTreeType
The BayesTree type produced by elimination.
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
A thin wrapper around std::vector that uses a custom allocator.
Keys orderedFrontalKeys
Frontal keys of this node.
FastVector< std::shared_ptr< Cluster > > Children
A Cluster is just a collection of factors.
void addFactors(Key key, const CONTAINER &factorsToAdd)
Add factors associated with a single key.
Children children
sub-trees
std::shared_ptr< FactorType > sharedFactor
Shared pointer to a factor.
GRAPH::Eliminate Eliminate
Typedef for an eliminate subroutine.
FastVector< sharedFactor > remainingFactors_
ClusterTree< GRAPH > This
This class.
void mergeChildren(const std::vector< bool > &merge)
Merge all children for which bit is set into this node.
std::shared_ptr< FactorType > sharedFactor
Shared pointer to a factor.
std::uint64_t Key
Integer nonlinear key type.
void addRoot(const std::shared_ptr< Cluster > &cluster)
GRAPH FactorGraphType
The factor graph type.
Cluster(Key key, const CONTAINER &factorsToAdd)
Construct from factors associated with a single key.
virtual void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
print this node
std::shared_ptr< ConditionalType > sharedConditional
Shared pointer to a conditional.