30 template<
class BAYESTREE,
class GRAPH,
class ETREE_NODE>
45 parentData(_parentData) {
50 const std::shared_ptr<ETREE_NODE>& node,
57 std::make_shared<Node>(node->key, node->factors);
64 const std::shared_ptr<ETREE_NODE>& ETreeNode,
80 symbolicFactors.
push_back(ETreeNode->factors);
85 keyAsOrdering.push_back(ETreeNode->key);
86 const auto [myConditional, mySeparatorFactor] =
96 node->problemSize_ = (
int) (myConditional->size() * symbolicFactors.
size());
100 const size_t myNrParents = myConditional->nrParents();
101 const size_t nrChildren = node->nrChildren();
102 assert(childConditionals.size() == nrChildren);
105 std::vector<size_t> nrFrontals = node->nrFrontalsOfChildren();
106 std::vector<bool> merge(nrChildren,
false);
107 size_t myNrFrontals = 1;
108 for (
size_t i = 0;
i<nrChildren;
i++){
110 if (myNrParents + myNrFrontals == childConditionals[
i]->nrParents()) {
112 myNrFrontals += nrFrontals[
i];
118 node->mergeChildren(merge);
123 template<
class BAYESTREE,
class GRAPH>
124 template<
class ETREE_BAYESNET,
class ETREE_GRAPH>
127 gttic(JunctionTree_FromEliminationTree);
141 rootData.junctionTreeNode = std::make_shared<typename Base::Node>();
143 Data::ConstructorTraversalVisitorPre,
144 Data::ConstructorTraversalVisitorPostAlg2);
147 this->addChildrenAsRoots(rootData.junctionTreeNode);
static ConstructorTraversalData ConstructorTraversalVisitorPre(const std::shared_ptr< ETREE_NODE > &node, ConstructorTraversalData &parentData)
JunctionTree< BAYESTREE, GRAPH >::sharedNode sharedNode
IsDerived< DERIVEDFACTOR > push_back(std::shared_ptr< DERIVEDFACTOR > factor)
Add a factor directly using a shared_ptr.
sharedNode junctionTreeNode
std::vector< T, typename internal::FastDefaultVectorAllocator< T >::type > FastVector
std::pair< std::shared_ptr< SymbolicConditional >, std::shared_ptr< SymbolicFactor > > EliminateSymbolic(const FactorGraph< FACTOR > &factors, const Ordering &keys)
void DepthFirstForest(FOREST &forest, DATA &rootData, VISITOR_PRE &visitorPre, VISITOR_POST &visitorPost)
Collects factorgraph fragments defined on variable clusters, arranged in a tree.
JunctionTree< BAYESTREE, GRAPH >::Node Node
const FastVector< sharedFactor > & remainingFactors() const
ConstructorTraversalData(ConstructorTraversalData *_parentData)
A Cluster is just a collection of factors.
ConstructorTraversalData *const parentData
void reserve(size_t size)
static void ConstructorTraversalVisitorPostAlg2(const std::shared_ptr< ETREE_NODE > &ETreeNode, const ConstructorTraversalData &myData)
FastVector< SymbolicConditional::shared_ptr > childSymbolicConditionals
FastVector< SymbolicFactor::shared_ptr > childSymbolicFactors