| 
									
										
										
										
											2009-10-28 04:23:19 +08:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * @file    BayesChain | 
					
						
							|  |  |  |  * @brief   Bayes Chain, the result of eliminating a factor graph | 
					
						
							|  |  |  |  * @author  Frank Dellaert | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // \callgraph
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-28 10:57:38 +08:00
										 |  |  | #include <boost/shared_ptr.hpp>
 | 
					
						
							| 
									
										
										
										
											2009-10-28 04:23:19 +08:00
										 |  |  | #include <boost/serialization/map.hpp>
 | 
					
						
							|  |  |  | #include <boost/serialization/list.hpp>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-28 10:57:38 +08:00
										 |  |  | #include "Testable.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-28 04:23:19 +08:00
										 |  |  | namespace gtsam { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/**
 | 
					
						
							|  |  |  | 	 * Bayes Chain, the result of eliminating a factor graph | 
					
						
							|  |  |  | 	 * This is the base class for SymbolicBayesChain, DiscreteBayesChain, and GaussianBayesChain | 
					
						
							|  |  |  | 	 * Corresponding to what is used for the "Conditional" template argument: | 
					
						
							|  |  |  | 	 * a ConditionalProbabilityTable, a ConditionalGaussian, or a SymbolicConditional. | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	template<class Conditional> | 
					
						
							| 
									
										
										
										
											2009-10-28 10:57:38 +08:00
										 |  |  | 	class BayesChain: public Testable<BayesChain<Conditional> > { | 
					
						
							|  |  |  | 	protected: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/** nodes keys stored in topological sort order, i.e. from parents to children */ | 
					
						
							|  |  |  | 		std::list<std::string> keys_; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/** nodes stored on key */ | 
					
						
							|  |  |  | 		typedef typename std::map<std::string, boost::shared_ptr<Conditional> > Nodes; | 
					
						
							|  |  |  | 		Nodes nodes_; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		typedef typename Nodes::const_iterator const_iterator; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-28 04:23:19 +08:00
										 |  |  | 	public: | 
					
						
							| 
									
										
										
										
											2009-10-28 10:57:38 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		/** print */ | 
					
						
							|  |  |  | 		void print(const std::string& s = "") const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/** check equality */ | 
					
						
							|  |  |  | 		bool equals(const BayesChain& other, double tol = 1e-9) const; | 
					
						
							| 
									
										
										
										
											2009-10-28 04:23:19 +08:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } /// namespace gtsam
 |