Added partial sequential and multifrontal elimination and const fixes
							parent
							
								
									da99a6e9fb
								
							
						
					
					
						commit
						642eca5fc5
					
				|  | @ -33,8 +33,8 @@ namespace gtsam { | |||
|   { | ||||
|     if(ordering && variableIndex) { | ||||
|       // Do elimination
 | ||||
|       std::pair<boost::shared_ptr<BAYESNET>, boost::shared_ptr<FACTORGRAPH> > result = | ||||
|         ELIMINATIONTREE(asDerived(), *variableIndex, *ordering).eliminate(function); | ||||
|       std::pair<boost::shared_ptr<BAYESNET>, boost::shared_ptr<FACTORGRAPH> > result | ||||
|         = ELIMINATIONTREE(asDerived(), *variableIndex, *ordering).eliminate(function); | ||||
|       // If any factors are remaining, the ordering was incomplete
 | ||||
|       if(!result.second->empty()) | ||||
|         throw InconsistentEliminationRequested(); | ||||
|  | @ -59,15 +59,13 @@ namespace gtsam { | |||
|   template<class FACTOR, class FACTORGRAPH, class CONDITIONAL, | ||||
|   class BAYESNET, class ELIMINATIONTREE, class BAYESTREE, class JUNCTIONTREE> | ||||
|     boost::shared_ptr<BAYESTREE> | ||||
|     EliminateableFactorGraph<FACTOR, FACTORGRAPH, CONDITIONAL, BAYESNET, ELIMINATIONTREE, BAYESTREE, JUNCTIONTREE>:: | ||||
|     eliminateMultifrontal( | ||||
|     const Eliminate& function, OptionalOrdering ordering, OptionalVariableIndex variableIndex) const | ||||
|     EliminateableFactorGraph<FACTOR, FACTORGRAPH, CONDITIONAL, BAYESNET, ELIMINATIONTREE, BAYESTREE, JUNCTIONTREE> | ||||
|     ::eliminateMultifrontal(const Eliminate& function, OptionalOrdering ordering, OptionalVariableIndex variableIndex) const | ||||
|   { | ||||
|     if(ordering && variableIndex) { | ||||
|       // Do elimination
 | ||||
|       std::pair<boost::shared_ptr<BAYESTREE>, boost::shared_ptr<FACTORGRAPH> > result; | ||||
|       // Do elimination with given ordering
 | ||||
|       result = JUNCTIONTREE(ELIMINATIONTREE(asDerived(), *variableIndex, *ordering)).eliminate(function); | ||||
|       std::pair<boost::shared_ptr<BAYESTREE>, boost::shared_ptr<FACTORGRAPH> > result | ||||
|         = JUNCTIONTREE(ELIMINATIONTREE(asDerived(), *variableIndex, *ordering)).eliminate(function); | ||||
|       // If any factors are remaining, the ordering was incomplete
 | ||||
|       if(!result.second->empty()) | ||||
|         throw InconsistentEliminationRequested(); | ||||
|  | @ -88,4 +86,39 @@ namespace gtsam { | |||
|     } | ||||
|   } | ||||
| 
 | ||||
|   /* ************************************************************************* */ | ||||
|   template<class FACTOR, class FACTORGRAPH, class CONDITIONAL, | ||||
|   class BAYESNET, class ELIMINATIONTREE, class BAYESTREE, class JUNCTIONTREE> | ||||
|     std::pair<boost::shared_ptr<BAYESNET>, boost::shared_ptr<FACTORGRAPH> > | ||||
|     EliminateableFactorGraph<FACTOR, FACTORGRAPH, CONDITIONAL, BAYESNET, ELIMINATIONTREE, BAYESTREE, JUNCTIONTREE> | ||||
|     ::eliminatePartialSequential(const Eliminate& function, const OrderingUnordered& ordering, | ||||
|     OptionalVariableIndex variableIndex = boost::none) const | ||||
|   { | ||||
|     if(variableIndex) { | ||||
|       // Do elimination
 | ||||
|       return ELIMINATIONTREE(asDerived(), *variableIndex, ordering).eliminate(function); | ||||
|     } else { | ||||
|       // If no variable index is provided, compute one and call this function again
 | ||||
|       return eliminatePartialSequential(function, ordering, VariableIndexUnordered(asDerived())); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   /* ************************************************************************* */ | ||||
|   template<class FACTOR, class FACTORGRAPH, class CONDITIONAL, | ||||
|   class BAYESNET, class ELIMINATIONTREE, class BAYESTREE, class JUNCTIONTREE> | ||||
|     std::pair<boost::shared_ptr<BAYESTREE>, boost::shared_ptr<FACTORGRAPH> > | ||||
|     EliminateableFactorGraph<FACTOR, FACTORGRAPH, CONDITIONAL, BAYESNET, ELIMINATIONTREE, BAYESTREE, JUNCTIONTREE> | ||||
|     ::eliminatePartialMultifrontal(const Eliminate& function, const OrderingUnordered& ordering, | ||||
|     OptionalVariableIndex variableIndex = boost::none) const | ||||
|   { | ||||
|     if(variableIndex) { | ||||
|       // Do elimination
 | ||||
|       return JUNCTIONTREE(ELIMINATIONTREE(asDerived(), *variableIndex, ordering)).eliminate(function); | ||||
|     } else { | ||||
|       // If no variable index is provided, compute one and call this function again
 | ||||
|       return eliminatePartialMultifrontal(function, ordering, VariableIndexUnordered(asDerived())); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -96,7 +96,7 @@ namespace gtsam { | |||
|      *  B = X\backslash A \f$. */ | ||||
|     std::pair<boost::shared_ptr<BAYESNET>, boost::shared_ptr<FACTORGRAPH> > | ||||
|       eliminatePartialSequential(const Eliminate& function, const OrderingUnordered& ordering, | ||||
|       OptionalVariableIndex variableIndex = boost::none); | ||||
|       OptionalVariableIndex variableIndex = boost::none) const; | ||||
| 
 | ||||
|     /** Do sequential elimination of the given \c variables in an ordering computed by COLAMD to
 | ||||
|      *  produce a Bayes net and a remaining factor graph.  This computes the factorization \f$ p(X) | ||||
|  | @ -104,7 +104,7 @@ namespace gtsam { | |||
|      *  factor graph, and \f$ B = X\backslash A \f$. */ | ||||
|     std::pair<boost::shared_ptr<BAYESNET>, boost::shared_ptr<FACTORGRAPH> > | ||||
|       eliminatePartialSequential(const Eliminate& function, const std::vector<Key>& variables, | ||||
|       OptionalVariableIndex variableIndex = boost::none); | ||||
|       OptionalVariableIndex variableIndex = boost::none) const; | ||||
| 
 | ||||
|     /** Do multifrontal elimination of the given \c variables in an ordering computed by COLAMD to
 | ||||
|      *  produce a Bayes net and a remaining factor graph.  This computes the factorization \f$ p(X) | ||||
|  | @ -112,7 +112,7 @@ namespace gtsam { | |||
|      *  factor graph, and \f$ B = X\backslash A \f$. */ | ||||
|     std::pair<boost::shared_ptr<BAYESTREE>, boost::shared_ptr<FACTORGRAPH> > | ||||
|       eliminatePartialMultifrontal(const Eliminate& function, const OrderingUnordered& ordering, | ||||
|       OptionalVariableIndex variableIndex = boost::none); | ||||
|       OptionalVariableIndex variableIndex = boost::none) const; | ||||
|      | ||||
|     /** Do multifrontal elimination of some variables in the given \c ordering to produce a Bayes
 | ||||
|      *  tree and a remaining factor graph.  This computes the factorization \f$ p(X) = p(A|B) p(B) | ||||
|  | @ -120,7 +120,7 @@ namespace gtsam { | |||
|      *  \f$ B = X\backslash A \f$. */ | ||||
|     std::pair<boost::shared_ptr<BAYESTREE>, boost::shared_ptr<FACTORGRAPH> > | ||||
|       eliminatePartialMultifrontal(const Eliminate& function, const std::vector<Key>& variables, | ||||
|       OptionalVariableIndex variableIndex = boost::none); | ||||
|       OptionalVariableIndex variableIndex = boost::none) const; | ||||
| 
 | ||||
|   private: | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue