# Levenberg optimizer halts quickly when given more variables, or fewer constraints

I'm using the g2o C++ optimization library to refine a GPS trajectory using accelerometer data.

The program uses a Levenberg-Marquardt optimizer over data points representing the position and orientation (vector part of quaternion) of the accelerometer. The only constraints are the accelerations in the local reference frame.

Error is measured as the difference between the accelerometer reading, and the local second derivative of the path traced by the data points — the change in velocity from (a to b) to (b to c), disregarding change in orientation, plus the upward acceleration counteracting gravity.

The initial path is a polygon drawn between GPS readings.

The optimizer runs for five iterations of gradient descent, and seems to make good adjustments. The polygon corners get rounded off a bit. But then it seems to get stuck, and Levenberg's lambda goes up for five iterations before the program terminates.

# BUT

It does a lot more refinement if I further constrain it using data from the gyroscope. However, not at as much as I'd expect, and the gyro data needs have artificially high Fisher information.

Working on segments of the whole problem doesn't terminate so quickly. It does more refinement using acceleration alone.

What could be going wrong? The inability to refine the initial estimate by acceleration alone seems to indicate a serious problem.

-

## 2 Answers

It could be that your optimization problem is very badly conditioned when using only the accelerometer data. In other words, the accelerometer data might not sufficiently constrain the parameters so that many different paths adequately fit the data. In terms of the minimization problem this means that you'd have a large "flat spot" at the minimum of different paths with nearly the same objective value.

To test for this, look at the condition number of $J^{T}J$ at the optimal trajectory. If this matrix is ill-conditioned, then you do indeed have a badly conditioned problem.

This would explain the increase in the LM's $\lambda$. If $J^{T}J$ is approaching singularity, LM will increase $\lambda$ to overcome that singularity. This results in shorter and shorter steps, and eventually the LM code just gives up.

-

1
Is this consistent with the behavior that any partition of the problem does not stall? If only some variables are at a broad plateau, which may be a local minimum with wiggle room, will it affect the convergence of the whole problem this way? Since some variables are bound to converge before others, I'm surprised if this is the case… – Potatoswatter Jan 21 at 1:36

The last vertex (data point) in the initial estimate was not getting initialized.

I'm not sure why this choked the solver. Something to do with the error from one outlier point propagating to the other data points, and pulling everything out of the minimum. It still doesn't make sense that everything would be pulled out after so few iterations, though, and the effect isn't obvious on inspection of the premature solution.

-
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 4, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 5, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9260411858558655, "perplexity_flag": "middle"}