Main MRPT website > C++ reference for MRPT 1.5.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:



[New in MRPT 1.5.0] Requires Eigen>=3.1

Definition at line 42 of file ScalarFactorGraph.h.

#include <mrpt/graphs/ScalarFactorGraph.h>

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


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. Return true if found and deleted correctly. More...
void clearAllConstraintsByType_Unary ()
void clearAllConstraintsByType_Binary ()
void updateEstimation (Eigen::VectorXd &solved_x_inc, Eigen::VectorXd *solved_variances=NULL)
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 30 of file ScalarFactorGraph.cpp.

Member Function Documentation

◆ addConstraint() [1/2]

void ScalarFactorGraph::addConstraint ( const UnaryFactorVirtualBase listOfConstraints)

Insert constraints into the GMRF problem.

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 52 of file ScalarFactorGraph.cpp.

References m_factors_unary.

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

◆ addConstraint() [2/2]

void ScalarFactorGraph::addConstraint ( const BinaryFactorVirtualBase listOfConstraints)

Definition at line 56 of file ScalarFactorGraph.cpp.

References m_factors_binary.

◆ clear()

void ScalarFactorGraph::clear ( )

Reset state: remove all constraints and nodes.

Definition at line 36 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 ( )

Definition at line 87 of file ScalarFactorGraph.h.

◆ clearAllConstraintsByType_Unary()

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

Definition at line 86 of file ScalarFactorGraph.h.

◆ enableProfiler()

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

◆ eraseConstraint()

bool ScalarFactorGraph::eraseConstraint ( const FactorBase c)

Removes a constraint. Return true if found and deleted correctly.

Definition at line 61 of file ScalarFactorGraph.cpp.

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

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

◆ initialize()

void ScalarFactorGraph::initialize ( const size_t  nodeCount)

Initialize the GMRF internal state and copy the prior factors.

nodeCountNumber of unknown nodes in the MRF graph

Definition at line 45 of file ScalarFactorGraph.cpp.

References m_numNodes, and MRPT_LOG_DEBUG_STREAM.

◆ isProfilerEnabled()

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

◆ updateEstimation()

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

Definition at line 90 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().

Member Data Documentation

◆ m_enable_profiler

bool mrpt::graphs::ScalarFactorGraph::m_enable_profiler

Definition at line 104 of file ScalarFactorGraph.h.

Referenced by updateEstimation().

◆ m_factors_binary

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

Definition at line 101 of file ScalarFactorGraph.h.

Referenced by addConstraint(), clear(), eraseConstraint(), and updateEstimation().

◆ m_factors_unary

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

Definition at line 100 of file ScalarFactorGraph.h.

Referenced by addConstraint(), clear(), eraseConstraint(), and updateEstimation().

◆ m_numNodes

size_t mrpt::graphs::ScalarFactorGraph::m_numNodes

number of nodes in the graph

Definition at line 98 of file ScalarFactorGraph.h.

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

◆ m_timelogger

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

Definition at line 103 of file ScalarFactorGraph.h.

Referenced by updateEstimation().

Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020