27#ifndef G2O_BLOCK_SOLVER_H
28#define G2O_BLOCK_SOLVER_H
34#include "g2o/config.h"
47template <
int _PoseDim,
int _LandmarkDim>
51 typedef Eigen::Matrix<double, PoseDim, PoseDim, Eigen::ColMajor>
53 typedef Eigen::Matrix<double, LandmarkDim, LandmarkDim, Eigen::ColMajor>
55 typedef Eigen::Matrix<double, PoseDim, LandmarkDim, Eigen::ColMajor>
58 typedef Eigen::Matrix<double, LandmarkDim, 1, Eigen::ColMajor>
73 static const int PoseDim = Eigen::Dynamic;
102template <
typename Traits>
129 virtual bool updateStructure(
const std::vector<HyperGraph::Vertex*>& vset,
132 virtual bool solve();
135 const std::vector<std::pair<int, int>>& blockIndices);
136 virtual bool setLambda(
double lambda,
bool backup =
false);
147 virtual bool saveHessian(
const std::string& fileName)
const;
150 _Hpp->multiplySymmetricUpperTriangle(dest, src);
154 void resize(
int* blockPoseIndices,
int numPoseBlocks,
155 int* blockLandmarkIndices,
int numLandmarkBlocks,
int totalDim);
159 std::unique_ptr<SparseBlockMatrix<PoseMatrixType>>
_Hpp;
160 std::unique_ptr<SparseBlockMatrix<LandmarkMatrixType>>
_Hll;
161 std::unique_ptr<SparseBlockMatrix<PoseLandmarkMatrixType>>
_Hpl;
163 std::unique_ptr<SparseBlockMatrix<PoseMatrixType>>
_Hschur;
164 std::unique_ptr<SparseBlockMatrixDiagonal<LandmarkMatrixType>>
_DInvSchur;
166 std::unique_ptr<SparseBlockMatrixCCS<PoseLandmarkMatrixType>>
_HplCCS;
175 std::vector<OpenMPMutex> _coefficientsMutex;
181 std::unique_ptr<double[], aligned_deleter<double>>
_bschur;
187template <
int p,
int l>
base for the block solvers with some basic function interfaces
virtual void multiplyHessian(double *dest, const double *src) const =0
virtual ~BlockSolverBase()
Implementation of a solver operating on the blocks of the Hessian.
void resize(int *blockPoseIndices, int numPoseBlocks, int *blockLandmarkIndices, int numLandmarkBlocks, int totalDim)
std::unique_ptr< SparseBlockMatrix< PoseMatrixType > > _Hschur
virtual bool computeMarginals(SparseBlockMatrix< MatrixX > &spinv, const std::vector< std::pair< int, int > > &blockIndices)
Traits::PoseHessianType PoseHessianType
virtual bool buildStructure(bool zeroBlocks=false)
Traits::LandmarkVectorType LandmarkVectorType
virtual void setWriteDebug(bool writeDebug)
virtual void restoreDiagonal()
std::unique_ptr< SparseBlockMatrixCCS< PoseLandmarkMatrixType > > _HplCCS
std::unique_ptr< LinearSolverType > _linearSolver
virtual bool buildSystem()
static const int LandmarkDim
virtual bool schur()
should the solver perform the schur complement or not
Traits::LandmarkHessianType LandmarkHessianType
virtual bool saveHessian(const std::string &fileName) const
write the hessian to disk using the specified file name
Traits::PoseVectorType PoseVectorType
virtual bool supportsSchur()
virtual void setSchur(bool s)
virtual void multiplyHessian(double *dest, const double *src) const
Traits::LinearSolverType LinearSolverType
std::unique_ptr< SparseBlockMatrix< LandmarkMatrixType > > _Hll
std::unique_ptr< SparseBlockMatrix< PoseMatrixType > > _Hpp
virtual bool init(SparseOptimizer *optmizer, bool online=false)
Traits::PoseMatrixType PoseMatrixType
Traits::PoseLandmarkMatrixType PoseLandmarkMatrixType
LinearSolver< PoseMatrixType > & linearSolver() const
virtual bool writeDebug() const
std::unique_ptr< SparseBlockMatrixDiagonal< LandmarkMatrixType > > _DInvSchur
std::unique_ptr< SparseBlockMatrixCCS< PoseMatrixType > > _HschurTransposedCCS
std::unique_ptr< double[], aligned_deleter< double > > _bschur
std::vector< LandmarkVectorType > _diagonalBackupLandmark
virtual bool updateStructure(const std::vector< HyperGraph::Vertex * > &vset, const HyperGraph::EdgeSet &edges)
virtual bool setLambda(double lambda, bool backup=false)
std::vector< PoseVectorType > _diagonalBackupPose
std::unique_ptr< SparseBlockMatrix< PoseLandmarkMatrixType > > _Hpl
std::unique_ptr< double[], aligned_deleter< double > > _coefficients
Traits::PoseLandmarkHessianType PoseLandmarkHessianType
Traits::LandmarkMatrixType LandmarkMatrixType
std::set< Edge * > EdgeSet
Generic interface for a sparse solver operating on a graph which solves one iteration of the lineariz...
Sparse matrix which uses blocks.
BlockSolverPL< 7, 3 > BlockSolver_7_3
MatrixN< Eigen::Dynamic > MatrixX
BlockSolverPL< 6, 3 > BlockSolver_6_3
BlockSolverPL< Eigen::Dynamic, Eigen::Dynamic > BlockSolverX
VectorN< Eigen::Dynamic > VectorX
BlockSolverPL< 3, 2 > BlockSolver_3_2
BlockSolver< BlockSolverTraits< p, l > > BlockSolverPL
MatrixX LandmarkMatrixType
SparseBlockMatrix< PoseMatrixType > PoseHessianType
MatrixX PoseLandmarkMatrixType
SparseBlockMatrix< LandmarkMatrixType > LandmarkHessianType
VectorX LandmarkVectorType
SparseBlockMatrix< PoseLandmarkMatrixType > PoseLandmarkHessianType
LinearSolver< PoseMatrixType > LinearSolverType
traits to summarize the properties of the fixed size optimization problem
SparseBlockMatrix< PoseMatrixType > PoseHessianType
Eigen::Matrix< double, LandmarkDim, LandmarkDim, Eigen::ColMajor > LandmarkMatrixType
Eigen::Matrix< double, PoseDim, PoseDim, Eigen::ColMajor > PoseMatrixType
Eigen::Matrix< double, PoseDim, LandmarkDim, Eigen::ColMajor > PoseLandmarkMatrixType
static const int LandmarkDim
LinearSolver< PoseMatrixType > LinearSolverType
Eigen::Matrix< double, LandmarkDim, 1, Eigen::ColMajor > LandmarkVectorType
SparseBlockMatrix< LandmarkMatrixType > LandmarkHessianType
SparseBlockMatrix< PoseLandmarkMatrixType > PoseLandmarkHessianType
Eigen::Matrix< double, PoseDim, 1, Eigen::ColMajor > PoseVectorType