test new solver functions

release/4.3a0
Frank Dellaert 2012-09-16 17:54:59 +00:00
parent 89cd600165
commit 439b724011
1 changed files with 51 additions and 36 deletions

View File

@ -63,47 +63,62 @@ TEST( SymbolicSequentialSolver, inference ) {
EXPECT(assert_equal(expected,*actual)); EXPECT(assert_equal(expected,*actual));
{ {
// jointBayesNet // jointBayesNet
vector<Index> js; vector<Index> js;
js.push_back(0); js.push_back(0);
js.push_back(4); js.push_back(4);
js.push_back(3); js.push_back(3);
SymbolicBayesNet::shared_ptr actualBN = solver.jointBayesNet(js); SymbolicBayesNet::shared_ptr actualBN = solver.jointBayesNet(js);
SymbolicBayesNet expectedBN; SymbolicBayesNet expectedBN;
expectedBN.push_front(boost::make_shared<IndexConditional>(3)); expectedBN.push_front(boost::make_shared<IndexConditional>(3));
expectedBN.push_front(boost::make_shared<IndexConditional>(4, 3)); expectedBN.push_front(boost::make_shared<IndexConditional>(4, 3));
expectedBN.push_front(boost::make_shared<IndexConditional>(0, 4)); expectedBN.push_front(boost::make_shared<IndexConditional>(0, 4));
EXPECT( assert_equal(expectedBN,*actualBN)); EXPECT( assert_equal(expectedBN,*actualBN));
// jointFactorGraph // jointFactorGraph
SymbolicFactorGraph::shared_ptr actualFG = solver.jointFactorGraph(js); SymbolicFactorGraph::shared_ptr actualFG = solver.jointFactorGraph(js);
SymbolicFactorGraph expectedFG; SymbolicFactorGraph expectedFG;
expectedFG.push_factor(0, 4); expectedFG.push_factor(0, 4);
expectedFG.push_factor(4, 3); expectedFG.push_factor(4, 3);
expectedFG.push_factor(3); expectedFG.push_factor(3);
EXPECT( assert_equal(expectedFG,(SymbolicFactorGraph)(*actualFG))); EXPECT( assert_equal(expectedFG,(SymbolicFactorGraph)(*actualFG)));
} }
{ {
// jointBayesNet // jointBayesNet
vector<Index> js; vector<Index> js;
js.push_back(0); js.push_back(0);
js.push_back(3); js.push_back(2);
js.push_back(4); js.push_back(3);
SymbolicBayesNet::shared_ptr actualBN = solver.jointBayesNet(js); SymbolicBayesNet::shared_ptr actualBN = solver.jointBayesNet(js);
SymbolicBayesNet expectedBN; SymbolicBayesNet expectedBN;
expectedBN.push_front(boost::make_shared<IndexConditional>(3)); expectedBN.push_front(boost::make_shared<IndexConditional>(2));
expectedBN.push_front(boost::make_shared<IndexConditional>(4, 3)); expectedBN.push_front(boost::make_shared<IndexConditional>(3, 2));
expectedBN.push_front(boost::make_shared<IndexConditional>(0, 4)); expectedBN.push_front(boost::make_shared<IndexConditional>(0, 3, 2));
EXPECT( assert_equal(expectedBN,*actualBN)); EXPECT( assert_equal(expectedBN,*actualBN));
// jointFactorGraph // jointFactorGraph
SymbolicFactorGraph::shared_ptr actualFG = solver.jointFactorGraph(js); SymbolicFactorGraph::shared_ptr actualFG = solver.jointFactorGraph(js);
SymbolicFactorGraph expectedFG; SymbolicFactorGraph expectedFG;
expectedFG.push_factor(0, 4); expectedFG.push_factor(0, 3, 2);
expectedFG.push_factor(4, 3); expectedFG.push_factor(3, 2);
expectedFG.push_factor(3); expectedFG.push_factor(2);
EXPECT( assert_equal(expectedFG,(SymbolicFactorGraph)(*actualFG))); EXPECT( assert_equal(expectedFG,(SymbolicFactorGraph)(*actualFG)));
}
{
// conditionalBayesNet
vector<Index> js;
js.push_back(0);
js.push_back(2);
js.push_back(3);
size_t nrFrontals = 2;
SymbolicBayesNet::shared_ptr actualBN = //
solver.conditionalBayesNet(js, nrFrontals);
SymbolicBayesNet expectedBN;
expectedBN.push_front(boost::make_shared<IndexConditional>(3, 2));
expectedBN.push_front(boost::make_shared<IndexConditional>(0, 3, 2));
EXPECT( assert_equal(expectedBN,*actualBN));
} }
} }