class mrpt::graphs::ScalarFactorGraph
Overview
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:
Linear error functions (for now).
Scalar (1-dim) error functions.
Gaussian factors.
Solver: Eigen SparseQR.
Usage:
Call initialize() to set the number of nodes.
Call addConstraints() to insert constraints. This may be called more than once.
Call updateEstimation() to run one step of the linear SparseQR solver.
#include <mrpt/graphs/ScalarFactorGraph.h> class ScalarFactorGraph: public mrpt::system::COutputLogger { public: // structs struct BinaryFactorVirtualBase; struct FactorBase; struct UnaryFactorVirtualBase; // construction ScalarFactorGraph(); // methods void clear(); void initialize(size_t nodeCount); void addConstraint(const UnaryFactorVirtualBase& listOfConstraints); void addConstraint(const BinaryFactorVirtualBase& listOfConstraints); bool eraseConstraint(const FactorBase& c); void clearAllConstraintsByType_Unary(); void clearAllConstraintsByType_Binary(); void updateEstimation( mrpt::math::CVectorDouble& solved_x_inc, mrpt::math::CVectorDouble* solved_variances = nullptr ); bool isProfilerEnabled() const; void enableProfiler(bool enable = true); };
Inherited Members
public: // structs struct TMsg; // fields bool logging_enable_console_output {true}; bool logging_enable_keep_record {false}; // methods void logStr(const VerbosityLevel level, std::string_view msg_str) const; void logFmt(const VerbosityLevel level, const char* fmt, ...) const; void void logCond(const VerbosityLevel level, bool cond, const std::string& msg_str) const; void setLoggerName(const std::string& name); std::string getLoggerName() const; void setVerbosityLevel(const VerbosityLevel level); void setVerbosityLevelForCallbacks(const VerbosityLevel level); void setMinLoggingLevel(const VerbosityLevel level); VerbosityLevel getMinLoggingLevel() const; VerbosityLevel getMinLoggingLevelForCallbacks() const; bool isLoggingLevelVisible(VerbosityLevel level) const; void getLogAsString(std::string& log_contents) const; std::string getLogAsString() const; void writeLogToFile(const std::optional<std::string>& fname_in = std::nullopt) const; void dumpLogToConsole() const; std::string getLoggerLastMsg() const; void getLoggerLastMsg(std::string& msg_str) const; void loggerReset(); void logRegisterCallback(output_logger_callback_t userFunc); bool logDeregisterCallback(output_logger_callback_t userFunc); COutputLogger& operator = (const COutputLogger&); COutputLogger& operator = (COutputLogger&&); static std::array<mrpt::system::ConsoleForegroundColor, NUMBER_OF_VERBOSITY_LEVELS>& logging_levels_to_colors(); static const std::array<const char*, NUMBER_OF_VERBOSITY_LEVELS>& logging_levels_to_names();
Methods
void clear()
Reset state: remove all constraints and nodes.
void initialize(size_t nodeCount)
Initialize the GMRF internal state and copy the prior factors.
void addConstraint(const UnaryFactorVirtualBase& listOfConstraints)
Insert constraints into the GMRF problem.
Parameters:
listOfConstraints |
List of user-implemented constraints. A pointer to the passed object is kept, but memory ownship REMAINS being responsibility 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. |
bool eraseConstraint(const FactorBase& c)
Removes a constraint.
Return true if found and deleted correctly.