Main MRPT website > C++ reference for MRPT 1.9.9
List of all members | Classes | Public Member Functions | Private Attributes
mrpt::graphs::ScalarFactorGraph Class Reference

Detailed Description

Sparse solver for GMRF (Gaussian Markov Random Fields) graphical models.

The design of this class is optimized for large problems (e.g. >1e3 nodes, >1e4 constrainst) by leaving to the user/caller the responsibility of allocating all "nodes" and constraints. This class can be seen as an intermediary solution between current methods in mrpt::graphslam and the well-known G2O library:

Assumptions/limitations:

Usage:

Note
[New in MRPT 1.5.0] Requires Eigen>=3.1

Definition at line 44 of file ScalarFactorGraph.h.

#include <mrpt/graphs/ScalarFactorGraph.h>

Inheritance diagram for mrpt::graphs::ScalarFactorGraph:
Inheritance graph

Classes

struct  BinaryFactorVirtualBase
 Simple, scalar (1-dim) constraint (edge) for a GMRF. More...
 
struct  FactorBase
 
struct  UnaryFactorVirtualBase
 Simple, scalar (1-dim) constraint (edge) for a GMRF. More...
 

Public Member Functions

 ScalarFactorGraph ()
 
void clear ()
 Reset state: remove all constraints and nodes. More...
 
void initialize (const size_t nodeCount)
 Initialize the GMRF internal state and copy the prior factors. More...
 
void addConstraint (const UnaryFactorVirtualBase &listOfConstraints)
 Insert constraints into the GMRF problem. More...
 
void addConstraint (const BinaryFactorVirtualBase &listOfConstraints)
 
bool eraseConstraint (const FactorBase &c)
 Removes a constraint. More...
 
void clearAllConstraintsByType_Unary ()
 
void clearAllConstraintsByType_Binary ()
 
void updateEstimation (Eigen::VectorXd &solved_x_inc, Eigen::VectorXd *solved_variances=nullptr)
 
bool isProfilerEnabled () const
 
void enableProfiler (bool enable=true)
 

Private Attributes

size_t m_numNodes
 number of nodes in the graph More...
 
std::deque< const UnaryFactorVirtualBase * > m_factors_unary
 
std::deque< const BinaryFactorVirtualBase * > m_factors_binary
 
mrpt::utils::CTimeLogger m_timelogger
 
bool m_enable_profiler
 

Constructor & Destructor Documentation

◆ ScalarFactorGraph()

ScalarFactorGraph::ScalarFactorGraph ( )

Definition at line 26 of file ScalarFactorGraph.cpp.

Member Function Documentation

◆ addConstraint() [1/2]

void ScalarFactorGraph::addConstraint ( const UnaryFactorVirtualBase listOfConstraints)

Insert constraints into the GMRF problem.

Parameters
listOfConstraintsList of user-implemented constraints. A pointer to the passed object is kept, but memory ownship REMAINS being responsability of the caller. This is done such that arrays/vectors of constraints can be more efficiently allocated if their type is known at build time.

Definition at line 47 of file ScalarFactorGraph.cpp.

References m_factors_unary.

Referenced by mrpt::maps::CRandomFieldGridMap3D::insertIndividualReading(), and mrpt::maps::CRandomFieldGridMap2D::insertObservation_GMRF().

Here is the caller graph for this function:

◆ addConstraint() [2/2]

void ScalarFactorGraph::addConstraint ( const BinaryFactorVirtualBase listOfConstraints)

Definition at line 51 of file ScalarFactorGraph.cpp.

References m_factors_binary.

◆ clear()

void ScalarFactorGraph::clear ( )

Reset state: remove all constraints and nodes.

Definition at line 31 of file ScalarFactorGraph.cpp.

References m_factors_binary, m_factors_unary, m_numNodes, and MRPT_LOG_DEBUG.

◆ clearAllConstraintsByType_Binary()

void mrpt::graphs::ScalarFactorGraph::clearAllConstraintsByType_Binary ( )
inline

