diff --git a/.cproject b/.cproject index 248ce11a7..e123eff02 100644 --- a/.cproject +++ b/.cproject @@ -610,6 +610,14 @@ true true + + make + + testEliminationTree.run + true + true + true + make check diff --git a/inference/EliminationTree-inl.h b/inference/EliminationTree-inl.h new file mode 100644 index 000000000..ab19b42aa --- /dev/null +++ b/inference/EliminationTree-inl.h @@ -0,0 +1,24 @@ +/* + * EliminationTree-inl.h + * Created on: Feb 4, 2010 + * @Author: Kai Ni + * @Author: Frank Dellaert + * @brief: The elimination tree, template bodies + */ + +#pragma once + +#include + +#include "EliminationTree.h" + +namespace gtsam { + + using namespace std; + + /* ************************************************************************* */ + template + EliminationTree::EliminationTree(FG& fg, const Ordering& ordering) { + } + +} //namespace gtsam diff --git a/inference/EliminationTree.h b/inference/EliminationTree.h new file mode 100644 index 000000000..43d162a78 --- /dev/null +++ b/inference/EliminationTree.h @@ -0,0 +1,40 @@ +/* + * EliminationTree.h + * Created on: Feb 4, 2010 + * @Author: Kai Ni + * @Author: Frank Dellaert + * @brief: The elimination tree + */ + +#pragma once + +#include +#include "ClusterTree.h" + +namespace gtsam { + + /** + * An elimination tree (see Gilbert01bit) associated with a factorg raph and an ordering + * is a cluster-tree where there is one node j for each variable, and the parent of each node + * corresponds to the first variable in the ordering that variable j is connected to. + */ + template + class EliminationTree: public ClusterTree { + + public: + + // In a junction tree each cluster is associated with a clique + typedef typename ClusterTree::Cluster Node; + typedef typename Node::shared_ptr sharedNode; + + public: + // constructor + EliminationTree() { + } + + // constructor given a factor graph and the elimination ordering + EliminationTree(FG& fg, const Ordering& ordering); + + }; // EliminationTree + +} // namespace gtsam diff --git a/inference/JunctionTree-inl.h b/inference/JunctionTree-inl.h index 21b8fbaf6..773f8a795 100644 --- a/inference/JunctionTree-inl.h +++ b/inference/JunctionTree-inl.h @@ -1,9 +1,9 @@ /* * JunctionTree-inl.h - * - * Created on: Feb 4, 2010 - * Author: nikai - * Description: the junction tree + * Created on: Feb 4, 2010 + * @Author: Kai Ni + * @Author: Frank Dellaert + * @brief: The junction tree, template bodies */ #pragma once diff --git a/inference/JunctionTree.h b/inference/JunctionTree.h index 7c1891109..00cc59ad7 100644 --- a/inference/JunctionTree.h +++ b/inference/JunctionTree.h @@ -1,9 +1,9 @@ /* * JunctionTree.h - * - * Created on: Feb 4, 2010 - * Author: nikai - * Description: The junction tree + * Created on: Feb 4, 2010 + * @Author: Kai Ni + * @Author: Frank Dellaert + * @brief: The junction tree */ #pragma once diff --git a/inference/Makefile.am b/inference/Makefile.am index 46632d97b..b4f8ed69c 100644 --- a/inference/Makefile.am +++ b/inference/Makefile.am @@ -26,11 +26,12 @@ headers += graph.h graph-inl.h headers += FactorGraph.h FactorGraph-inl.h headers += ClusterTree.h ClusterTree-inl.h headers += JunctionTree.h JunctionTree-inl.h +headers += EliminationTree.h EliminationTree-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 testClusterTree testJunctionTree testBayesTree testISAM +check_PROGRAMS += testFactorGraph testClusterTree testEliminationTree testJunctionTree testBayesTree testISAM #---------------------------------------------------------------------------------------------------- # discrete diff --git a/inference/testEliminationTree.cpp b/inference/testEliminationTree.cpp new file mode 100644 index 000000000..bc367710d --- /dev/null +++ b/inference/testEliminationTree.cpp @@ -0,0 +1,50 @@ +/** + * @file testEliminationTree.cpp + * @brief Unit tests for Elimination Tree + * @author Kai Ni + * @author Frank Dellaert + */ + +#include // for operator += +#include // for operator += +using namespace boost::assign; + +#include + +#define GTSAM_MAGIC_KEY + +#include "SymbolicFactorGraph.h" +#include "ClusterTree-inl.h" +#include "EliminationTree-inl.h" + +using namespace gtsam; + +// explicit instantiation and typedef +template class EliminationTree; +typedef EliminationTree SymbolicEliminationTree; + +/* ************************************************************************* * + * graph: x1 - x2 - x3 - x4 + * tree: x1 -> x2 -> x3 -> x4 (arrow is parent pointer) + ****************************************************************************/ +TEST( EliminationTree, constructor ) +{ + SymbolicFactorGraph fg; + fg.push_factor("x1","x2"); + fg.push_factor("x2","x3"); + fg.push_factor("x3","x4"); + + SymbolicEliminationTree expected(); + + Ordering ordering; ordering += "x2","x1","x3","x4"; + SymbolicEliminationTree actual(fg, ordering); + +// CHECK(assert_equal(expected, actual)); +} + +/* ************************************************************************* */ +int main() { + TestResult tr; + return TestRegistry::runAllTests(tr); +} +/* ************************************************************************* */ diff --git a/inference/testJunctionTree.cpp b/inference/testJunctionTree.cpp index 2dfefd589..d033fd7e7 100644 --- a/inference/testJunctionTree.cpp +++ b/inference/testJunctionTree.cpp @@ -1,6 +1,6 @@ /** * @file testJunctionTree.cpp - * @brief Unit tests for Bayes Tree + * @brief Unit tests for Junction Tree * @author Kai Ni * @author Frank Dellaert */