Simplified Cluster class, commented out JT stuff in GFG to not trigger big recompiles
parent
d07dfac236
commit
37298fa609
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#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<Cluster> 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<shared_ptr> 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<shared_ptr>& 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;
|
||||
|
|
|
|||
|
|
@ -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 FG>
|
||||
class JunctionTree : public ClusterTree<FG> {
|
||||
template<class FG>
|
||||
class JunctionTree: public ClusterTree<FG> {
|
||||
|
||||
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<FG>::Cluster Clique;
|
||||
typedef typename Clique::shared_ptr sharedClique;
|
||||
|
||||
// And we will frequently refer to a symbolic Bayes tree
|
||||
typedef BayesTree<SymbolicConditional> SymbolicBayesTree;
|
||||
|
||||
private:
|
||||
// distribute the factors along the Bayes tree
|
||||
sharedClique distributeFactors(FG& fg, const BayesTree<SymbolicConditional>::sharedClique clique);
|
||||
sharedClique distributeFactors(FG& fg,
|
||||
const SymbolicBayesTree::sharedClique clique);
|
||||
|
||||
// utility function called by eliminate
|
||||
template <class Conditional>
|
||||
template<class Conditional>
|
||||
std::pair<FG, BayesTree<Conditional> > 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 <class Conditional>
|
||||
template<class Conditional>
|
||||
BayesTree<Conditional> eliminate();
|
||||
|
||||
}; // JunctionTree
|
||||
|
|
|
|||
|
|
@ -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<GaussianBayesNet>
|
||||
|
|
|
|||
Loading…
Reference in New Issue