More detailed timing in UnorderedLinear script
							parent
							
								
									da10417cfc
								
							
						
					
					
						commit
						5d0629c91a
					
				|  | @ -218,28 +218,35 @@ int main(int argc, char *argv[]) | ||||||
|   // Get linear graph
 |   // Get linear graph
 | ||||||
|   cout << "Converting to unordered linear graph" << endl; |   cout << "Converting to unordered linear graph" << endl; | ||||||
|   Ordering ordering = *isamsoln.orderingArbitrary(); |   Ordering ordering = *isamsoln.orderingArbitrary(); | ||||||
|  |   Ordering orderingCOLAMD = *nlfg.orderingCOLAMD(isamsoln); | ||||||
|   GaussianFactorGraph gfg = *nlfg.linearize(isamsoln, ordering); |   GaussianFactorGraph gfg = *nlfg.linearize(isamsoln, ordering); | ||||||
|   GaussianFactorGraphUnordered gfgu = convertToUnordered(gfg, ordering); |   GaussianFactorGraphUnordered gfgu = convertToUnordered(gfg, ordering); | ||||||
| 
 | 
 | ||||||
|   OrderingUnordered orderingUnordered; |   //OrderingUnordered orderingUnordered;
 | ||||||
|   for(Index j = 0; j < ordering.size(); ++j) |   //for(Index j = 0; j < ordering.size(); ++j)
 | ||||||
|     orderingUnordered.push_back(ordering.key(j)); |   //  orderingUnordered.push_back(ordering.key(j));
 | ||||||
| 
 | 
 | ||||||
|   // Solve linear graph
 |   // Solve linear graph
 | ||||||
|   cout << "Optimizing unordered graph" << endl; |   cout << "Optimizing unordered graph" << endl; | ||||||
|   VectorValuesUnordered unorderedSolnFinal; |   VectorValuesUnordered unorderedSolnFinal; | ||||||
|   { |   { | ||||||
|     boost::timer::cpu_timer timer; |  | ||||||
|     gttic_(Solve_unordered); |     gttic_(Solve_unordered); | ||||||
|     VectorValuesUnordered unorderedSoln; |     VectorValuesUnordered unorderedSoln; | ||||||
|     for(size_t i = 0; i < 1; ++i) { |     for(size_t i = 0; i < 1; ++i) { | ||||||
|       unorderedSoln = gfgu.optimize(); |       gttic_(VariableIndex); | ||||||
|  |       VariableIndexUnordered vi(gfgu); | ||||||
|  |       gttoc_(VariableIndex); | ||||||
|  |       gttic_(COLAMD); | ||||||
|  |       OrderingUnordered orderingUnordered = OrderingUnordered::COLAMD(vi); | ||||||
|  |       gttoc_(COLAMD); | ||||||
|  |       gttic_(eliminate); | ||||||
|  |       GaussianBayesTreeUnordered::shared_ptr bt = gfgu.eliminateMultifrontal(orderingUnordered); | ||||||
|  |       gttoc_(eliminate); | ||||||
|  |       gttic_(optimize); | ||||||
|  |       unorderedSoln = bt->optimize(); | ||||||
|  |       gttoc_(optimize); | ||||||
|     } |     } | ||||||
|     gttoc_(Solve_unordered); |     gttoc_(Solve_unordered); | ||||||
|     timer.stop(); |  | ||||||
|     boost::timer::cpu_times times = timer.elapsed(); |  | ||||||
|     std::cout << "Total CPU time: " << double(times.system + times.user) / 1e9 |  | ||||||
|       << ", wall time: " << double(times.wall) / 1e9 << std::endl; |  | ||||||
|     unorderedSolnFinal = unorderedSoln; |     unorderedSolnFinal = unorderedSoln; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | @ -248,26 +255,30 @@ int main(int argc, char *argv[]) | ||||||
|   VectorValues orderedSolnFinal; |   VectorValues orderedSolnFinal; | ||||||
|   { |   { | ||||||
|     Ordering orderingToUse = ordering; |     Ordering orderingToUse = ordering; | ||||||
|     GaussianFactorGraph orderedGraph = *nlfg.linearize(isamsoln, *nlfg.orderingCOLAMD(isamsoln)); |     GaussianFactorGraph::shared_ptr orderedGraph = nlfg.linearize(isamsoln, *nlfg.orderingCOLAMD(isamsoln)); | ||||||
|     boost::timer::cpu_timer timer; |  | ||||||
|     gttic_(Solve_ordered); |     gttic_(Solve_ordered); | ||||||
|     VectorValues orderedSoln; |     VectorValues orderedSoln; | ||||||
|     for(size_t i = 0; i < 1; ++i) { |     for(size_t i = 0; i < 1; ++i) { | ||||||
|       VariableIndex vi(nlfg); |       gttic_(VariableIndex); | ||||||
|       boost::shared_ptr<Permutation> permutation = inference::PermutationCOLAMD(vi); |       boost::shared_ptr<VariableIndex> vi = boost::make_shared<VariableIndex>(gfg); | ||||||
|  |       gttoc_(VariableIndex); | ||||||
|  |       gttic_(COLAMD); | ||||||
|  |       boost::shared_ptr<Permutation> permutation = inference::PermutationCOLAMD(*vi); | ||||||
|       orderingToUse.permuteInPlace(*permutation); |       orderingToUse.permuteInPlace(*permutation); | ||||||
|       orderedSoln = *GaussianMultifrontalSolver(orderedGraph, true).optimize(); |       gttoc_(COLAMD); | ||||||
|  |       gttic_(eliminate); | ||||||
|  |       boost::shared_ptr<GaussianBayesTree> bt = GaussianMultifrontalSolver(*orderedGraph, true).eliminate(); | ||||||
|  |       gttoc_(eliminate); | ||||||
|  |       gttic_(optimize); | ||||||
|  |       orderedSoln = optimize(*bt); | ||||||
|  |       gttoc_(optimize); | ||||||
|     } |     } | ||||||
|     gttoc_(Solve_ordered); |     gttoc_(Solve_ordered); | ||||||
|     timer.stop(); |  | ||||||
|     boost::timer::cpu_times times = timer.elapsed(); |  | ||||||
|     std::cout << "Total CPU time: " << double(times.system + times.user) / 1e9 |  | ||||||
|       << ", wall time: " << double(times.wall) / 1e9 << std::endl; |  | ||||||
|     orderedSolnFinal = orderedSoln; |     orderedSolnFinal = orderedSoln; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   // Compare results
 |   // Compare results
 | ||||||
|   compareSolutions(orderedSolnFinal, ordering, unorderedSolnFinal); |   compareSolutions(orderedSolnFinal, orderingCOLAMD, unorderedSolnFinal); | ||||||
| 
 | 
 | ||||||
|   //GaussianEliminationTreeUnordered(gfgu, orderingUnordered).print("ETree: ");
 |   //GaussianEliminationTreeUnordered(gfgu, orderingUnordered).print("ETree: ");
 | ||||||
|   //GaussianJunctionTreeUnordered(GaussianEliminationTreeUnordered(gfgu, orderingUnordered)).print("JTree: ");
 |   //GaussianJunctionTreeUnordered(GaussianEliminationTreeUnordered(gfgu, orderingUnordered)).print("JTree: ");
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue