From a7540a730580e0468fa8206fac4d78bf757c7b36 Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Sat, 27 Jul 2013 18:35:31 +0000 Subject: [PATCH] Removed unused code --- gtsam/inference/BayesTreeUnordered-inst.h | 81 ------------- .../symbolic/tests/testSymbolicBayesTree.cpp | 113 ------------------ 2 files changed, 194 deletions(-) diff --git a/gtsam/inference/BayesTreeUnordered-inst.h b/gtsam/inference/BayesTreeUnordered-inst.h index ef51f9c7f..a072781e5 100644 --- a/gtsam/inference/BayesTreeUnordered-inst.h +++ b/gtsam/inference/BayesTreeUnordered-inst.h @@ -201,87 +201,6 @@ namespace gtsam { treeTraversal::DepthFirstForest(*this, data, boost::bind(&_pushClique, boost::ref(graph), _1)); } - /* ************************************************************************* */ - //template - //void BayesTreeUnordered::recursiveTreeBuild(const boost::shared_ptr >& symbolic, - // const std::vector >& conditionals, - // const typename BayesTreeUnordered::sharedClique& parent) { - - // // Helper function to build a non-symbolic tree (e.g. Gaussian) using a - // // symbolic tree, used in the BT(BN) constructor. - - // // Build the current clique - // FastList cliqueConditionals; - // BOOST_FOREACH(Index j, symbolic->conditional()->frontals()) { - // cliqueConditionals.push_back(conditionals[j]); } - // typename BayesTreeUnordered::sharedClique thisClique(new CLIQUE(CONDITIONAL::Combine(cliqueConditionals.begin(), cliqueConditionals.end()))); - - // // Add the new clique with the current parent - // this->addClique(thisClique, parent); - - // // Build the children, whose parent is the new clique - // BOOST_FOREACH(const BayesTreeUnordered::sharedClique& child, symbolic->children()) { - // this->recursiveTreeBuild(child, conditionals, thisClique); } - //} - - /* ************************************************************************* */ - //template - //BayesTreeUnordered::BayesTreeUnordered(const BayesNet& bayesNet) { - // // First generate symbolic BT to determine clique structure - // BayesTreeUnordered sbt(bayesNet); - - // // Build index of variables to conditionals - // std::vector > conditionals(sbt.root()->conditional()->frontals().back() + 1); - // BOOST_FOREACH(const boost::shared_ptr& c, bayesNet) { - // if(c->nrFrontals() != 1) - // throw std::invalid_argument("BayesTreeUnordered constructor from BayesNet only supports single frontal variable conditionals"); - // if(c->firstFrontalKey() >= conditionals.size()) - // throw std::invalid_argument("An inconsistent BayesNet was passed into the BayesTreeUnordered constructor!"); - // if(conditionals[c->firstFrontalKey()]) - // throw std::invalid_argument("An inconsistent BayesNet with duplicate frontal variables was passed into the BayesTreeUnordered constructor!"); - - // conditionals[c->firstFrontalKey()] = c; - // } - - // // Build the new tree - // this->recursiveTreeBuild(sbt.root(), conditionals, sharedClique()); - //} - - /* ************************************************************************* */ - //template<> - //inline BayesTreeUnordered::BayesTreeUnordered(const BayesNet& bayesNet) { - // BayesNet::const_reverse_iterator rit; - // for ( rit=bayesNet.rbegin(); rit != bayesNet.rend(); ++rit ) - // insert(*this, *rit); - //} - - /* ************************************************************************* */ - //template - //BayesTreeUnordered::BayesTreeUnordered(const BayesNet& bayesNet, std::list > subtrees) { - // if (bayesNet.size() == 0) - // throw std::invalid_argument("BayesTreeUnordered::insert: empty bayes net!"); - - // // get the roots of child subtrees and merge their nodes_ - // std::list childRoots; - // typedef BayesTreeUnordered Tree; - // BOOST_FOREACH(const Tree& subtree, subtrees) { - // nodes_.assign(subtree.nodes_.begin(), subtree.nodes_.end()); - // childRoots.push_back(subtree.root()); - // } - - // // create a new clique and add all the conditionals to the clique - // sharedClique new_clique; - // typename BayesNet::sharedConditional conditional; - // BOOST_REVERSE_FOREACH(conditional, bayesNet) { - // if (!new_clique.get()) - // new_clique = addClique(conditional,childRoots); - // else - // addToCliqueFront(*this, conditional, new_clique); - // } - - // root_ = new_clique; - //} - /* ************************************************************************* */ template BayesTreeUnordered::BayesTreeUnordered(const This& other) { diff --git a/gtsam/symbolic/tests/testSymbolicBayesTree.cpp b/gtsam/symbolic/tests/testSymbolicBayesTree.cpp index dd2ac7973..673ce2dc4 100644 --- a/gtsam/symbolic/tests/testSymbolicBayesTree.cpp +++ b/gtsam/symbolic/tests/testSymbolicBayesTree.cpp @@ -39,20 +39,6 @@ using namespace gtsam::symbol_shorthand; static bool debug = false; namespace { - /* ************************************************************************* */ - //// Conditionals for ASIA example from the tutorial with A and D evidence - //SymbolicConditionalUnordered::shared_ptr - // B(new SymbolicConditionalUnordered(_B_)), - // L(new SymbolicConditionalUnordered(_L_, _B_)), - // E(new SymbolicConditionalUnordered(_E_, _L_, _B_)), - // S(new SymbolicConditionalUnordered(_S_, _L_, _B_)), - // T(new SymbolicConditionalUnordered(_T_, _E_, _L_)), - // X(new SymbolicConditionalUnordered(_X_, _E_)); - - //// Cliques - //SymbolicConditionalUnordered::shared_ptr ELB( - // boost::make_shared( - // SymbolicConditionalUnordered::FromKeys(list_of(_E_)(_L_)(_B_), 3))); /* ************************************************************************* */ // Helper functions for below @@ -80,49 +66,6 @@ namespace { } -/* ************************************************************************* */ -TEST( SymbolicBayesTree, constructor ) -{ - // Create using insert - //SymbolicBayesTreeUnordered bayesTree = createAsiaSymbolicBayesTree(); - - //bayesTree.print("bayesTree: "); - - // Check Size -// LONGS_EQUAL(4, bayesTree.size()); -// EXPECT(!bayesTree.empty()); -// -// // Check root -// boost::shared_ptr actual_root = bayesTree.root()->conditional(); -// CHECK(assert_equal(*ELB,*actual_root)); -// -// // Create from symbolic Bayes chain in which we want to discover cliques -// BayesNet ASIA; -// ASIA.push_back(X); -// ASIA.push_back(T); -// ASIA.push_back(S); -// ASIA.push_back(E); -// ASIA.push_back(L); -// ASIA.push_back(B); -// SymbolicBayesTreeUnordered bayesTree2(ASIA); -// -// // Check whether the same -// CHECK(assert_equal(bayesTree,bayesTree2)); -// -// // CHECK findParentClique, should *not depend on order of parents* -//// Ordering ordering; ordering += _X_, _T_, _S_, _E_, _L_, _B_; -//// IndexTable index(ordering); -// -// list parents1; parents1 += _E_, _L_; -// CHECK(assert_equal(_E_, bayesTree.findParentClique(parents1))); -// -// list parents2; parents2 += _L_, _E_; -// CHECK(assert_equal(_E_, bayesTree.findParentClique(parents2))); -// -// list parents3; parents3 += _L_, _B_; -// CHECK(assert_equal(_L_, bayesTree.findParentClique(parents3))); -} - /* ************************************************************************* */ TEST(SymbolicBayesTree, clear) { @@ -398,62 +341,6 @@ TEST( BayesTree, removeTop4 ) EXPECT(orphans.empty()); } -/////* ************************************************************************* */ -/////** -//// * x2 - x3 - x4 - x5 -//// * | / \ | -//// * x1 / \ x6 -//// */ -////TEST( BayesTree, insert ) -////{ -//// // construct bayes tree by split the graph along the separator x3 - x4 -//// const Index _x1_=0, _x2_=1, _x6_=2, _x5_=3, _x3_=4, _x4_=5; -//// SymbolicFactorGraph fg1, fg2, fg3; -//// fg1.push_factor(_x3_, _x4_); -//// fg2.push_factor(_x1_, _x2_); -//// fg2.push_factor(_x2_, _x3_); -//// fg2.push_factor(_x1_, _x3_); -//// fg3.push_factor(_x5_, _x4_); -//// fg3.push_factor(_x6_, _x5_); -//// fg3.push_factor(_x6_, _x4_); -//// -////// Ordering ordering1; ordering1 += _x3_, _x4_; -////// Ordering ordering2; ordering2 += _x1_, _x2_; -////// Ordering ordering3; ordering3 += _x6_, _x5_; -//// -//// BayesNet bn1, bn2, bn3; -//// bn1 = *SymbolicSequentialSolver::EliminateUntil(fg1, _x4_+1); -//// bn2 = *SymbolicSequentialSolver::EliminateUntil(fg2, _x2_+1); -//// bn3 = *SymbolicSequentialSolver::EliminateUntil(fg3, _x5_+1); -//// -//// // insert child cliques -//// SymbolicBayesTreeUnordered actual; -//// list children; -//// SymbolicBayesTreeUnordered::sharedClique r1 = actual.insert(bn2, children); -//// SymbolicBayesTreeUnordered::sharedClique r2 = actual.insert(bn3, children); -//// -//// // insert root clique -//// children.push_back(r1); -//// children.push_back(r2); -//// actual.insert(bn1, children, true); -//// -//// // traditional way -//// SymbolicFactorGraph fg; -//// fg.push_factor(_x3_, _x4_); -//// fg.push_factor(_x1_, _x2_); -//// fg.push_factor(_x2_, _x3_); -//// fg.push_factor(_x1_, _x3_); -//// fg.push_factor(_x5_, _x4_); -//// fg.push_factor(_x6_, _x5_); -//// fg.push_factor(_x6_, _x4_); -//// -////// Ordering ordering; ordering += _x1_, _x2_, _x6_, _x5_, _x3_, _x4_; -//// BayesNet bn(*SymbolicSequentialSolver(fg).eliminate()); -//// SymbolicBayesTreeUnordered expected(bn); -//// CHECK(assert_equal(expected, actual)); -//// -////} - /* ************************************************************************* */ TEST( SymbolicBayesTreeUnordered, thinTree ) {