34 #include "../stuff/timeutil.h" 43 OptimizationAlgorithmLevenberg::OptimizationAlgorithmLevenberg(
Solver* solver) :
66 if (iteration == 0 && !online) {
83 double tempChi=currentChi;
85 double iniChi = currentChi;
127 tempChi=std::numeric_limits<double>::max();
129 rho = (currentChi-tempChi);
135 double alpha = 1.-pow((2*rho-1),3);
155 if((iniChi-currentChi)*1e3<iniChi)
170 double maxDiagonal=0.;
175 for (
int j = 0; j < dim; ++j){
176 maxDiagonal = std::max(fabs(v->
hessian(j,j)),maxDiagonal);
179 return _tau*maxDiagonal;
double computeLambdaInit() const
virtual void restoreDiagonal()=0
virtual bool schur()=0
should the solver perform the schur complement or not
statistics about the optimization
Property< double > * _userLambdaInit
bool terminate()
if external stop flag is given, return its state. False otherwise
#define __PRETTY_FUNCTION__
double computeScale() const
double _goodStepLowerScale
lower bound for lambda decrease if a good LM step
virtual const double & hessian(int i, int j) const =0
get the element from the hessian matrix
double _goodStepUpperScale
upper bound for lambda decrease if a good LM step
double timeResiduals
residuals
int _levenbergIterations
the numer of levenberg iterations performed to accept the last step
virtual void printVerbose(std::ostream &os) const
void pop(SparseOptimizer::VertexContainer &vlist)
pop (restore) the estimate a subset of the variables from the stack
virtual bool setLambda(double lambda, bool backup=false)=0
int levenbergIterations
number of iterations performed by LM
void computeActiveErrors()
void discardTop(SparseOptimizer::VertexContainer &vlist)
ignore the latest stored element on the stack, remove it from the stack but do not restore the estima...
Base for solvers operating on the approximated Hessian, e.g., Gauss-Newton, Levenberg.
virtual ~OptimizationAlgorithmLevenberg()
PropertyMap _properties
the properties of your solver, use this to store the parameters of your solver
int dimension() const
dimension of the estimated state belonging to this node
P * makeProperty(const std::string &name_, const typename P::ValueType &v)
void setValue(const T &v)
Generic interface for a sparse solver operating on a graph which solves one iteration of the lineariz...
SparseOptimizer * _optimizer
the optimizer the solver is working on
static G2OBatchStatistics * globalStats()
const VertexContainer & indexMapping() const
the index mapping of the vertices
double get_monotonic_time()
SparseOptimizer * optimizer() const
the optimizer (graph) on which the solver works
A general case Vertex for optimization.
Property< int > * _maxTrialsAfterFailure
double * x()
return x, the solution vector
void setUserLambdaInit(double lambda)
specify the initial lambda used for the first iteraion, if not given the SparseOptimizer tries to com...
double timeUpdate
time to apply the update
double * b()
return b, the right hand side of the system
virtual bool buildSystem()=0
size_t vectorSize() const
return the size of the solution vector (x) and b
double activeRobustChi2() const
double timeQuadraticForm
construct the quadratic form in the graph
void setMaxTrialsAfterFailure(int max_trials)
the number of internal iteration if an update step increases chi^2 within Levenberg-Marquardt ...
void push(SparseOptimizer::VertexContainer &vlist)
push the estimate of a subset of the variables onto a stack
double timeLinearSolution
total time for solving Ax=b (including detup for schur)
virtual SolverResult solve(int iteration, bool online=false)
virtual bool buildStructure(bool zeroBlocks=false)=0