| 
									
										
										
										
											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-11-12 12:52:40 +08:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * @file    inference.h | 
					
						
							|  |  |  |  * @brief   Contains *generic* inference algorithms that convert between templated | 
					
						
							|  |  |  |  * graphical models, i.e., factor graphs, Bayes nets, and Bayes trees | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  |  * @author  Frank Dellaert, Richard Roberts | 
					
						
							| 
									
										
										
										
											2009-11-12 12:52:40 +08:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  | #include <gtsam/base/types.h>
 | 
					
						
							| 
									
										
										
										
											2010-08-20 01:23:19 +08:00
										 |  |  | #include <gtsam/inference/FactorGraph.h>
 | 
					
						
							|  |  |  | #include <gtsam/inference/BayesNet.h>
 | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  | #include <gtsam/inference/VariableIndex.h>
 | 
					
						
							|  |  |  | #include <gtsam/inference/Permutation.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <vector>
 | 
					
						
							|  |  |  | #include <deque>
 | 
					
						
							| 
									
										
										
										
											2009-11-12 12:52:40 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace gtsam { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  | 	class Inference { | 
					
						
							|  |  |  | 	private: | 
					
						
							|  |  |  | 	  /* Static members only, private constructor */ | 
					
						
							|  |  |  | 	  Inference() {} | 
					
						
							| 
									
										
										
										
											2009-11-12 12:52:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  | 	public: | 
					
						
							| 
									
										
										
										
											2009-11-12 12:52:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  |     /**
 | 
					
						
							|  |  |  |      * Compute a permutation (variable ordering) using colamd | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2010-10-20 09:10:27 +08:00
										 |  |  |     template<class VARIABLEINDEXTYPE> | 
					
						
							|  |  |  |     static boost::shared_ptr<Permutation> PermutationCOLAMD(const VARIABLEINDEXTYPE& variableIndex) { return PermutationCOLAMD(variableIndex, std::vector<Index>()); } | 
					
						
							|  |  |  |     template<class VARIABLEINDEXTYPE, typename CONSTRAINTCONTAINER> | 
					
						
							|  |  |  |     static boost::shared_ptr<Permutation> PermutationCOLAMD(const VARIABLEINDEXTYPE& variableIndex, const CONSTRAINTCONTAINER& constrainLast); | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// ELIMINATE: FACTOR GRAPH -> BAYES NET
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //	/**
 | 
					
						
							|  |  |  | //   * Eliminate a single node yielding a Conditional
 | 
					
						
							|  |  |  | //   * Eliminates the factors from the factor graph through findAndRemoveFactors
 | 
					
						
							|  |  |  | //   * and adds a new factor on the separator to the factor graph
 | 
					
						
							|  |  |  | //   */
 | 
					
						
							|  |  |  | //	template<class Factor, class Conditional>
 | 
					
						
							|  |  |  | //	boost::shared_ptr<Conditional>
 | 
					
						
							| 
									
										
										
										
											2010-10-12 05:14:35 +08:00
										 |  |  | //	eliminateOne(FactorGraph<Factor>& factorGraph, Index key);
 | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  | //
 | 
					
						
							|  |  |  | //	/**
 | 
					
						
							|  |  |  | //	 * eliminate factor graph using the given (not necessarily complete)
 | 
					
						
							|  |  |  | //	 * ordering, yielding a chordal Bayes net and (partially eliminated) FG
 | 
					
						
							|  |  |  | //	 */
 | 
					
						
							|  |  |  | //	template<class Factor, class Conditional>
 | 
					
						
							|  |  |  | //	BayesNet<Conditional> eliminate(FactorGraph<Factor>& factorGraph, const Ordering& ordering);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// FACTOR/MARGINALIZE: BAYES NET -> FACTOR GRAPH
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //	/**
 | 
					
						
							|  |  |  | //	 * Factor P(X) as P(not keys|keys) P(keys)
 | 
					
						
							|  |  |  | //	 * @return P(not keys|keys) as an incomplete BayesNet, and P(keys) as a factor graph
 | 
					
						
							|  |  |  | //	 */
 | 
					
						
							|  |  |  | //	template<class Factor, class Conditional>
 | 
					
						
							|  |  |  | //	std::pair< BayesNet<Conditional>, FactorGraph<Factor> >
 | 
					
						
							|  |  |  | //	factor(const BayesNet<Conditional>& bn, const Ordering& keys);
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //	/**
 | 
					
						
							|  |  |  | //	 * integrate out all except ordering, might be inefficient as the ordering
 | 
					
						
							|  |  |  | //	 * will simply be the current ordering with the keys put in the back
 | 
					
						
							|  |  |  | //	 */
 | 
					
						
							|  |  |  | //	template<class Factor, class Conditional>
 | 
					
						
							|  |  |  | //	FactorGraph<Factor> marginalize(const BayesNet<Conditional>& bn, const Ordering& keys);
 | 
					
						
							| 
									
										
										
										
											2009-11-12 12:52:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-05 06:03:40 +08:00
										 |  |  | 	/**
 | 
					
						
							|  |  |  | 	 * Hacked-together function to compute a Gaussian marginal for the given variable. | 
					
						
							|  |  |  | 	 * todo: This is inefficient! | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2010-03-05 06:40:01 +08:00
										 |  |  | 	//std::pair<Vector,Matrix> marginalGaussian(const GaussianFactorGraph& fg, const Symbol& key);
 | 
					
						
							| 
									
										
										
										
											2010-03-05 06:03:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-12 12:52:40 +08:00
										 |  |  | } /// namespace gtsam
 |