Simplified Cluster class, commented out JT stuff in GFG to not trigger big recompiles
parent
d07dfac236
commit
37298fa609
|
|
@ -8,8 +8,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <set>
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
#include "Ordering.h"
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
|
|
@ -24,41 +24,23 @@ namespace gtsam {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// the class for subgraphs that also include the pointers to the parents and two children
|
// the class for subgraphs that also include the pointers to the parents and two children
|
||||||
class Cluster : public FG {
|
struct Cluster : public FG {
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
typedef typename boost::shared_ptr<Cluster> shared_ptr;
|
typedef typename boost::shared_ptr<Cluster> shared_ptr;
|
||||||
|
|
||||||
/* commented private out to make compile but needs to be addressed */
|
shared_ptr parent_; // the parent cluster
|
||||||
|
|
||||||
shared_ptr parent_; // the parent subgraph node
|
|
||||||
std::vector<shared_ptr> children_; // the child clusters
|
std::vector<shared_ptr> children_; // the child clusters
|
||||||
Ordering frontal_; // the frontal variables
|
Ordering frontal_; // the frontal variables
|
||||||
Unordered separator_; // the separator variables
|
Unordered separator_; // the separator variables
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// empty constructor
|
// empty constructor
|
||||||
Cluster() {}
|
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
|
// return the members
|
||||||
const Ordering& frontal() const { return frontal_;}
|
const Ordering& frontal() const { return frontal_;}
|
||||||
const Unordered& separator() const { return separator_;}
|
const Unordered& separator() const { return separator_;}
|
||||||
const std::vector<shared_ptr>& children() { return children_; }
|
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
|
// print the object
|
||||||
void print(const std::string& indent) const;
|
void print(const std::string& indent) const;
|
||||||
void printTree(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
|
* 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.
|
* used to collect the factors associated with each clique during the elimination process.
|
||||||
*/
|
*/
|
||||||
template <class FG>
|
template<class FG>
|
||||||
class JunctionTree : public ClusterTree<FG> {
|
class JunctionTree: public ClusterTree<FG> {
|
||||||
|
|
||||||
public:
|
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 ClusterTree<FG>::Cluster Clique;
|
||||||
typedef typename Clique::shared_ptr sharedClique;
|
typedef typename Clique::shared_ptr sharedClique;
|
||||||
|
|
||||||
|
// And we will frequently refer to a symbolic Bayes tree
|
||||||
|
typedef BayesTree<SymbolicConditional> SymbolicBayesTree;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// distribute the factors along the Bayes tree
|
// 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
|
// utility function called by eliminate
|
||||||
template <class Conditional>
|
template<class Conditional>
|
||||||
std::pair<FG, BayesTree<Conditional> > eliminateOneClique(sharedClique fg_);
|
std::pair<FG, BayesTree<Conditional> > eliminateOneClique(sharedClique fg_);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// constructor
|
// constructor
|
||||||
JunctionTree() {}
|
JunctionTree() {
|
||||||
|
}
|
||||||
|
|
||||||
// constructor given a factor graph and the elimination ordering
|
// constructor given a factor graph and the elimination ordering
|
||||||
JunctionTree(FG& fg, const Ordering& ordering);
|
JunctionTree(FG& fg, const Ordering& ordering);
|
||||||
|
|
||||||
// eliminate the factors in the subgraphs
|
// eliminate the factors in the subgraphs
|
||||||
template <class Conditional>
|
template<class Conditional>
|
||||||
BayesTree<Conditional> eliminate();
|
BayesTree<Conditional> eliminate();
|
||||||
|
|
||||||
}; // JunctionTree
|
}; // JunctionTree
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
#include "FactorGraph-inl.h"
|
#include "FactorGraph-inl.h"
|
||||||
#include "inference-inl.h"
|
#include "inference-inl.h"
|
||||||
#include "iterative.h"
|
#include "iterative.h"
|
||||||
#include "GaussianJunctionTree.h"
|
//#include "GaussianJunctionTree.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace gtsam;
|
using namespace gtsam;
|
||||||
|
|
@ -297,12 +297,12 @@ VectorConfig GaussianFactorGraph::optimize(const Ordering& ordering, bool old)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
VectorConfig GaussianFactorGraph::optimizeMultiFrontals(const Ordering& ordering)
|
//VectorConfig GaussianFactorGraph::optimizeMultiFrontals(const Ordering& ordering)
|
||||||
{
|
//{
|
||||||
GaussianJunctionTree junctionTree(*this, ordering);
|
// GaussianJunctionTree junctionTree(*this, ordering);
|
||||||
|
//
|
||||||
return junctionTree.optimize();
|
// return junctionTree.optimize();
|
||||||
}
|
//}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
boost::shared_ptr<GaussianBayesNet>
|
boost::shared_ptr<GaussianBayesNet>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue