Public Types | Public Member Functions | Protected Attributes | Private Types | List of all members
gtsam::FactorGraph< FACTOR > Class Template Reference

#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< sharedFactorfactors_
 

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< Thisshared_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
 
sharedFactorat (size_t i)
 
const sharedFactor operator[] (size_t i) const
 
sharedFactoroperator[] (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)
 

Detailed Description

template<class FACTOR>
class gtsam::FactorGraph< FACTOR >

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.

Member Typedef Documentation

template<class FACTOR>
typedef FastVector<sharedFactor>::const_iterator gtsam::FactorGraph< FACTOR >::const_iterator

Definition at line 101 of file FactorGraph.h.

template<class FACTOR>
typedef FACTOR gtsam::FactorGraph< FACTOR >::FactorType

factor type

Definition at line 96 of file FactorGraph.h.

template<class FACTOR>
template<typename T >
using gtsam::FactorGraph< FACTOR >::HasDerivedElementType = typename std::enable_if<std::is_base_of< FactorType, typename T::value_type::element_type>::value>::type
private

Check if T has a value_type derived from FactorType.

Definition at line 121 of file FactorGraph.h.

template<class FACTOR>
template<typename T >
using gtsam::FactorGraph< FACTOR >::HasDerivedValueType = typename std::enable_if< std::is_base_of<FactorType, typename T::value_type>::value>::type
private

Check if T has a value_type derived from FactorType.

Definition at line 116 of file FactorGraph.h.

template<class FACTOR>
template<typename DERIVEDFACTOR >
using gtsam::FactorGraph< FACTOR >::IsDerived = typename std::enable_if< std::is_base_of<FactorType, DERIVEDFACTOR>::value>::type
private

Check if a DERIVEDFACTOR is in fact derived from FactorType.

Definition at line 111 of file FactorGraph.h.

template<class FACTOR>
typedef FastVector<sharedFactor>::iterator gtsam::FactorGraph< FACTOR >::iterator

Definition at line 100 of file FactorGraph.h.

template<class FACTOR>
typedef boost::shared_ptr<This> gtsam::FactorGraph< FACTOR >::shared_ptr
private

Shared pointer for this class.

Definition at line 106 of file FactorGraph.h.

template<class FACTOR>
typedef boost::shared_ptr<FACTOR> gtsam::FactorGraph< FACTOR >::sharedFactor

Shared pointer to a factor.

Definition at line 98 of file FactorGraph.h.

template<class FACTOR>
typedef FactorGraph<FACTOR> gtsam::FactorGraph< FACTOR >::This
private

Typedef for this class.

Definition at line 104 of file FactorGraph.h.

template<class FACTOR>
typedef sharedFactor gtsam::FactorGraph< FACTOR >::value_type

Definition at line 99 of file FactorGraph.h.

Constructor & Destructor Documentation

template<class FACTOR>
gtsam::FactorGraph< FACTOR >::FactorGraph ( )
inlineprotected

Default constructor

Definition at line 134 of file FactorGraph.h.

template<class FACTOR>
template<typename ITERATOR >
gtsam::FactorGraph< FACTOR >::FactorGraph ( ITERATOR  firstFactor,
ITERATOR  lastFactor 
)
inlineprotected

Constructor from iterator over factors (shared_ptr or plain objects)

Definition at line 138 of file FactorGraph.h.

template<class FACTOR>
template<class CONTAINER >
gtsam::FactorGraph< FACTOR >::FactorGraph ( const CONTAINER &  factors)
inlineexplicitprotected

Construct from container of factors (shared_ptr or plain objects)

Definition at line 144 of file FactorGraph.h.

template<class FACTOR>
virtual gtsam::FactorGraph< FACTOR >::~FactorGraph ( )
virtualdefault

Default destructor.

Member Function Documentation

template<class FACTOR>
template<class DERIVEDFACTOR >
IsDerived<DERIVEDFACTOR> gtsam::FactorGraph< FACTOR >::add ( boost::shared_ptr< DERIVEDFACTOR >  factor)
inline

add is a synonym for push_back.

Definition at line 190 of file FactorGraph.h.

