Fixed examples from timing statement change (missed)
							parent
							
								
									4876cc7ff7
								
							
						
					
					
						commit
						c44f8f7f80
					
				|  | @ -79,7 +79,7 @@ int main(int argc, char** argv) { | |||
| 
 | ||||
| 
 | ||||
|   cout << "\nComputing Node Marginals ..(Sequential Elimination)" << endl; | ||||
|   tic_(1, "Sequential"); | ||||
|   tic_(Sequential); | ||||
|   for (vector<DiscreteKey>::iterator itr = nodes.begin(); itr != nodes.end(); | ||||
|       ++itr) { | ||||
|     //Compute the marginal
 | ||||
|  | @ -89,14 +89,14 @@ int main(int argc, char** argv) { | |||
|     cout << "Node#" << setw(4) << itr->first << " :  "; | ||||
|     print(margProbs); | ||||
|   } | ||||
|   toc_(1, "Sequential"); | ||||
|   toc_(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 ..(BayesTree based)" << endl; | ||||
|   tic_(2, "Multifrontal"); | ||||
|   tic_(Multifrontal); | ||||
|   for (vector<DiscreteKey>::iterator itr = nodes.begin(); itr != nodes.end(); | ||||
|       ++itr) { | ||||
|     //Compute the marginal
 | ||||
|  | @ -106,7 +106,7 @@ int main(int argc, char** argv) { | |||
|     cout << "Node#" << setw(4) << itr->first << " :  "; | ||||
|     print(margProbs); | ||||
|   } | ||||
|   toc_(2, "Multifrontal"); | ||||
|   toc_(Multifrontal); | ||||
| 
 | ||||
|   tictoc_print_(); | ||||
|   return 0; | ||||
|  |  | |||
|  | @ -82,51 +82,55 @@ int main(int argc, char *argv[]) { | |||
| 
 | ||||
|   int n = 10000000; | ||||
| 
 | ||||
|   { | ||||
|   VirtualBase** b = new VirtualBase*[n]; | ||||
|   tic_(0, "Virtual"); | ||||
|   tic_(0, "new"); | ||||
|   tic_(Virtual); | ||||
|   tic_(new); | ||||
|   for(int i=0; i<n; ++i) | ||||
|     b[i] = new VirtualDerived(); | ||||
|   toc_(0, "new"); | ||||
|   tic_(1, "method"); | ||||
|   toc_(new); | ||||
|   tic_(method); | ||||
|   for(int i=0; i<n; ++i) | ||||
|     b[i]->method(); | ||||
|   toc_(1, "method"); | ||||
|   tic_(2, "dynamic_cast"); | ||||
|   toc_(method); | ||||
|   tic_(dynamic_cast); | ||||
|   for(int i=0; i<n; ++i) { | ||||
|     VirtualDerived* d = dynamic_cast<VirtualDerived*>(b[i]); | ||||
|     if(d) | ||||
|       d->method(); | ||||
|   } | ||||
|   toc_(2, "dynamic_cast"); | ||||
|   tic_(3, "delete"); | ||||
|   toc_(dynamic_cast); | ||||
|   tic_(delete); | ||||
|   for(int i=0; i<n; ++i) | ||||
|     delete b[i]; | ||||
|   toc_(3, "delete"); | ||||
|   toc_(0, "Virtual"); | ||||
|   toc_(delete); | ||||
|   toc_(Virtual); | ||||
|   delete[] b; | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   { | ||||
|   NonVirtualDerived** d = new NonVirtualDerived*[n]; | ||||
|   tic_(1, "NonVirtual"); | ||||
|   tic_(0, "new"); | ||||
|   tic_(NonVirtual); | ||||
|   tic_(new); | ||||
|   for(int i=0; i<n; ++i) | ||||
|     d[i] = new NonVirtualDerived(); | ||||
|   toc_(0, "new"); | ||||
|   tic_(1, "method"); | ||||
|   toc_(new); | ||||
|   tic_(method); | ||||
|   for(int i=0; i<n; ++i) | ||||
|     d[i]->method(); | ||||
|   toc_(1, "method"); | ||||
|   tic_(2, "dynamic_cast (does nothing)"); | ||||
|   toc_(method); | ||||
|   tic_(dynamic_cast (does nothing)); | ||||
|   for(int i=0; i<n; ++i) | ||||
|     d[i]->method(); | ||||
|   toc_(2, "dynamic_cast (does nothing)"); | ||||
|   tic_(3, "delete"); | ||||
|   toc_(dynamic_cast (does nothing)); | ||||
|   tic_(delete); | ||||
|   for(int i=0; i<n; ++i) | ||||
|     delete d[i]; | ||||
|   toc_(3, "delete"); | ||||
|   toc_(1, "NonVirtual"); | ||||
|   toc_(delete); | ||||
|   toc_(NonVirtual); | ||||
|   delete[] d; | ||||
|   } | ||||
| 
 | ||||
|   tictoc_finishedIteration_(); | ||||
|   tictoc_print_(); | ||||
|  |  | |||
|  | @ -151,9 +151,9 @@ void solveStaged(size_t addMutex = 2) { | |||
|     scheduler.buildGraph(addMutex); | ||||
| 
 | ||||
|     // Do EXACT INFERENCE
 | ||||
|     tic_(3,"eliminate"); | ||||
|     tic_(eliminate); | ||||
|     DiscreteBayesNet::shared_ptr chordal = scheduler.eliminate(); | ||||
|     toc_(3,"eliminate"); | ||||
|     toc_(eliminate); | ||||
| 
 | ||||
|     // find root node
 | ||||
|     DiscreteConditional::shared_ptr root = *(chordal->rbegin()); | ||||
|  |  | |||
|  | @ -178,9 +178,9 @@ void solveStaged(size_t addMutex = 2) { | |||
|     scheduler.buildGraph(addMutex); | ||||
| 
 | ||||
|     // Do EXACT INFERENCE
 | ||||
|     tic_(3,"eliminate"); | ||||
|     tic_(eliminate); | ||||
|     DiscreteBayesNet::shared_ptr chordal = scheduler.eliminate(); | ||||
|     toc_(3,"eliminate"); | ||||
|     toc_(eliminate); | ||||
| 
 | ||||
|     // find root node
 | ||||
|     DiscreteConditional::shared_ptr root = *(chordal->rbegin()); | ||||
|  |  | |||
|  | @ -46,11 +46,11 @@ int main(int argc, char *argv[]) { | |||
| 
 | ||||
|   cout << "Loading data..." << endl; | ||||
| 
 | ||||
|   tic_(1, "Find datafile (script only)"); | ||||
|   tic_(Find_datafile); | ||||
|   string datasetFile = findExampleDataFile("w10000-odom"); | ||||
|   std::pair<NonlinearFactorGraph::shared_ptr, Values::shared_ptr> data = | ||||
|     load2D(datasetFile); | ||||
|   toc_(1, "Find datafile (script only)"); | ||||
|   toc_(Find_datafile); | ||||
| 
 | ||||
|   NonlinearFactorGraph measurements = *data.first; | ||||
|   Values initial = *data.second; | ||||
|  | @ -66,7 +66,7 @@ int main(int argc, char *argv[]) { | |||
|     NonlinearFactorGraph newFactors; | ||||
| 
 | ||||
|     // Collect measurements and new variables for the current step
 | ||||
|     tic_(2, "Collect measurements (script only)"); | ||||
|     tic_(Collect_measurements); | ||||
|     if(step == 1) { | ||||
|       //      cout << "Initializing " << 0 << endl;
 | ||||
|       newVariables.insert(0, Pose()); | ||||
|  | @ -114,19 +114,19 @@ int main(int argc, char *argv[]) { | |||
|       } | ||||
|       ++ nextMeasurement; | ||||
|     } | ||||
|     toc_(2, "Collect measurements (script only)"); | ||||
|     toc_(Collect_measurements); | ||||
| 
 | ||||
|     // Update iSAM2
 | ||||
|     tic_(3, "Update ISAM2"); | ||||
|     tic_(Update_ISAM2); | ||||
|     isam2.update(newFactors, newVariables); | ||||
|     toc_(3, "Update ISAM2"); | ||||
|     toc_(Update_ISAM2); | ||||
| 
 | ||||
|     if(step % 100 == 0) { | ||||
|       tic_(4, "chi2 (script only)"); | ||||
|       tic_(chi2); | ||||
|       Values estimate(isam2.calculateEstimate()); | ||||
|       double chi2 = chi2_red(isam2.getFactorsUnsafe(), estimate); | ||||
|       cout << "chi2 = " << chi2 << endl; | ||||
|       toc_(4, "chi2 (script only)"); | ||||
|       toc_(chi2); | ||||
|     } | ||||
| 
 | ||||
|     tictoc_finishedIteration_(); | ||||
|  | @ -141,9 +141,9 @@ int main(int argc, char *argv[]) { | |||
|   Marginals marginals(isam2.getFactorsUnsafe(), isam2.calculateEstimate()); | ||||
|   int i=0; | ||||
|   BOOST_FOREACH(Key key, initial.keys()) { | ||||
|     tic_(5, "marginalInformation"); | ||||
|     tic_(marginalInformation); | ||||
|     Matrix info = marginals.marginalInformation(key); | ||||
|     toc_(5, "marginalInformation"); | ||||
|     toc_(marginalInformation); | ||||
|     tictoc_finishedIteration_(); | ||||
|     if(i % 1000 == 0) | ||||
|       tictoc_print_(); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue