/* ---------------------------------------------------------------------------- * 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 SymbolicFactorGraph.h * @date Oct 29, 2009 * @author Frank Dellaert * @author Richard Roberts */ #pragma once #include #include #include #include namespace gtsam { class SymbolicFactorGraph; class SymbolicConditional; class SymbolicBayesNet; class SymbolicEliminationTree; class SymbolicBayesTree; class SymbolicJunctionTree; /* ************************************************************************* */ template<> struct EliminationTraits { typedef SymbolicFactor FactorType; ///< Type of factors in factor graph typedef SymbolicFactorGraph FactorGraphType; ///< Type of the factor graph (e.g. GaussianFactorGraph) typedef SymbolicConditional ConditionalType; ///< Type of conditionals from elimination typedef SymbolicBayesNet BayesNetType; ///< Type of Bayes net from sequential elimination typedef SymbolicEliminationTree EliminationTreeType; ///< Type of elimination tree typedef SymbolicBayesTree BayesTreeType; ///< Type of Bayes tree typedef SymbolicJunctionTree JunctionTreeType; ///< Type of Junction tree /// The default dense elimination function static std::pair, boost::shared_ptr > DefaultEliminate(const FactorGraphType& factors, const Ordering& keys) { return EliminateSymbolic(factors, keys); } }; /* ************************************************************************* */ /** Symbolic Factor Graph * \nosubgrouping */ class GTSAM_EXPORT SymbolicFactorGraph : public FactorGraph, public EliminateableFactorGraph { public: typedef SymbolicFactorGraph This; ///< Typedef to this class typedef FactorGraph Base; ///< Typedef to base factor graph type typedef EliminateableFactorGraph BaseEliminateable; ///< Typedef to base elimination class typedef boost::shared_ptr shared_ptr; ///< shared_ptr to this class /// @name Standard Constructors /// @{ /** Construct empty factor graph */ SymbolicFactorGraph() {} /** Construct from iterator over factors */ template SymbolicFactorGraph(ITERATOR firstFactor, ITERATOR lastFactor) : Base(firstFactor, lastFactor) {} /** Construct from container of factors (shared_ptr or plain objects) */ template explicit SymbolicFactorGraph(const CONTAINER& factors) : Base(factors) {} /** Implicit copy/downcast constructor to override explicit template container constructor */ template SymbolicFactorGraph(const FactorGraph& graph) : Base(graph) {} /// @} /// @name Testable /// @{ bool equals(const This& fg, double tol = 1e-9) const; /// @} /// @name Standard Interface /// @{ /** Push back unary factor */ void push_factor(Key key); /** Push back binary factor */ void push_factor(Key key1, Key key2); /** Push back ternary factor */ void push_factor(Key key1, Key key2, Key key3); /** Push back 4-way factor */ void push_factor(Key key1, Key key2, Key key3, Key key4); /// @} private: /** Serialization function */ friend class boost::serialization::access; template void serialize(ARCHIVE & ar, const unsigned int version) { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base); } }; /// traits template<> struct traits : public Testable { }; } //\ namespace gtsam