template<class FACTOR>
template<class FACTOR_OR_CONTAINER >
void gtsam::FactorGraph< FACTOR >::add ( const FACTOR_OR_CONTAINER &  factorOrContainer)
inline

Add a factor or container of factors, including STL collections, BayesTrees, etc.

Definition at line 249 of file FactorGraph.h.

template<class FACTOR >
template<typename CONTAINER , typename >
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.

template<class FACTOR>
const sharedFactor gtsam::FactorGraph< FACTOR >::at ( size_t  i) const
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.

template<class FACTOR>
sharedFactor& gtsam::FactorGraph< FACTOR >::at ( size_t  i)
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.

template<class FACTOR>
sharedFactor gtsam::FactorGraph< FACTOR >::back ( ) const
inline

Get the last factor

Definition at line 342 of file FactorGraph.h.

template<class FACTOR>
const_iterator gtsam::FactorGraph< FACTOR >::begin ( ) const
inline

Iterator to beginning of factors.

Definition at line 333 of file FactorGraph.h.

template<class FACTOR>
iterator gtsam::FactorGraph< FACTOR >::begin ( )
inline

non-const STL-style begin()

Definition at line 349 of file FactorGraph.h.

template<class FACTOR>
template<class DERIVEDFACTOR , class... Args>
IsDerived<DERIVEDFACTOR> gtsam::FactorGraph< FACTOR >::emplace_shared ( Args &&...  args)
inline

Emplace a shared pointer to factor of given type.

Definition at line 172 of file FactorGraph.h.

template<class FACTOR>
bool gtsam::FactorGraph< FACTOR >::empty ( ) const
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.

template<class FACTOR>
const_iterator gtsam::FactorGraph< FACTOR >::end ( ) const
inline

Iterator to end of factors.

Definition at line 336 of file FactorGraph.h.

template<class FACTOR>
iterator gtsam::FactorGraph< FACTOR >::end ( )
inline

non-const STL-style end()

Definition at line 352 of file FactorGraph.h.

template<class FACTOR >
bool gtsam::FactorGraph< FACTOR >::equals ( const This fg,
double  tol = 1e-9 
) const

Check equality

Definition at line 51 of file FactorGraph-inst.h.

template<class FACTOR>
iterator gtsam::FactorGraph< FACTOR >::erase ( iterator  item)
inline

Erase factor and rearrange other factors to take up the empty space

Definition at line 368 of file FactorGraph.h.

template<class FACTOR>
iterator gtsam::FactorGraph< FACTOR >::erase ( iterator  first,
iterator  last 
)
inline

Erase factors and rearrange other factors to take up the empty space

Definition at line 371 of file FactorGraph.h.

template<class FACTOR>
bool gtsam::FactorGraph< FACTOR >::exists ( size_t  idx) const
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.

template<class FACTOR>
sharedFactor gtsam::FactorGraph< FACTOR >::front ( ) const
inline

Get the first factor

Definition at line 339 of file FactorGraph.h.

template<class FACTOR >
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.

template<class FACTOR >
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.

template<class FACTOR >
size_t gtsam::FactorGraph< FACTOR >::nrFactors ( ) const

return the number of non-null factors

Definition at line 67 of file FactorGraph-inst.h.

template<class FACTOR>
template<class DERIVEDFACTOR >
std::enable_if< std::is_base_of<FactorType, DERIVEDFACTOR>::value, boost::assign::list_inserter<RefCallPushBack<This> > >::type gtsam::FactorGraph< FACTOR >::operator+= ( boost::shared_ptr< DERIVEDFACTOR >  factor)
inline

+= works well with boost::assign list inserter.

Definition at line 199 of file FactorGraph.h.

template<class FACTOR>
template<class FACTOR_OR_CONTAINER >
boost::assign::list_inserter<CRefCallPushBack<This> > gtsam::FactorGraph< FACTOR >::operator+= ( const FACTOR_OR_CONTAINER &  factorOrContainer)
inline

Add a factor or container of factors, including STL collections, BayesTrees, etc.

Definition at line 258 of file FactorGraph.h.

template<class FACTOR>
const sharedFactor gtsam::FactorGraph< FACTOR >::operator[] ( size_t  i) const
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.

