43 std::unique_ptr<BlockSolverBase>
solver)
64 int iteration,
bool online) {
67 "underlying linear solver operates on different graph");
73 bool ok =
_solver.buildStructure();
76 return OptimizationAlgorithm::Fail;
96 double currentChi =
_optimizer->activeRobustChi2();
108 double bNormSquared = b.squaredNorm();
109 double alpha = bNormSquared /
_auxVector.dot(b);
112 double hsdNorm =
_hsd.norm();
113 double hgnNorm = -1.;
115 bool solvedGaussNewton =
false;
116 bool goodStep =
false;
122 if (!solvedGaussNewton) {
123 const double minLambda =
cst(1e-12);
124 const double maxLambda =
cst(1e3);
125 solvedGaussNewton =
true;
129 bool solverOk =
false;
152 hgnNorm = VectorX::ConstMapType(
_solver.x(),
_solver.vectorSize()).norm();
156 assert(hgnNorm >= 0. &&
"Norm of the GN step is not computed");
161 }
else if (hsdNorm >
_delta) {
167 double bmaSquaredNorm =
_auxVector.squaredNorm();
170 beta = (-c + sqrt(c * c + bmaSquaredNorm *
174 double hsdSqrNorm =
_hsd.squaredNorm();
177 (c + sqrt(c * c + bmaSquaredNorm * (
_delta *
_delta - hsdSqrNorm)));
179 assert(beta > 0. && beta < 1 &&
"Error while computing beta");
183 "Computed step does not correspond to the trust region");
195 double newChi =
_optimizer->activeRobustChi2();
196 double nonLinearGain = currentChi - newChi;
197 if (fabs(linearGain) < 1e-12) linearGain =
cst(1e-12);
198 double rho = nonLinearGain / linearGain;
213 }
while (!goodStep && numTries < _maxTrialsAfterFailure->value());
base for the block solvers with some basic function interfaces
virtual void multiplyHessian(double *dest, const double *src) const =0
VectorX _hsd
steepest decent step
double _delta
trust region
Property< double > * _initialLambda
int _lastStep
type of the step taken by the algorithm
virtual void printVerbose(std::ostream &os) const
VectorX _hdl
final dogleg step
Property< int > * _maxTrialsAfterFailure
static const char * stepType2Str(int stepType)
convert the type into an integer
Property< double > * _lamdbaFactor
double _currentLambda
the damping factor to force positive definite matrix
std::unique_ptr< BlockSolverBase > m_solver
virtual ~OptimizationAlgorithmDogleg()
virtual SolverResult solve(int iteration, bool online=false)
OptimizationAlgorithmDogleg(std::unique_ptr< BlockSolverBase > solver)
Property< double > * _userDeltaInit
bool _wasPDInAllIterations
Solver & solver()
return the underlying solver used to solve the linear system
OptimizationAlgorithmWithHessian(Solver &solver)
SparseOptimizer * _optimizer
the optimizer the solver is working on
#define __PRETTY_FUNCTION__
constexpr double cst(long double v)
double get_monotonic_time()
statistics about the optimization
double timeResiduals
residuals
static G2OBatchStatistics * globalStats()
double timeQuadraticForm
construct the quadratic form in the graph
utility functions for handling time related stuff