Loading...
Searching...
No Matches
SymbolicFactor.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/inference/Factor.h>
#include <gtsam/inference/Key.h>
#include <gtsam/base/Testable.h>
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include <utility>
namespace gtsam {
// Forward declarations
class SymbolicConditional;
class HybridValues;
class Ordering;
class GTSAM_EXPORT SymbolicFactor : public Factor {
public:
typedef SymbolicFactor This;
typedef Factor Base;
typedef SymbolicConditional ConditionalType;
typedef boost::shared_ptr<This> shared_ptr;
SymbolicFactor() {}
explicit SymbolicFactor(Key j) :
Base(KeyVector{j}) {}
SymbolicFactor(Key j1, Key j2) :
Base(KeyVector{j1, j2}) {}
SymbolicFactor(Key j1, Key j2, Key j3) :
Base(KeyVector{j1, j2, j3}) {}
SymbolicFactor(Key j1, Key j2, Key j3, Key j4) :
Base(KeyVector{j1, j2, j3, j4}) {}
SymbolicFactor(Key j1, Key j2, Key j3, Key j4, Key j5) :
Base(KeyVector{j1, j2, j3, j4, j5}) {}
SymbolicFactor(Key j1, Key j2, Key j3, Key j4, Key j5, Key j6) :
Base(KeyVector{j1, j2, j3, j4, j5, j6}) {}
explicit SymbolicFactor(const Factor& factor) : Base(factor.keys()) {}
virtual ~SymbolicFactor() {}
SymbolicFactor::shared_ptr clone() const { return boost::make_shared<This>(*this); }
bool equals(const This& other, double tol = 1e-9) const;
void print(
const std::string& s = "SymbolicFactor",
const KeyFormatter& formatter = DefaultKeyFormatter) const override {
Base::print(s, formatter);
}
void printKeys(
const std::string& s = "SymbolicFactor",
const KeyFormatter& formatter = DefaultKeyFormatter) const override {
Base::printKeys(s, formatter);
}
template<typename KEYITERATOR>
static SymbolicFactor FromIterators(KEYITERATOR beginKey, KEYITERATOR endKey) {
return SymbolicFactor(Base::FromIterators(beginKey, endKey));
}
template<typename KEYITERATOR>
static SymbolicFactor::shared_ptr FromIteratorsShared(KEYITERATOR beginKey, KEYITERATOR endKey) {
SymbolicFactor::shared_ptr result = boost::make_shared<SymbolicFactor>();
result->keys_.assign(beginKey, endKey);
return result;
}
template<class CONTAINER>
static SymbolicFactor FromKeys(const CONTAINER& keys) {
return SymbolicFactor(Base::FromKeys(keys));
}
template<class CONTAINER>
static SymbolicFactor::shared_ptr FromKeysShared(const CONTAINER& keys) {
return FromIteratorsShared(keys.begin(), keys.end());
}
double error(const HybridValues& c) const override;
std::pair<boost::shared_ptr<SymbolicConditional>, boost::shared_ptr<SymbolicFactor> >
eliminate(const Ordering& keys) const;
private:
friend class boost::serialization::access;
template<class ARCHIVE>
void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
}
}; // IndexFactor
// Forward declarations
class SymbolicFactorGraph;
class Ordering;
GTSAM_EXPORT std::pair<boost::shared_ptr<SymbolicConditional>, boost::shared_ptr<SymbolicFactor> >
EliminateSymbolic(const SymbolicFactorGraph& factors, const Ordering& keys);
template<>
struct traits<SymbolicFactor> : public Testable<SymbolicFactor> {
};
} //\ namespace gtsam
Testable.h
Concept check for values that can be used in unit tests.
Factor.h
The base class for all factors.
Key.h
gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
gtsam::KeyVector
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition Key.h:86
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::HybridValues
HybridValues represents a collection of DiscreteValues and VectorValues.
Definition HybridValues.h:38
gtsam::Factor::keys
const KeyVector & keys() const
Access the factor's involved variable keys.
Definition Factor.h:140
gtsam::Factor::Factor
Factor()
Default constructor for I/O.
Definition Factor.h:91
gtsam::Factor::FromIterators
static Factor FromIterators(ITERATOR first, ITERATOR last)
Construct factor from iterator keys.
Definition Factor.h:112
gtsam::Factor::FromKeys
static Factor FromKeys(const CONTAINER &keys)
Construct factor from container of keys.
Definition Factor.h:106
gtsam::Factor::printKeys
virtual void printKeys(const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const
print only keys
Definition Factor.cpp:35
gtsam::Factor::print
virtual void print(const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const
print
Definition Factor.cpp:29
gtsam::Ordering
Definition Ordering.h:34
gtsam::SymbolicConditional
SymbolicConditional is a conditional with keys but no probability data, produced by symbolic eliminat...
Definition SymbolicConditional.h:38
gtsam::SymbolicFactor
SymbolicFactor represents a symbolic factor that specifies graph topology but is not associated with ...
Definition SymbolicFactor.h:39
gtsam::SymbolicFactor::print
void print(const std::string &s="SymbolicFactor", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print
Definition SymbolicFactor.h:96
gtsam::SymbolicFactor::SymbolicFactor
SymbolicFactor(Key j1, Key j2, Key j3, Key j4, Key j5, Key j6)
Construct 6-way factor.
Definition SymbolicFactor.h:77
gtsam::SymbolicFactor::shared_ptr
boost::shared_ptr< This > shared_ptr
Overriding the shared_ptr typedef.
Definition SymbolicFactor.h:48
gtsam::SymbolicFactor::FromKeys
static SymbolicFactor FromKeys(const CONTAINER &keys)
Constructor from a collection of keys - compatible with boost assign::list_of and boost assign::cref_...
Definition SymbolicFactor.h:130
gtsam::SymbolicFactor::SymbolicFactor
SymbolicFactor(const Factor &factor)
Create symbolic version of any factor.
Definition SymbolicFactor.h:81
gtsam::SymbolicFactor::SymbolicFactor
SymbolicFactor(Key j1, Key j2, Key j3, Key j4)
Construct 4-way factor.
Definition SymbolicFactor.h:69
gtsam::SymbolicFactor::SymbolicFactor
SymbolicFactor(Key j1, Key j2)
Construct binary factor.
Definition SymbolicFactor.h:61
gtsam::SymbolicFactor::FromIterators
static SymbolicFactor FromIterators(KEYITERATOR beginKey, KEYITERATOR endKey)
Constructor from a collection of keys.
Definition SymbolicFactor.h:115
gtsam::SymbolicFactor::printKeys
void printKeys(const std::string &s="SymbolicFactor", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print only keys
Definition SymbolicFactor.h:103
gtsam::SymbolicFactor::FromKeysShared
static SymbolicFactor::shared_ptr FromKeysShared(const CONTAINER &keys)
Constructor from a collection of keys - compatible with boost assign::list_of and boost assign::cref_...
Definition SymbolicFactor.h:137
gtsam::SymbolicFactor::SymbolicFactor
SymbolicFactor(Key j1, Key j2, Key j3)
Construct ternary factor.
Definition SymbolicFactor.h:65
gtsam::SymbolicFactor::SymbolicFactor
SymbolicFactor(Key j)
Construct unary factor.
Definition SymbolicFactor.h:57
gtsam::SymbolicFactor::SymbolicFactor
SymbolicFactor(Key j1, Key j2, Key j3, Key j4, Key j5)
Construct 5-way factor.
Definition SymbolicFactor.h:73
gtsam::SymbolicFactor::FromIteratorsShared
static SymbolicFactor::shared_ptr FromIteratorsShared(KEYITERATOR beginKey, KEYITERATOR endKey)
Constructor from a collection of keys.
Definition SymbolicFactor.h:121
gtsam::SymbolicFactor::SymbolicFactor
SymbolicFactor()
Default constructor for I/O.
Definition SymbolicFactor.h:54
gtsam::SymbolicFactor::clone
SymbolicFactor::shared_ptr clone() const
Copy this object as its actual derived type.
Definition SymbolicFactor.h:86