split JunctionTree to GaussianJunctionTree
parent
3736d73413
commit
f67220773a
|
@ -16,7 +16,7 @@
|
|||
#include "FactorGraph-inl.h"
|
||||
#include "inference-inl.h"
|
||||
#include "iterative.h"
|
||||
#include "JunctionTree-inl.h"
|
||||
#include "GaussianJunctionTree-inl.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace gtsam;
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* GaussianJunctionTree-inl.h
|
||||
*
|
||||
* Created on: Jul 12, 2010
|
||||
* Author: nikai
|
||||
* Description: the Gaussian junction tree
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include "JunctionTree-inl.h"
|
||||
#include "GaussianJunctionTree.h"
|
||||
|
||||
namespace gtsam {
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ************************************************************************* */
|
||||
/**
|
||||
* GaussianJunctionTree
|
||||
*/
|
||||
template <class FG>
|
||||
void GaussianJunctionTree<FG>::btreeBackSubstitue(typename BayesTree<GaussianConditional>::sharedClique current, VectorConfig& config) {
|
||||
// solve the bayes net in the current node
|
||||
typename BayesNet<GaussianConditional>::const_reverse_iterator it = current->rbegin();
|
||||
for (; it!=current->rend(); it++) {
|
||||
Vector x = (*it)->solve(config); // Solve for that variable
|
||||
config.insert((*it)->key(),x); // store result in partial solution
|
||||
}
|
||||
|
||||
// solve the bayes nets in the child nodes
|
||||
typedef typename BayesTree<GaussianConditional>::sharedClique sharedBayesClique;
|
||||
BOOST_FOREACH(sharedBayesClique child, current->children_) {
|
||||
btreeBackSubstitue(child, config);
|
||||
}
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
template <class FG>
|
||||
VectorConfig GaussianJunctionTree<FG>::optimize() {
|
||||
// eliminate from leaves to the root
|
||||
typedef JunctionTree<FG> Base;
|
||||
BayesTree<GaussianConditional> bayesTree;
|
||||
this->eliminate<GaussianConditional>();
|
||||
|
||||
// back-substitution
|
||||
VectorConfig result;
|
||||
btreeBackSubstitue(bayesTree.root(), result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
} //namespace gtsam
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* GaussianJunctionTree.h
|
||||
*
|
||||
* Created on: Jul 12, 2010
|
||||
* Author: nikai
|
||||
* Description: the Gaussian junction tree
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "JunctionTree.h"
|
||||
#include "GaussianConditional.h"
|
||||
#include "GaussianFactorGraph.h"
|
||||
|
||||
namespace gtsam {
|
||||
|
||||
/* ************************************************************************* */
|
||||
/**
|
||||
* GaussianJunctionTree that does the optimization
|
||||
*/
|
||||
template <class FG>
|
||||
class GaussianJunctionTree: public JunctionTree<FG> {
|
||||
public:
|
||||
typedef JunctionTree<FG> Base;
|
||||
typedef typename JunctionTree<FG>::sharedClique sharedClique;
|
||||
|
||||
protected:
|
||||
// back-substitute in topological sort order (parents first)
|
||||
void btreeBackSubstitue(typename BayesTree<GaussianConditional>::sharedClique current, VectorConfig& config);
|
||||
|
||||
public :
|
||||
|
||||
GaussianJunctionTree() : Base() {}
|
||||
|
||||
// constructor
|
||||
GaussianJunctionTree(FG& fg, const Ordering& ordering) : Base(fg, ordering) {}
|
||||
|
||||
// optimize the linear graph
|
||||
VectorConfig optimize();
|
||||
}; // GaussianJunctionTree
|
||||
|
||||
} // namespace gtsam
|
|
@ -156,38 +156,4 @@ namespace gtsam {
|
|||
return root_->equals(*other.root_);
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
/**
|
||||
* GaussianJunctionTree
|
||||
*/
|
||||
template <class FG>
|
||||
void GaussianJunctionTree<FG>::btreeBackSubstitue(typename BayesTree<GaussianConditional>::sharedClique current, VectorConfig& config) {
|
||||
// solve the bayes net in the current node
|
||||
typename BayesNet<GaussianConditional>::const_reverse_iterator it = current->rbegin();
|
||||
for (; it!=current->rend(); it++) {
|
||||
Vector x = (*it)->solve(config); // Solve for that variable
|
||||
config.insert((*it)->key(),x); // store result in partial solution
|
||||
}
|
||||
|
||||
// solve the bayes nets in the child nodes
|
||||
typedef typename BayesTree<GaussianConditional>::sharedClique sharedBayesClique;
|
||||
BOOST_FOREACH(sharedBayesClique child, current->children_) {
|
||||
btreeBackSubstitue(child, config);
|
||||
}
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
template <class FG>
|
||||
VectorConfig GaussianJunctionTree<FG>::optimize() {
|
||||
// eliminate from leaves to the root
|
||||
typedef JunctionTree<FG> Base;
|
||||
BayesTree<GaussianConditional> bayesTree;
|
||||
this->eliminate<GaussianConditional>();
|
||||
|
||||
// back-substitution
|
||||
VectorConfig result;
|
||||
btreeBackSubstitue(bayesTree.root(), result);
|
||||
return result;
|
||||
}
|
||||
|
||||
} //namespace gtsam
|
||||
|
|
|
@ -10,10 +10,8 @@
|
|||
|
||||
#include <set>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include "GaussianConditional.h"
|
||||
#include "GaussianFactorGraph.h"
|
||||
#include "BayesTree.h"
|
||||
#include "SymbolicConditional.h"
|
||||
|
||||
namespace gtsam {
|
||||
|
||||
|
@ -102,29 +100,4 @@ namespace gtsam {
|
|||
|
||||
}; // JunctionTree
|
||||
|
||||
/* ************************************************************************* */
|
||||
/**
|
||||
* GaussianJunctionTree that does the optimization
|
||||
*/
|
||||
template <class FG>
|
||||
class GaussianJunctionTree: public JunctionTree<FG> {
|
||||
public:
|
||||
typedef JunctionTree<FG> Base;
|
||||
typedef typename JunctionTree<FG>::sharedClique sharedClique;
|
||||
|
||||
protected:
|
||||
// back-substitute in topological sort order (parents first)
|
||||
void btreeBackSubstitue(typename BayesTree<GaussianConditional>::sharedClique current, VectorConfig& config);
|
||||
|
||||
public :
|
||||
|
||||
GaussianJunctionTree() : Base() {}
|
||||
|
||||
// constructor
|
||||
GaussianJunctionTree(FG& fg, const Ordering& ordering) : Base(fg, ordering) {}
|
||||
|
||||
// optimize the linear graph
|
||||
VectorConfig optimize();
|
||||
}; // GaussianJunctionTree
|
||||
|
||||
} // namespace gtsam
|
||||
|
|
|
@ -25,11 +25,12 @@ headers += inference.h inference-inl.h
|
|||
headers += graph.h graph-inl.h
|
||||
headers += FactorGraph.h FactorGraph-inl.h
|
||||
headers += JunctionTree.h JunctionTree-inl.h
|
||||
headers += GaussianJunctionTree.h GaussianJunctionTree-inl.h
|
||||
headers += BayesNet.h BayesNet-inl.h
|
||||
headers += BayesTree.h BayesTree-inl.h
|
||||
headers += ISAM.h ISAM-inl.h
|
||||
headers += ISAM2.h ISAM2-inl.h
|
||||
check_PROGRAMS += testFactorGraph testJunctionTree testOrdering
|
||||
check_PROGRAMS += testFactorGraph testGaussianJunctionTree testOrdering
|
||||
check_PROGRAMS += testBayesTree testISAM
|
||||
|
||||
#----------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -16,7 +16,7 @@ using namespace boost::assign;
|
|||
|
||||
#define GTSAM_MAGIC_KEY
|
||||
|
||||
#include "JunctionTree-inl.h"
|
||||
#include "GaussianJunctionTree-inl.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace gtsam;
|
|
@ -6,7 +6,7 @@
|
|||
check_PROGRAMS = testBayesNetPreconditioner testConstraintOptimizer
|
||||
check_PROGRAMS += testGaussianBayesNet testGaussianFactor testGaussianFactorGraph
|
||||
check_PROGRAMS += testGaussianISAM testGaussianISAM2 testGraph
|
||||
check_PROGRAMS += testInference testIterative testJunctionTree
|
||||
check_PROGRAMS += testInference testIterative testGaussianJunctionTree
|
||||
check_PROGRAMS += testNonlinearEquality testNonlinearFactor testNonlinearFactorGraph
|
||||
check_PROGRAMS += testNonlinearOptimizer testSQP testSubgraphPreconditioner
|
||||
check_PROGRAMS += testSymbolicBayesNet testSymbolicFactorGraph testTupleConfig
|
||||
|
|
|
@ -17,7 +17,7 @@ using namespace boost::assign;
|
|||
#define GTSAM_MAGIC_KEY
|
||||
|
||||
#include "smallExample.h"
|
||||
#include "JunctionTree-inl.h"
|
||||
#include "GaussianJunctionTree-inl.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace gtsam;
|
Loading…
Reference in New Issue