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:
Definition at line 42 of file ScalarFactorGraph.h.
#include <mrpt/graphs/ScalarFactorGraph.h>
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. 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 |
ScalarFactorGraph::ScalarFactorGraph | ( | ) |
Definition at line 30 of file ScalarFactorGraph.cpp.
void ScalarFactorGraph::addConstraint | ( | const UnaryFactorVirtualBase & | listOfConstraints | ) |
Insert constraints into the GMRF problem.
listOfConstraints | List 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().
void ScalarFactorGraph::addConstraint | ( | const BinaryFactorVirtualBase & | listOfConstraints | ) |
Definition at line 56 of file ScalarFactorGraph.cpp.
References m_factors_binary.
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.
|
inline |
Definition at line 87 of file ScalarFactorGraph.h.
|
inline |
Definition at line 86 of file ScalarFactorGraph.h.
|
inline |
Definition at line 95 of file ScalarFactorGraph.h.
Referenced by mrpt::maps::CRandomFieldGridMap2D::enableProfiler().
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().
void ScalarFactorGraph::initialize | ( | const size_t | nodeCount | ) |
Initialize the GMRF internal state and copy the prior factors.
nodeCount | Number of unknown nodes in the MRF graph |
Definition at line 45 of file ScalarFactorGraph.cpp.
References m_numNodes, and MRPT_LOG_DEBUG_STREAM.
|
inline |
Definition at line 94 of file ScalarFactorGraph.h.
Referenced by mrpt::maps::CRandomFieldGridMap2D::isProfilerEnabled().
void ScalarFactorGraph::updateEstimation | ( | Eigen::VectorXd & | solved_x_inc, |
Eigen::VectorXd * | solved_variances = NULL |
||
) |
solved_x_inc | Output increment of the current estimate. Caller must add this vector to current state vector to obtain the optimal estimation. |
solved_variances | If !=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().
|
private |
Definition at line 104 of file ScalarFactorGraph.h.
Referenced by updateEstimation().
|
private |
Definition at line 101 of file ScalarFactorGraph.h.
Referenced by addConstraint(), clear(), eraseConstraint(), and updateEstimation().
|
private |
Definition at line 100 of file ScalarFactorGraph.h.
Referenced by addConstraint(), clear(), eraseConstraint(), and updateEstimation().
|
private |
number of nodes in the graph
Definition at line 98 of file ScalarFactorGraph.h.
Referenced by clear(), initialize(), and updateEstimation().
|
private |
Definition at line 103 of file ScalarFactorGraph.h.
Referenced by updateEstimation().
Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019 |