template<class FACTOR>
sharedFactor& gtsam::FactorGraph< FACTOR >::operator[] ( size_t  i)
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.

template<class FACTOR >
void gtsam::FactorGraph< FACTOR >::print ( const std::string &  s = "FactorGraph< FACTOR >",
const KeyFormatter formatter = DefaultKeyFormatter 
) const
virtual
template<class FACTOR>
template<class DERIVEDFACTOR >
IsDerived<DERIVEDFACTOR> gtsam::FactorGraph< FACTOR >::push_back ( boost::shared_ptr< DERIVEDFACTOR >  factor)
inline

Add a factor directly using a shared_ptr.

Definition at line 166 of file FactorGraph.h.

template<class FACTOR>
template<class DERIVEDFACTOR >
IsDerived<DERIVEDFACTOR> gtsam::FactorGraph< FACTOR >::push_back ( const DERIVEDFACTOR &  factor)
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.

template<class FACTOR>
template<typename ITERATOR >
HasDerivedElementType<ITERATOR> gtsam::FactorGraph< FACTOR >::push_back ( ITERATOR  firstFactor,
ITERATOR  lastFactor 
)
inline

Push back many factors with an iterator over shared_ptr (factors are not copied)

Definition at line 213 of file FactorGraph.h.

template<class FACTOR>
template<typename ITERATOR >
HasDerivedValueType<ITERATOR> gtsam::FactorGraph< FACTOR >::push_back ( ITERATOR  firstFactor,
ITERATOR  lastFactor 
)
inline

Push back many factors with an iterator (factors are copied)

Definition at line 220 of file FactorGraph.h.

template<class FACTOR>
template<typename CONTAINER >
HasDerivedElementType<CONTAINER> gtsam::FactorGraph< FACTOR >::push_back ( const CONTAINER &  container)
inline

Push back many factors as shared_ptr's in a container (factors are not copied)

Definition at line 234 of file FactorGraph.h.

template<class FACTOR>
template<typename CONTAINER >
HasDerivedValueType<CONTAINER> gtsam::FactorGraph< FACTOR >::push_back ( const CONTAINER &  container)
inline

Push back non-pointer objects in a container (factors are copied).

Definition at line 240 of file FactorGraph.h.

template<class FACTOR>
template<class CLIQUE >
std::enable_if< std::is_base_of<This, typename CLIQUE::FactorGraphType>::value>::type gtsam::FactorGraph< FACTOR >::push_back ( const BayesTree< CLIQUE > &  bayesTree)
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.

template<class FACTOR>
void gtsam::FactorGraph< FACTOR >::remove ( size_t  i)
inline

delete factor without re-arranging indexes by inserting a nullptr pointer

Definition at line 362 of file FactorGraph.h.

template<class FACTOR>
void gtsam::FactorGraph< FACTOR >::replace ( size_t  index,
sharedFactor  factor 
)
inline

replace a factor by index

Definition at line 365 of file FactorGraph.h.

template<class FACTOR>
void gtsam::FactorGraph< FACTOR >::reserve ( size_t  size)
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.

template<class FACTOR>
void gtsam::FactorGraph< FACTOR >::resize ( size_t  size)
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.

template<class FACTOR>
template<class ARCHIVE >
void gtsam::FactorGraph< FACTOR >::serialize ( ARCHIVE &  ar,
const unsigned  int 
)
inlineprivate

Definition at line 399 of file FactorGraph.h.

template<class FACTOR>
size_t gtsam::FactorGraph< FACTOR >::size ( ) const
inline

return the number of factors (including any null factors set by remove() ).

Definition at line 306 of file FactorGraph.h.

Friends And Related Function Documentation

template<class FACTOR>
friend class boost::serialization::access
friend

Serialization function

Definition at line 397 of file FactorGraph.h.

Member Data Documentation

template<class FACTOR>
FastVector<sharedFactor> gtsam::FactorGraph< FACTOR >::factors_
protected

concept check, makes sure FACTOR defines print and equals Collection of factors

Definition at line 128 of file FactorGraph.h.


The documentation for this class was generated from the following files:


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:58:09