/* ---------------------------------------------------------------------------- * 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 inference.h * @brief Contains *generic* inference algorithms that convert between templated * graphical models, i.e., factor graphs, Bayes nets, and Bayes trees * @author Frank Dellaert, Richard Roberts */ #pragma once #include #include #include #include #include #include #include namespace gtsam { class Inference { private: /* Static members only, private constructor */ Inference() {} public: /** * Compute a permutation (variable ordering) using colamd */ template static boost::shared_ptr PermutationCOLAMD(const VARIABLEINDEXTYPE& variableIndex) { return PermutationCOLAMD(variableIndex, std::vector()); } template static boost::shared_ptr PermutationCOLAMD(const VARIABLEINDEXTYPE& variableIndex, const CONSTRAINTCONTAINER& constrainLast); }; // 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 // boost::shared_ptr // eliminateOne(FactorGraph& factorGraph, Index key); // // /** // * eliminate factor graph using the given (not necessarily complete) // * ordering, yielding a chordal Bayes net and (partially eliminated) FG // */ // template // BayesNet eliminate(FactorGraph& 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 // std::pair< BayesNet, FactorGraph > // factor(const BayesNet& 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 // FactorGraph marginalize(const BayesNet& bn, const Ordering& keys); /** * Hacked-together function to compute a Gaussian marginal for the given variable. * todo: This is inefficient! */ //std::pair marginalGaussian(const GaussianFactorGraph& fg, const Symbol& key); } /// namespace gtsam