From 21974f95e161346bece7f05e8ebe0195f731b2f2 Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Wed, 18 Nov 2009 16:31:19 +0000 Subject: [PATCH] test for incremental update --- cpp/testIncremental.cpp | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/cpp/testIncremental.cpp b/cpp/testIncremental.cpp index 890d7f848..369d64c59 100644 --- a/cpp/testIncremental.cpp +++ b/cpp/testIncremental.cpp @@ -10,6 +10,7 @@ using namespace boost::assign; #include #include "SymbolicBayesNet.h" +#include "SymbolicFactor.h" #include "GaussianBayesNet.h" #include "Ordering.h" #include "BayesTree-inl.h" @@ -21,10 +22,6 @@ typedef BayesTree SymbolicBayesTree; typedef BayesTree GaussianBayesTree; - -// todo: copied from testBayesTree - - // Conditionals for ASIA example from the tutorial with A and D evidence SymbolicConditional::shared_ptr B(new SymbolicConditional("B")), L( new SymbolicConditional("L", "B")), E( @@ -32,6 +29,12 @@ SymbolicConditional::shared_ptr B(new SymbolicConditional("B")), L( "L", "B")), T(new SymbolicConditional("T", "E", "L")), X( new SymbolicConditional("X", "E")); +/* ************************************************************************* */ + +SymbolicBayesTree update(const SymbolicBayesTree& initial, const SymbolicFactor& newFactor) { + return initial; +} + /* ************************************************************************* */ TEST( BayesTree, iSAM ) { @@ -43,8 +46,28 @@ TEST( BayesTree, iSAM ) bayesTree.insert(S); bayesTree.insert(T); bayesTree.insert(X); - bayesTree.print("bayesTree"); + + // Create expected Bayes tree + SymbolicBayesTree expected; + expected.insert(B); + expected.insert(L); + expected.insert(S); + expected.insert(E); + expected.insert(T); + expected.insert(X); + expected.print("expected"); + + // create a new factor to be inserted + list keys; + keys += "B","S"; + SymbolicFactor newFactor(keys); + + // do incremental inference + SymbolicBayesTree actual = update(bayesTree, newFactor); + + // Check whether the same + //CHECK(assert_equal(expected,actual)); } /* ************************************************************************* */