From 6fe2b77a25b3358bba657c70bb0e102a9d8f8a84 Mon Sep 17 00:00:00 2001 From: Abhijit Kundu Date: Fri, 8 Jun 2012 00:18:32 +0000 Subject: [PATCH] In the middle of evaluating performance of DiscreteSequentialSolver vs DiscreteMarginals --- examples/UGM_chain.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/examples/UGM_chain.cpp b/examples/UGM_chain.cpp index 5d8e5a841..e7f408cb0 100644 --- a/examples/UGM_chain.cpp +++ b/examples/UGM_chain.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -31,7 +32,7 @@ using namespace gtsam; int main(int argc, char** argv) { // Set Number of Nodes in the Graph - const int nrNodes = 50; + const int nrNodes = 60; // Each node takes 1 of 7 possible states denoted by 0-6 in following order: // ["VideoGames" "Industry" "GradSchool" "VideoGames(with PhD)" @@ -75,11 +76,27 @@ int main(int argc, char** argv) { optimalDecoding->print("\nMost Probable Explanation (optimalDecoding)\n"); // "Inference" Computing marginals for each node + + + cout << "\nComputing Node Marginals ..(Sequential Elimination)" << endl; + tic_(1, "Sequential"); + for (vector::iterator itr = nodes.begin(); itr != nodes.end(); + ++itr) { + //Compute the marginal + Vector margProbs = solver.marginalProbabilities(*itr); + + //Print the marginals + cout << "Node#" << setw(4) << itr->first << " : "; + print(margProbs); + } + toc_(1, "Sequential"); + // Here we'll make use of DiscreteMarginals class, which makes use of // bayes-tree based shortcut evaluation of marginals DiscreteMarginals marginals(graph); - cout << "\nComputing Node Marginals .." << endl; + cout << "\nComputing Node Marginals ..(BayesTree based)" << endl; + tic_(2, "Multifrontal"); for (vector::iterator itr = nodes.begin(); itr != nodes.end(); ++itr) { //Compute the marginal @@ -88,9 +105,10 @@ int main(int argc, char** argv) { //Print the marginals cout << "Node#" << setw(4) << itr->first << " : "; print(margProbs); - cout << endl; } + toc_(2, "Multifrontal"); + tictoc_print_(); return 0; }