| 
									
										
										
										
											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 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-28 07:15:36 +08:00
										 |  |  | #include "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
 | 
					
						
							| 
									
										
										
										
											2009-12-28 07:15:36 +08:00
										 |  |  | #include "ISAM-inl.h"
 | 
					
						
							|  |  |  | template class ISAM<GaussianConditional>; | 
					
						
							| 
									
										
										
										
											2009-12-10 06:02:50 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace gtsam { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2009-12-28 07:15:36 +08:00
										 |  |  | void optimize(const GaussianISAM::sharedClique& clique, VectorConfig& 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
 | 
					
						
							| 
									
										
										
										
											2009-12-11 01:00:11 +08:00
										 |  |  |     result.insert(cg->key(), x);   // store result in partial solution
 | 
					
						
							| 
									
										
										
										
											2009-12-10 06:02:50 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2009-12-28 07:15:36 +08:00
										 |  |  | 	BOOST_FOREACH(GaussianISAM::sharedClique child, clique->children_) { | 
					
						
							|  |  |  | //	list<GaussianISAM::Clique::shared_ptr>::const_iterator child;
 | 
					
						
							| 
									
										
										
										
											2009-12-11 01:00:11 +08:00
										 |  |  | //	for (child = clique->children_.begin(); child != clique->children_.end(); child++) {
 | 
					
						
							| 
									
										
										
										
											2009-12-10 06:02:50 +08:00
										 |  |  | 		optimize(child, result); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2009-12-28 07:15:36 +08:00
										 |  |  | VectorConfig optimize(const GaussianISAM& bayesTree) { | 
					
						
							| 
									
										
										
										
											2009-12-10 06:02:50 +08:00
										 |  |  | 	VectorConfig result; | 
					
						
							|  |  |  | 	// 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
 |