24 #include <unordered_map> 29 template class EliminatableClusterTree<HybridBayesTree,
30 HybridGaussianFactorGraph>;
31 template class JunctionTree<HybridBayesTree, HybridGaussianFactorGraph>;
49 : parentData(_parentData) {}
53 const std::shared_ptr<HybridEliminationTree::Node>& node,
64 for (
const auto&
f : node->factors) {
65 if (
auto hf = std::dynamic_pointer_cast<HybridFactor>(
f)) {
66 for (
auto& k : hf->discreteKeys()) {
69 }
else if (
auto hf = std::dynamic_pointer_cast<DecisionTreeFactor>(
f)) {
70 for (
auto& k : hf->discreteKeys()) {
81 const std::shared_ptr<HybridEliminationTree::Node>& node,
94 symbolicFactors.
reserve(node->factors.size() +
102 keyAsOrdering.push_back(node->key);
103 const auto [conditional, separatorFactor] =
114 jt_node->problemSize_ = (
int)(conditional->size() * symbolicFactors.
size());
118 const size_t nrParents = conditional->nrParents();
119 const size_t nrChildren = jt_node->nrChildren();
120 assert(childConditionals.size() == nrChildren);
123 std::vector<size_t> nrChildrenFrontals = jt_node->nrFrontalsOfChildren();
124 std::vector<bool> merge(nrChildren,
false);
125 size_t nrFrontals = 1;
126 for (
size_t i = 0;
i < nrChildren;
i++) {
128 if (nrParents + nrFrontals == childConditionals[
i]->nrParents()) {
131 const bool theirType =
134 if (myType == theirType) {
136 nrFrontals += nrChildrenFrontals[
i];
143 jt_node->mergeChildren(merge);
150 gttic(JunctionTree_FromEliminationTree);
162 rootData.junctionTreeNode =
163 std::make_shared<typename Base::Node>();
166 Data::ConstructorTraversalVisitorPre,
167 Data::ConstructorTraversalVisitorPost);
170 this->addChildrenAsRoots(rootData.junctionTreeNode);
HybridJunctionTree::Node Node
FastVector< SymbolicConditional::shared_ptr > childSymbolicConditionals
HybridJunctionTree(const HybridEliminationTree &eliminationTree)
IsDerived< DERIVEDFACTOR > push_back(std::shared_ptr< DERIVEDFACTOR > factor)
Add a factor directly using a shared_ptr.
std::vector< T, typename internal::FastDefaultVectorAllocator< T >::type > FastVector
bool exists(const VALUE &e) const
JunctionTree< HybridBayesTree, HybridGaussianFactorGraph >::sharedNode sharedNode
void merge(const FastSet &other)
std::pair< std::shared_ptr< SymbolicConditional >, std::shared_ptr< SymbolicFactor > > EliminateSymbolic(const FactorGraph< FACTOR > &factors, const Ordering &keys)
FastVector< SymbolicFactor::shared_ptr > childSymbolicFactors
void DepthFirstForest(FOREST &forest, DATA &rootData, VISITOR_PRE &visitorPre, VISITOR_POST &visitorPost)
HybridConstructorTraversalData(HybridConstructorTraversalData *_parentData)
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
const FastVector< sharedFactor > & remainingFactors() const
Linearized Hybrid factor graph that uses type erasure.
static void ConstructorTraversalVisitorPost(const std::shared_ptr< HybridEliminationTree::Node > &node, const HybridConstructorTraversalData &data)
HybridConstructorTraversalData *const parentData
The junction tree, template bodies.
void reserve(size_t size)
sharedNode junctionTreeNode
static HybridConstructorTraversalData ConstructorTraversalVisitorPre(const std::shared_ptr< HybridEliminationTree::Node > &node, HybridConstructorTraversalData &parentData)