diff --git a/inference/ClusterTree.h b/inference/ClusterTree.h index a2473a37b..5cf9f2bb3 100644 --- a/inference/ClusterTree.h +++ b/inference/ClusterTree.h @@ -8,8 +8,8 @@ #pragma once -#include #include +#include "Ordering.h" namespace gtsam { @@ -24,41 +24,23 @@ namespace gtsam { public: // the class for subgraphs that also include the pointers to the parents and two children - class Cluster : public FG { - - public: + struct Cluster : public FG { typedef typename boost::shared_ptr shared_ptr; - /* commented private out to make compile but needs to be addressed */ - - shared_ptr parent_; // the parent subgraph node + shared_ptr parent_; // the parent cluster std::vector children_; // the child clusters Ordering frontal_; // the frontal variables Unordered separator_; // the separator variables - public: - // empty constructor Cluster() {} - // constructor with all the information - Cluster(const FG& fgLocal, const Ordering& frontal, const Unordered& separator, - const shared_ptr& parent) - : frontal_(frontal), separator_(separator), FG(fgLocal), parent_(parent) {} - - // constructor for an empty graph - Cluster(const Ordering& frontal, const Unordered& separator, const shared_ptr& parent) - : frontal_(frontal), separator_(separator), parent_(parent) {} - // return the members const Ordering& frontal() const { return frontal_;} const Unordered& separator() const { return separator_;} const std::vector& children() { return children_; } - // add a child node - void addChild(const shared_ptr& child) { children_.push_back(child); } - // print the object void print(const std::string& indent) const; void printTree(const std::string& indent) const; diff --git a/inference/JunctionTree.h b/inference/JunctionTree.h index 63827254d..7c1891109 100644 --- a/inference/JunctionTree.h +++ b/inference/JunctionTree.h @@ -23,34 +23,37 @@ namespace gtsam { * represent the clique tree associated with a Bayes net, and the JunctionTree is * used to collect the factors associated with each clique during the elimination process. */ - template - class JunctionTree : public ClusterTree { + template + class JunctionTree: public ClusterTree { public: - /** - * In a junction tree each cluster is associated with a clique - */ + // In a junction tree each cluster is associated with a clique typedef typename ClusterTree::Cluster Clique; typedef typename Clique::shared_ptr sharedClique; + // And we will frequently refer to a symbolic Bayes tree + typedef BayesTree SymbolicBayesTree; + private: // distribute the factors along the Bayes tree - sharedClique distributeFactors(FG& fg, const BayesTree::sharedClique clique); + sharedClique distributeFactors(FG& fg, + const SymbolicBayesTree::sharedClique clique); // utility function called by eliminate - template + template std::pair > eliminateOneClique(sharedClique fg_); public: // constructor - JunctionTree() {} + JunctionTree() { + } // constructor given a factor graph and the elimination ordering JunctionTree(FG& fg, const Ordering& ordering); // eliminate the factors in the subgraphs - template + template BayesTree eliminate(); }; // JunctionTree diff --git a/linear/GaussianFactorGraph.cpp b/linear/GaussianFactorGraph.cpp index 48e8a2f6f..560daf1a4 100644 --- a/linear/GaussianFactorGraph.cpp +++ b/linear/GaussianFactorGraph.cpp @@ -16,7 +16,7 @@ #include "FactorGraph-inl.h" #include "inference-inl.h" #include "iterative.h" -#include "GaussianJunctionTree.h" +//#include "GaussianJunctionTree.h" using namespace std; using namespace gtsam; @@ -297,12 +297,12 @@ VectorConfig GaussianFactorGraph::optimize(const Ordering& ordering, bool old) } /* ************************************************************************* */ -VectorConfig GaussianFactorGraph::optimizeMultiFrontals(const Ordering& ordering) -{ - GaussianJunctionTree junctionTree(*this, ordering); - - return junctionTree.optimize(); -} +//VectorConfig GaussianFactorGraph::optimizeMultiFrontals(const Ordering& ordering) +//{ +// GaussianJunctionTree junctionTree(*this, ordering); +// +// return junctionTree.optimize(); +//} /* ************************************************************************* */ boost::shared_ptr