30template<
class BAYESTREE,
class GRAPH,
class ETREE_NODE>
33 typedef typename JunctionTree<BAYESTREE, GRAPH>::sharedNode sharedNode;
36 sharedNode junctionTreeNode;
45 parentData(_parentData) {
50 const boost::shared_ptr<ETREE_NODE>& node,
56 myData.junctionTreeNode =
57 boost::make_shared<Node>(node->key, node->factors);
58 parentData.junctionTreeNode->addChild(myData.junctionTreeNode);
63 static void ConstructorTraversalVisitorPostAlg2(
64 const boost::shared_ptr<ETREE_NODE>& ETreeNode,
65 const ConstructorTraversalData& myData) {
76 SymbolicFactors symbolicFactors;
77 symbolicFactors.reserve(
78 ETreeNode->factors.size() + myData.childSymbolicFactors.size());
80 symbolicFactors += ETreeNode->factors;
82 symbolicFactors += myData.childSymbolicFactors;
85 keyAsOrdering.push_back(ETreeNode->key);
88 boost::tie(myConditional, mySeparatorFactor) = internal::EliminateSymbolic(
89 symbolicFactors, keyAsOrdering);
92 myData.parentData->childSymbolicConditionals.push_back(myConditional);
93 myData.parentData->childSymbolicFactors.push_back(mySeparatorFactor);
95 sharedNode node = myData.junctionTreeNode;
97 myData.childSymbolicConditionals;
98 node->problemSize_ = (int) (myConditional->size() * symbolicFactors.size());
102 const size_t myNrParents = myConditional->nrParents();
103 const size_t nrChildren = node->nrChildren();
104 assert(childConditionals.size() == nrChildren);
107 std::vector<size_t> nrFrontals = node->nrFrontalsOfChildren();
108 std::vector<bool> merge(nrChildren,
false);
109 size_t myNrFrontals = 1;
110 for (
size_t i = 0;i<nrChildren;i++){
112 if (myNrParents + myNrFrontals == childConditionals[i]->nrParents()) {
114 myNrFrontals += nrFrontals[i];
120 node->mergeChildren(merge);
125template<
class BAYESTREE,
class GRAPH>
126template<
class ETREE_BAYESNET,
class ETREE_GRAPH>
129 gttic(JunctionTree_FromEliminationTree);
143 rootData.junctionTreeNode = boost::make_shared<typename Base::Node>();
145 Data::ConstructorTraversalVisitorPre,
146 Data::ConstructorTraversalVisitorPostAlg2);
149 this->addChildrenAsRoots(rootData.junctionTreeNode);
Collects factorgraph fragments defined on variable clusters, arranged in a tree.
std::vector< T, typename internal::FastDefaultVectorAllocator< T >::type > FastVector
FastVector is a type alias to a std::vector with a custom memory allocator.
Definition: FastVector.h:34
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
void DepthFirstForest(FOREST &forest, DATA &rootData, VISITOR_PRE &visitorPre, VISITOR_POST &visitorPost)
Traverse a forest depth-first with pre-order and post-order visits.
Definition: treeTraversal-inst.h:77
A factor graph is a bipartite graph with factor nodes connected to variable nodes.
Definition: FactorGraph.h:97
A Cluster is just a collection of factors.
Definition: ClusterTree.h:36
An elimination tree is a data structure used intermediately during elimination.
Definition: EliminationTree.h:52
const FastVector< sharedFactor > & remainingFactors() const
Return the remaining factors that are not pulled into elimination.
Definition: EliminationTree.h:154
Definition: EliminationTree.h:66
Definition: JunctionTree-inst.h:31
Definition: JunctionTree-inst.h:41
A JunctionTree is a cluster tree, a set of variable clusters with factors, arranged in a tree,...
Definition: JunctionTree.h:50
Definition: Ordering.h:34
boost::shared_ptr< This > shared_ptr
Typedef to the conditional base class.
Definition: SymbolicConditional.h:44
boost::shared_ptr< This > shared_ptr
Overriding the shared_ptr typedef.
Definition: SymbolicFactor.h:48