Loading...
Searching...
No Matches
SymbolicFactorGraph.h
Go to the documentation of this file.
/* ----------------------------------------------------------------------------
* 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
* -------------------------------------------------------------------------- */
#pragma once
#include <gtsam/symbolic/SymbolicFactor.h>
#include <gtsam/inference/FactorGraph.h>
#include <gtsam/inference/EliminateableFactorGraph.h>
#include <gtsam/base/types.h>
namespace gtsam {
class SymbolicFactorGraph;
class SymbolicConditional;
class SymbolicBayesNet;
class SymbolicEliminationTree;
class SymbolicBayesTree;
class SymbolicJunctionTree;
/* ************************************************************************* */
template<> struct EliminationTraits<SymbolicFactorGraph>
{
typedef SymbolicFactor FactorType;
typedef SymbolicFactorGraph FactorGraphType;
typedef SymbolicConditional ConditionalType;
typedef SymbolicBayesNet BayesNetType;
typedef SymbolicEliminationTree EliminationTreeType;
typedef SymbolicBayesTree BayesTreeType;
typedef SymbolicJunctionTree JunctionTreeType;
static std::pair<boost::shared_ptr<ConditionalType>, boost::shared_ptr<FactorType> >
DefaultEliminate(const FactorGraphType& factors, const Ordering& keys) {
return EliminateSymbolic(factors, keys); }
static Ordering DefaultOrderingFunc(
const FactorGraphType& graph,
boost::optional<const VariableIndex&> variableIndex) {
return Ordering::Colamd(*variableIndex);
}
};
/* ************************************************************************* */
class GTSAM_EXPORT SymbolicFactorGraph :
public FactorGraph<SymbolicFactor>,
public EliminateableFactorGraph<SymbolicFactorGraph>
{
public:
typedef SymbolicFactorGraph This;
typedef FactorGraph<SymbolicFactor> Base;
typedef EliminateableFactorGraph<This> BaseEliminateable;
typedef boost::shared_ptr<This> shared_ptr;
SymbolicFactorGraph() {}
template<typename ITERATOR>
SymbolicFactorGraph(ITERATOR firstFactor, ITERATOR lastFactor) : Base(firstFactor, lastFactor) {}
template<class CONTAINER>
explicit SymbolicFactorGraph(const CONTAINER& factors) : Base(factors) {}
template<class DERIVEDFACTOR>
SymbolicFactorGraph(const FactorGraph<DERIVEDFACTOR>& graph) : Base(graph) {}
SymbolicFactorGraph(
std::initializer_list<boost::shared_ptr<SymbolicFactor>> sharedFactors)
: Base(sharedFactors) {}
SymbolicFactorGraph(SymbolicFactor&& c) {
push_back(boost::make_shared<SymbolicFactor>(c));
}
SymbolicFactorGraph& operator()(SymbolicFactor&& c) {
push_back(boost::make_shared<SymbolicFactor>(c));
return *this;
}
virtual ~SymbolicFactorGraph() {}
bool equals(const This& fg, double tol = 1e-9) const;
void print(
const std::string& s = "SymbolicFactorGraph",
const KeyFormatter& formatter = DefaultKeyFormatter) const override {
Base::print(s, formatter);
}
void push_factor(Key key);
void push_factor(Key key1, Key key2);
void push_factor(Key key1, Key key2, Key key3);
void push_factor(Key key1, Key key2, Key key3, Key key4);
private:
friend class boost::serialization::access;
template<class ARCHIVE>
void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
}
};
template<>
struct traits<SymbolicFactorGraph> : public Testable<SymbolicFactorGraph> {
};
} //\ namespace gtsam
types.h
Typedefs for easier changing of types.
FactorGraph.h
Factor Graph Base Class.
EliminateableFactorGraph.h
Variable elimination algorithms for factor graphs.
SymbolicFactor.h
gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
gtsam::EliminateSymbolic
std::pair< boost::shared_ptr< SymbolicConditional >, boost::shared_ptr< SymbolicFactor > > EliminateSymbolic(const SymbolicFactorGraph &factors, const Ordering &keys)
Dense elimination function for symbolic factors.
Definition SymbolicFactor.cpp:36
gtsam::KeyFormatter
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition Key.h:35
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:100
gtsam::traits
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition concepts.h:30
gtsam::equals
Template to create a binary predicate.
Definition Testable.h:111
gtsam::Testable
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:151
gtsam::FactorGraph< SymbolicFactor >::print
virtual void print(const std::string &s="FactorGraph", const KeyFormatter &formatter=DefaultKeyFormatter) const
gtsam::FactorGraph< SymbolicFactor >::push_back
IsDerived< DERIVEDFACTOR > push_back(boost::shared_ptr< DERIVEDFACTOR > factor)
Definition FactorGraph.h:186
gtsam::FactorGraph< SymbolicFactor >::FactorGraph
FactorGraph()
Definition FactorGraph.h:142
gtsam::EliminationTraits
Traits class for eliminateable factor graphs, specifies the types that result from elimination,...
Definition EliminateableFactorGraph.h:36
gtsam::EliminateableFactorGraph
EliminateableFactorGraph is a base class for factor graphs that contains elimination algorithms.
Definition EliminateableFactorGraph.h:57
gtsam::Ordering
Definition Ordering.h:34
gtsam::Ordering::Colamd
static Ordering Colamd(const FACTOR_GRAPH &graph)
Compute a fill-reducing ordering using COLAMD from a factor graph (see details for note on performanc...
Definition Ordering.h:95
gtsam::SymbolicBayesNet
A SymbolicBayesNet is a Bayes Net of purely symbolic conditionals.
Definition SymbolicBayesNet.h:32
gtsam::SymbolicBayesTree
A Bayes tree that represents the connectivity between variables but is not associated with any probab...
Definition SymbolicBayesTree.h:51
gtsam::SymbolicConditional
SymbolicConditional is a conditional with keys but no probability data, produced by symbolic eliminat...
Definition SymbolicConditional.h:38
gtsam::SymbolicEliminationTree
Definition SymbolicEliminationTree.h:29
gtsam::SymbolicFactor
SymbolicFactor represents a symbolic factor that specifies graph topology but is not associated with ...
Definition SymbolicFactor.h:39
gtsam::EliminationTraits< SymbolicFactorGraph >::FactorType
SymbolicFactor FactorType
Type of factors in factor graph.
Definition SymbolicFactorGraph.h:38
gtsam::EliminationTraits< SymbolicFactorGraph >::FactorGraphType
SymbolicFactorGraph FactorGraphType
Type of the factor graph (e.g. GaussianFactorGraph).
Definition SymbolicFactorGraph.h:39
gtsam::EliminationTraits< SymbolicFactorGraph >::EliminationTreeType
SymbolicEliminationTree EliminationTreeType
Type of elimination tree.
Definition SymbolicFactorGraph.h:42
gtsam::EliminationTraits< SymbolicFactorGraph >::BayesNetType
SymbolicBayesNet BayesNetType
Type of Bayes net from sequential elimination.
Definition SymbolicFactorGraph.h:41
gtsam::EliminationTraits< SymbolicFactorGraph >::DefaultEliminate
static std::pair< boost::shared_ptr< ConditionalType >, boost::shared_ptr< FactorType > > DefaultEliminate(const FactorGraphType &factors, const Ordering &keys)
The default dense elimination function.
Definition SymbolicFactorGraph.h:47
gtsam::EliminationTraits< SymbolicFactorGraph >::DefaultOrderingFunc
static Ordering DefaultOrderingFunc(const FactorGraphType &graph, boost::optional< const VariableIndex & > variableIndex)
The default ordering generation function.
Definition SymbolicFactorGraph.h:50
gtsam::EliminationTraits< SymbolicFactorGraph >::JunctionTreeType
SymbolicJunctionTree JunctionTreeType
Type of Junction tree.
Definition SymbolicFactorGraph.h:44
gtsam::EliminationTraits< SymbolicFactorGraph >::BayesTreeType
SymbolicBayesTree BayesTreeType
Type of Bayes tree.
Definition SymbolicFactorGraph.h:43
gtsam::EliminationTraits< SymbolicFactorGraph >::ConditionalType
SymbolicConditional ConditionalType
Type of conditionals from elimination.
Definition SymbolicFactorGraph.h:40
gtsam::SymbolicFactorGraph
Symbolic Factor Graph.
Definition SymbolicFactorGraph.h:64
gtsam::SymbolicFactorGraph::SymbolicFactorGraph
SymbolicFactorGraph(SymbolicFactor &&c)
Construct from a single factor.
Definition SymbolicFactorGraph.h:99
gtsam::SymbolicFactorGraph::operator()
SymbolicFactorGraph & operator()(SymbolicFactor &&c)
Add a single factor and return a reference.
Definition SymbolicFactorGraph.h:109
gtsam::SymbolicFactorGraph::SymbolicFactorGraph
SymbolicFactorGraph()
Construct empty factor graph.
Definition SymbolicFactorGraph.h:76
gtsam::SymbolicFactorGraph::SymbolicFactorGraph
SymbolicFactorGraph(const FactorGraph< DERIVEDFACTOR > &graph)
Implicit copy/downcast constructor to override explicit template container constructor.
Definition SymbolicFactorGraph.h:88
gtsam::SymbolicFactorGraph::SymbolicFactorGraph
SymbolicFactorGraph(std::initializer_list< boost::shared_ptr< SymbolicFactor > > sharedFactors)
Constructor that takes an initializer list of shared pointers.
Definition SymbolicFactorGraph.h:94
gtsam::SymbolicFactorGraph::print
void print(const std::string &s="SymbolicFactorGraph", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print
Definition SymbolicFactorGraph.h:125
gtsam::SymbolicFactorGraph::BaseEliminateable
EliminateableFactorGraph< This > BaseEliminateable
Typedef to base elimination class.
Definition SymbolicFactorGraph.h:69
gtsam::SymbolicFactorGraph::shared_ptr
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition SymbolicFactorGraph.h:70
gtsam::SymbolicFactorGraph::This
SymbolicFactorGraph This
Typedef to this class.
Definition SymbolicFactorGraph.h:67
gtsam::SymbolicFactorGraph::SymbolicFactorGraph
SymbolicFactorGraph(ITERATOR firstFactor, ITERATOR lastFactor)
Construct from iterator over factors.
Definition SymbolicFactorGraph.h:80
gtsam::SymbolicFactorGraph::~SymbolicFactorGraph
virtual ~SymbolicFactorGraph()
Destructor.
Definition SymbolicFactorGraph.h:115
gtsam::SymbolicFactorGraph::Base
FactorGraph< SymbolicFactor > Base
Typedef to base factor graph type.
Definition SymbolicFactorGraph.h:68
gtsam::SymbolicFactorGraph::SymbolicFactorGraph
SymbolicFactorGraph(const CONTAINER &factors)
Construct from container of factors (shared_ptr or plain objects).
Definition SymbolicFactorGraph.h:84
gtsam::SymbolicJunctionTree
A EliminatableClusterTree, i.e., a set of variable clusters with factors, arranged in a tree,...
Definition SymbolicJunctionTree.h:51