| 
									
										
										
										
											2012-05-15 17:51:26 +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 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * -------------------------------------------------------------------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  *  @file Constraint.h | 
					
						
							|  |  |  |  *  @date May 15, 2012 | 
					
						
							|  |  |  |  *  @author Frank Dellaert | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-14 02:56:21 +08:00
										 |  |  | #include <gtsam_unstable/base/dllexport.h>
 | 
					
						
							| 
									
										
										
										
											2012-05-15 17:51:26 +08:00
										 |  |  | #include <gtsam/discrete/DiscreteFactor.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace gtsam { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   class Domain; | 
					
						
							| 
									
										
										
										
											2012-05-15 17:51:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   /**
 | 
					
						
							|  |  |  |    * Base class for discrete probabilistic factors | 
					
						
							|  |  |  |    * The most general one is the derived DecisionTreeFactor | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  |   class Constraint : public DiscreteFactor { | 
					
						
							| 
									
										
										
										
											2012-05-15 17:51:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   public: | 
					
						
							| 
									
										
										
										
											2012-05-15 17:51:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     typedef boost::shared_ptr<Constraint> shared_ptr; | 
					
						
							| 
									
										
										
										
											2012-05-15 17:51:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   protected: | 
					
						
							| 
									
										
										
										
											2012-05-15 17:51:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     /// Construct n-way factor
 | 
					
						
							|  |  |  |     Constraint(const std::vector<Index>& js) : | 
					
						
							|  |  |  |       DiscreteFactor(js) { | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-05-15 17:51:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     /// Construct unary factor
 | 
					
						
							|  |  |  |     Constraint(Index j) : | 
					
						
							|  |  |  |       DiscreteFactor(j) { | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-05-15 17:51:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     /// Construct binary factor
 | 
					
						
							|  |  |  |     Constraint(Index j1, Index j2) : | 
					
						
							|  |  |  |       DiscreteFactor(j1, j2) { | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-05-15 17:51:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     /// construct from container
 | 
					
						
							|  |  |  |     template<class KeyIterator> | 
					
						
							|  |  |  |     Constraint(KeyIterator beginKey, KeyIterator endKey) : | 
					
						
							|  |  |  |       DiscreteFactor(beginKey, endKey) { | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-05-15 17:51:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   public: | 
					
						
							| 
									
										
										
										
											2012-05-15 17:51:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     /// @name Standard Constructors
 | 
					
						
							|  |  |  |     /// @{
 | 
					
						
							| 
									
										
										
										
											2012-05-15 17:51:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     /// Default constructor for I/O
 | 
					
						
							|  |  |  |     Constraint(); | 
					
						
							| 
									
										
										
										
											2012-05-15 17:51:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     /// Virtual destructor
 | 
					
						
							|  |  |  |     virtual ~Constraint() {} | 
					
						
							| 
									
										
										
										
											2012-05-15 17:51:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     /// @}
 | 
					
						
							|  |  |  |     /// @name Standard Interface
 | 
					
						
							|  |  |  |     /// @{
 | 
					
						
							| 
									
										
										
										
											2012-05-15 17:51:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     /*
 | 
					
						
							|  |  |  |      * Ensure Arc-consistency | 
					
						
							|  |  |  |      * @param j domain to be checked | 
					
						
							|  |  |  |      * @param domains all other domains | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     virtual bool ensureArcConsistency(size_t j, std::vector<Domain>& domains) const = 0; | 
					
						
							| 
									
										
										
										
											2012-05-15 17:51:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     /// Partially apply known values
 | 
					
						
							|  |  |  |     virtual shared_ptr partiallyApply(const Values&) const = 0; | 
					
						
							| 
									
										
										
										
											2012-05-15 17:51:26 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |     /// Partially apply known values, domain version
 | 
					
						
							|  |  |  |     virtual shared_ptr partiallyApply(const std::vector<Domain>&) const = 0; | 
					
						
							|  |  |  |     /// @}
 | 
					
						
							|  |  |  |   }; | 
					
						
							| 
									
										
										
										
											2012-05-15 17:51:26 +08:00
										 |  |  | // DiscreteFactor
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }// namespace gtsam
 |