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 44 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. 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 |
ScalarFactorGraph::ScalarFactorGraph | ( | ) |
Definition at line 26 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 47 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 51 of file ScalarFactorGraph.cpp.
References m_factors_binary.
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.
|
inline |
Definition at line 96 of file ScalarFactorGraph.h.
References m_factors_binary.
|
inline |
Definition at line 95 of file ScalarFactorGraph.h.
References m_factors_unary.
|
inline |
Definition at line 105 of file ScalarFactorGraph.h.
References m_enable_profiler.
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 56 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 40 of file ScalarFactorGraph.cpp.
References m_numNodes, and MRPT_LOG_DEBUG_STREAM.
|
inline |
Definition at line 104 of file ScalarFactorGraph.h.
References m_enable_profiler.
Referenced by mrpt::maps::CRandomFieldGridMap2D::isProfilerEnabled().
void ScalarFactorGraph::updateEstimation | ( | Eigen::VectorXd & | solved_x_inc, |
Eigen::VectorXd * | solved_variances = nullptr |
||
) |
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 !=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().
|
private |
Definition at line 114 of file ScalarFactorGraph.h.
Referenced by enableProfiler(), isProfilerEnabled(), and updateEstimation().
|
private |
Definition at line 111 of file ScalarFactorGraph.h.
Referenced by addConstraint(), clear(), clearAllConstraintsByType_Binary(), eraseConstraint(), and updateEstimation().
|
private |
Definition at line 110 of file ScalarFactorGraph.h.
Referenced by addConstraint(), clear(), clearAllConstraintsByType_Unary(), eraseConstraint(), and updateEstimation().
|
private |
number of nodes in the graph
Definition at line 108 of file ScalarFactorGraph.h.
Referenced by clear(), initialize(), and updateEstimation().
|
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 |