#include <BayesTree.h>
Public Types | |
typedef FastVector< sharedFactor >::const_iterator | const_iterator |
typedef FACTOR | FactorType |
factor type More... | |
typedef FastVector< sharedFactor >::iterator | iterator |
typedef boost::shared_ptr< FACTOR > | sharedFactor |
Shared pointer to a factor. More... | |
typedef sharedFactor | value_type |
Public Member Functions | |
virtual | ~FactorGraph ()=default |
Default destructor. More... | |
Protected Attributes | |
FastVector< sharedFactor > | factors_ |
Private Types | |
template<typename T > | |
using | HasDerivedElementType = typename std::enable_if< std::is_base_of< FactorType, typename T::value_type::element_type >::value >::type |
Check if T has a value_type derived from FactorType. More... | |
template<typename T > | |
using | HasDerivedValueType = typename std::enable_if< std::is_base_of< FactorType, typename T::value_type >::value >::type |
Check if T has a value_type derived from FactorType. More... | |
template<typename DERIVEDFACTOR > | |
using | IsDerived = typename std::enable_if< std::is_base_of< FactorType, DERIVEDFACTOR >::value >::type |
Check if a DERIVEDFACTOR is in fact derived from FactorType. More... | |
typedef boost::shared_ptr< This > | shared_ptr |
Shared pointer for this class. More... | |
typedef FactorGraph< FACTOR > | This |
Typedef for this class. More... | |
Standard Constructors | |
FactorGraph () | |
template<typename ITERATOR > | |
FactorGraph (ITERATOR firstFactor, ITERATOR lastFactor) | |
template<class CONTAINER > | |
FactorGraph (const CONTAINER &factors) | |
Adding Single Factors | |
void | reserve (size_t size) |
template<class DERIVEDFACTOR > | |
IsDerived< DERIVEDFACTOR > | push_back (boost::shared_ptr< DERIVEDFACTOR > factor) |
Add a factor directly using a shared_ptr. More... | |
template<class DERIVEDFACTOR , class... Args> | |
IsDerived< DERIVEDFACTOR > | emplace_shared (Args &&...args) |
Emplace a shared pointer to factor of given type. More... | |
template<class DERIVEDFACTOR > | |
IsDerived< DERIVEDFACTOR > | push_back (const DERIVEDFACTOR &factor) |
template<class DERIVEDFACTOR > | |
IsDerived< DERIVEDFACTOR > | add (boost::shared_ptr< DERIVEDFACTOR > factor) |
add is a synonym for push_back. More... | |
template<class DERIVEDFACTOR > | |
std::enable_if< std::is_base_of< FactorType, DERIVEDFACTOR >::value, boost::assign::list_inserter< RefCallPushBack< This > > >::type | operator+= (boost::shared_ptr< DERIVEDFACTOR > factor) |
+= works well with boost::assign list inserter. More... | |
Adding via iterators | |
template<typename ITERATOR > | |
HasDerivedElementType< ITERATOR > | push_back (ITERATOR firstFactor, ITERATOR lastFactor) |
template<typename ITERATOR > | |
HasDerivedValueType< ITERATOR > | push_back (ITERATOR firstFactor, ITERATOR lastFactor) |
Push back many factors with an iterator (factors are copied) More... | |
Adding via container | |
template<typename CONTAINER > | |
HasDerivedElementType< CONTAINER > | push_back (const CONTAINER &container) |
template<typename CONTAINER > | |
HasDerivedValueType< CONTAINER > | push_back (const CONTAINER &container) |
Push back non-pointer objects in a container (factors are copied). More... | |
template<class FACTOR_OR_CONTAINER > | |
void | add (const FACTOR_OR_CONTAINER &factorOrContainer) |
template<class FACTOR_OR_CONTAINER > | |
boost::assign::list_inserter< CRefCallPushBack< This > > | operator+= (const FACTOR_OR_CONTAINER &factorOrContainer) |
Specialized versions | |
template<class CLIQUE > | |
std::enable_if< std::is_base_of< This, typename CLIQUE::FactorGraphType >::value >::type | push_back (const BayesTree< CLIQUE > &bayesTree) |
template<typename CONTAINER , typename = HasDerivedElementType<CONTAINER>> | |
FactorIndices | add_factors (const CONTAINER &factors, bool useEmptySlots=false) |
Testable | |
virtual void | print (const std::string &s="FactorGraph", const KeyFormatter &formatter=DefaultKeyFormatter) const |
print out graph More... | |
bool | equals (const This &fg, double tol=1e-9) const |
Standard Interface | |
size_t | size () const |
bool | empty () const |
const sharedFactor | at (size_t i) const |
sharedFactor & | at (size_t i) |
const sharedFactor | operator[] (size_t i) const |
sharedFactor & | operator[] (size_t i) |
const_iterator | begin () const |
const_iterator | end () const |
sharedFactor | front () const |
sharedFactor | back () const |
Modifying Factor Graphs (imperative, discouraged) | |
iterator | begin () |
iterator | end () |
void | resize (size_t size) |
void | remove (size_t i) |
void | replace (size_t index, sharedFactor factor) |
iterator | erase (iterator item) |
iterator | erase (iterator first, iterator last) |
Advanced Interface | |
class | boost::serialization::access |
size_t | nrFactors () const |
KeySet | keys () const |
KeyVector | keyVector () const |
bool | exists (size_t idx) const |
template<class ARCHIVE > | |
void | serialize (ARCHIVE &ar, const unsigned int) |
A factor graph is a bipartite graph with factor nodes connected to variable nodes. In this class, however, only factor nodes are kept around.
Definition at line 32 of file BayesTree.h.
typedef FastVector<sharedFactor>::const_iterator gtsam::FactorGraph< FACTOR >::const_iterator |
Definition at line 101 of file FactorGraph.h.
typedef FACTOR gtsam::FactorGraph< FACTOR >::FactorType |
factor type
Definition at line 96 of file FactorGraph.h.
|
private |
Check if T has a value_type derived from FactorType.
Definition at line 121 of file FactorGraph.h.
|
private |
Check if T has a value_type derived from FactorType.
Definition at line 116 of file FactorGraph.h.
|
private |
Check if a DERIVEDFACTOR is in fact derived from FactorType.
Definition at line 111 of file FactorGraph.h.
typedef FastVector<sharedFactor>::iterator gtsam::FactorGraph< FACTOR >::iterator |
Definition at line 100 of file FactorGraph.h.
|
private |
Shared pointer for this class.
Definition at line 106 of file FactorGraph.h.
typedef boost::shared_ptr<FACTOR> gtsam::FactorGraph< FACTOR >::sharedFactor |
Shared pointer to a factor.
Definition at line 98 of file FactorGraph.h.
|
private |
Typedef for this class.
Definition at line 104 of file FactorGraph.h.
typedef sharedFactor gtsam::FactorGraph< FACTOR >::value_type |
Definition at line 99 of file FactorGraph.h.
|
inlineprotected |
Default constructor
Definition at line 134 of file FactorGraph.h.
|
inlineprotected |
Constructor from iterator over factors (shared_ptr or plain objects)
Definition at line 138 of file FactorGraph.h.
|
inlineexplicitprotected |
Construct from container of factors (shared_ptr or plain objects)
Definition at line 144 of file FactorGraph.h.
|
virtualdefault |
Default destructor.
|
inline |
add
is a synonym for push_back.
Definition at line 190 of file FactorGraph.h.
|
inline |
Add a factor or container of factors, including STL collections, BayesTrees, etc.
Definition at line 249 of file FactorGraph.h.
FactorIndices gtsam::FactorGraph< FACTOR >::add_factors | ( | const CONTAINER & | factors, |
bool | useEmptySlots = false |
||
) |
Add new factors to a factor graph and returns a list of new factor indices, optionally finding and reusing empty factor slots.
Definition at line 100 of file FactorGraph-inst.h.
|
inline |
Get a specific factor by index (this checks array bounds and may throw an exception, as opposed to operator[] which does not).
Definition at line 315 of file FactorGraph.h.
|
inline |
Get a specific factor by index (this checks array bounds and may throw an exception, as opposed to operator[] which does not).
Definition at line 320 of file FactorGraph.h.
|
inline |
Get the last factor
Definition at line 342 of file FactorGraph.h.
|
inline |
Iterator to beginning of factors.
Definition at line 333 of file FactorGraph.h.
|
inline |
non-const STL-style begin()
Definition at line 349 of file FactorGraph.h.
|
inline |
Emplace a shared pointer to factor of given type.
Definition at line 172 of file FactorGraph.h.
|
inline |
Check if the graph is empty (null factors set by remove() will cause this to return false).
Definition at line 310 of file FactorGraph.h.
|
inline |
Iterator to end of factors.
Definition at line 336 of file FactorGraph.h.
|
inline |
non-const STL-style end()
Definition at line 352 of file FactorGraph.h.
bool gtsam::FactorGraph< FACTOR >::equals | ( | const This & | fg, |
double | tol = 1e-9 |
||
) | const |
Check equality
Definition at line 51 of file FactorGraph-inst.h.
|
inline |
Erase factor and rearrange other factors to take up the empty space
Definition at line 368 of file FactorGraph.h.
|
inline |
Erase factors and rearrange other factors to take up the empty space
Definition at line 371 of file FactorGraph.h.
|
inline |
MATLAB interface utility: Checks whether a factor index idx exists in the graph and is a live pointer
Definition at line 393 of file FactorGraph.h.
|
inline |
Get the first factor
Definition at line 339 of file FactorGraph.h.
KeySet gtsam::FactorGraph< FACTOR >::keys | ( | ) | const |
Potentially slow function to return all keys involved, sorted, as a set
Definition at line 76 of file FactorGraph-inst.h.
KeyVector gtsam::FactorGraph< FACTOR >::keyVector | ( | ) | const |
Potentially slow function to return all keys involved, sorted, as a vector
Definition at line 86 of file FactorGraph-inst.h.
size_t gtsam::FactorGraph< FACTOR >::nrFactors | ( | ) | const |
return the number of non-null factors
Definition at line 67 of file FactorGraph-inst.h.
|
inline |
+=
works well with boost::assign list inserter.
Definition at line 199 of file FactorGraph.h.
|
inline |
Add a factor or container of factors, including STL collections, BayesTrees, etc.
Definition at line 258 of file FactorGraph.h.
|
inline |
Get a specific factor by index (this does not check array bounds, as opposed to at() which does).
Definition at line 325 of file FactorGraph.h.
|
inline |
Get a specific factor by index (this does not check array bounds, as opposed to at() which does).
Definition at line 330 of file FactorGraph.h.
|
virtual |
print out graph
Reimplemented in gtsam::GaussianBayesNet, gtsam::Scheduler, gtsam::DiscreteFactorGraph, gtsam::NonlinearFactorGraph, gtsam::SymbolicFactorGraph, gtsam::SymbolicBayesNet, gtsam::BayesNet< CONDITIONAL >, gtsam::BayesNet< DiscreteConditional >, and gtsam::InequalityFactorGraph.
Definition at line 38 of file FactorGraph-inst.h.
|
inline |
Add a factor directly using a shared_ptr.
Definition at line 166 of file FactorGraph.h.
|
inline |
Add a factor by value, will be copy-constructed (use push_back with a shared_ptr to avoid the copy).
Definition at line 183 of file FactorGraph.h.
|
inline |
Push back many factors with an iterator over shared_ptr (factors are not copied)
Definition at line 213 of file FactorGraph.h.
|
inline |
Push back many factors with an iterator (factors are copied)
Definition at line 220 of file FactorGraph.h.
|
inline |
Push back many factors as shared_ptr's in a container (factors are not copied)
Definition at line 234 of file FactorGraph.h.
|
inline |
Push back non-pointer objects in a container (factors are copied).
Definition at line 240 of file FactorGraph.h.
|
inline |
Push back a BayesTree as a collection of factors. NOTE: This should be hidden in derived classes in favor of a type-specialized version that calls this templated function.
Definition at line 276 of file FactorGraph.h.
|
inline |
delete factor without re-arranging indexes by inserting a nullptr pointer
Definition at line 362 of file FactorGraph.h.
|
inline |
replace a factor by index
Definition at line 365 of file FactorGraph.h.
|
inline |
Reserve space for the specified number of factors if you know in advance how many there will be (works like FastVector::reserve).
Definition at line 162 of file FactorGraph.h.
|
inline |
Directly resize the number of factors in the graph. If the new size is less than the original, factors at the end will be removed. If the new size is larger than the original, null factors will be appended.
Definition at line 358 of file FactorGraph.h.
|
inlineprivate |
Definition at line 399 of file FactorGraph.h.
|
inline |
return the number of factors (including any null factors set by remove() ).
Definition at line 306 of file FactorGraph.h.
|
friend |
Serialization function
Definition at line 397 of file FactorGraph.h.
|
protected |
concept check, makes sure FACTOR defines print and equals Collection of factors
Definition at line 128 of file FactorGraph.h.