| 
									
										
										
										
											2010-10-14 12:54:38 +08:00
										 |  |  | /* ----------------------------------------------------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * GTSAM Copyright 2010, Georgia Tech Research Corporation,  | 
					
						
							|  |  |  |  * Atlanta, Georgia 30332-0415 | 
					
						
							|  |  |  |  * All Rights Reserved | 
					
						
							|  |  |  |  * Authors: Frank Dellaert, et al. (see THANKS for the full author list) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * See LICENSE for the license information | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * -------------------------------------------------------------------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-10 06:02:50 +08:00
										 |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2009-12-28 07:15:36 +08:00
										 |  |  |  * @file    GaussianISAM | 
					
						
							| 
									
										
										
										
											2009-12-29 13:57:05 +08:00
										 |  |  |  * @brief   Linear ISAM only | 
					
						
							| 
									
										
										
										
											2009-12-10 06:02:50 +08:00
										 |  |  |  * @author  Michael Kaess | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-20 01:23:19 +08:00
										 |  |  | #include <gtsam/linear/GaussianISAM.h>
 | 
					
						
							| 
									
										
										
										
											2009-12-10 06:02:50 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | using namespace std; | 
					
						
							|  |  |  | using namespace gtsam; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Explicitly instantiate so we don't have to include everywhere
 | 
					
						
							| 
									
										
										
										
											2010-08-20 01:23:19 +08:00
										 |  |  | #include <gtsam/inference/ISAM-inl.h>
 | 
					
						
							| 
									
										
										
										
											2009-12-28 07:15:36 +08:00
										 |  |  | template class ISAM<GaussianConditional>; | 
					
						
							| 
									
										
										
										
											2009-12-10 06:02:50 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace gtsam { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2010-10-09 11:09:58 +08:00
										 |  |  | void optimize(const GaussianISAM::sharedClique& clique, VectorValues& result) { | 
					
						
							| 
									
										
										
										
											2009-12-10 06:02:50 +08:00
										 |  |  | 	// parents are assumed to already be solved and available in result
 | 
					
						
							| 
									
										
										
										
											2009-12-28 07:15:36 +08:00
										 |  |  | 	GaussianISAM::Clique::const_reverse_iterator it; | 
					
						
							| 
									
										
										
										
											2009-12-11 01:00:11 +08:00
										 |  |  | 	for (it = clique->rbegin(); it!=clique->rend(); it++) { | 
					
						
							| 
									
										
										
										
											2009-12-10 06:15:38 +08:00
										 |  |  | 		GaussianConditional::shared_ptr cg = *it; | 
					
						
							| 
									
										
										
										
											2009-12-10 06:02:50 +08:00
										 |  |  |     Vector x = cg->solve(result); // Solve for that variable
 | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  |     result[cg->key()] = x;   // store result in partial solution
 | 
					
						
							| 
									
										
										
										
											2009-12-10 06:02:50 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2010-02-17 11:29:12 +08:00
										 |  |  | 	BOOST_FOREACH(const GaussianISAM::sharedClique& child, clique->children_) { | 
					
						
							| 
									
										
										
										
											2009-12-10 06:02:50 +08:00
										 |  |  | 		optimize(child, result); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2010-10-09 11:09:58 +08:00
										 |  |  | VectorValues optimize(const GaussianISAM& bayesTree) { | 
					
						
							|  |  |  | 	VectorValues result(bayesTree.dims_); | 
					
						
							| 
									
										
										
										
											2009-12-10 06:02:50 +08:00
										 |  |  | 	// starting from the root, call optimize on each conditional
 | 
					
						
							|  |  |  | 	optimize(bayesTree.root(), result); | 
					
						
							| 
									
										
										
										
											2009-12-11 01:00:11 +08:00
										 |  |  | 	return result; | 
					
						
							| 
									
										
										
										
											2009-12-10 06:02:50 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } /// namespace gtsam
 |