Definition at line 96 of file ScalarFactorGraph.h.

References m_factors_binary.

◆ clearAllConstraintsByType_Unary()

void mrpt::graphs::ScalarFactorGraph::clearAllConstraintsByType_Unary ( )
inline

Definition at line 95 of file ScalarFactorGraph.h.

References m_factors_unary.

◆ enableProfiler()

void mrpt::graphs::ScalarFactorGraph::enableProfiler ( bool  enable = true)
inline

Definition at line 105 of file ScalarFactorGraph.h.

References m_enable_profiler.

Referenced by mrpt::maps::CRandomFieldGridMap2D::enableProfiler().

Here is the caller graph for this function:

◆ eraseConstraint()

bool ScalarFactorGraph::eraseConstraint ( const FactorBase c)

Removes a constraint.

Return true if found and deleted correctly.

Definition at line 56 of file ScalarFactorGraph.cpp.

References mrpt::utils::find(), m_factors_binary, and m_factors_unary.

Referenced by mrpt::maps::CRandomFieldGridMap2D::updateMapEstimation_GMRF().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialize()

void ScalarFactorGraph::initialize ( const size_t  nodeCount)

Initialize the GMRF internal state and copy the prior factors.

Parameters
nodeCountNumber of unknown nodes in the MRF graph

Definition at line 40 of file ScalarFactorGraph.cpp.

References m_numNodes, and MRPT_LOG_DEBUG_STREAM.

◆ isProfilerEnabled()

bool mrpt::graphs::ScalarFactorGraph::isProfilerEnabled ( ) const
inline

Definition at line 104 of file ScalarFactorGraph.h.

References m_enable_profiler.

Referenced by mrpt::maps::CRandomFieldGridMap2D::isProfilerEnabled().

Here is the caller graph for this function:

◆ updateEstimation()

void ScalarFactorGraph::updateEstimation ( Eigen::VectorXd &  solved_x_inc,
Eigen::VectorXd *  solved_variances = nullptr 
)
Parameters
solved_x_incOutput increment of the current estimate. Caller must add this vector to current state vector to obtain the optimal estimation.
solved_variancesIf !=nullptr, the variances of each estimate will be stored here.

Definition at line 85 of file ScalarFactorGraph.cpp.

References ASSERT_, ASSERTMSG_, mrpt::utils::CTimeLogger::enable(), mrpt::utils::CTimeLogger::enter(), mrpt::utils::CTimeLogger::leave(), m_enable_profiler, m_factors_binary, m_factors_unary, m_numNodes, m_timelogger, MRPT_LOG_DEBUG_FMT, MRPT_TODO, mrpt::math::sum(), and THROW_EXCEPTION.

Referenced by mrpt::maps::CRandomFieldGridMap3D::updateMapEstimation(), and mrpt::maps::CRandomFieldGridMap2D::updateMapEstimation_GMRF().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_enable_profiler

bool mrpt::graphs::ScalarFactorGraph::m_enable_profiler
private

Definition at line 114 of file ScalarFactorGraph.h.

Referenced by enableProfiler(), isProfilerEnabled(), and updateEstimation().

◆ m_factors_binary

std::deque<const BinaryFactorVirtualBase*> mrpt::graphs::ScalarFactorGraph::m_factors_binary
private

◆ m_factors_unary

std::deque<const UnaryFactorVirtualBase*> mrpt::graphs::ScalarFactorGraph::m_factors_unary
private

◆ m_numNodes

size_t mrpt::graphs::ScalarFactorGraph::m_numNodes
private

number of nodes in the graph

Definition at line 108 of file ScalarFactorGraph.h.

Referenced by clear(), initialize(), and updateEstimation().

◆ m_timelogger

mrpt::utils::CTimeLogger mrpt::graphs::ScalarFactorGraph::m_timelogger
private

Definition at line 113 of file ScalarFactorGraph.h.

Referenced by updateEstimation().




Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019