Max Num iterations vs single iteration multiple times

64 views
Skip to first unread message

Adit

unread,
Oct 18, 2017, 2:30:59 PM10/18/17
to Ceres Solver
Hello,

I am trying to understand why I get different optimization solutions in these two cases with identical data:

1. Running the solver with options.max_num_iterations = 500
2. Running the solver with options.max_num_iterations = 1 and running this m times until convergence where the output to each stage is fed as the initial values for the next step.

Basically I was trying to display the output at each iteration to show how the curve fitting algorithm finally converges. And then I realized that I am getting different final answers in these two cases.

Particular details for my problem: Running in Visual Studio C++ 2013. For my particular example the solver converges in around 25-50 iterations. I am using DENSE_QR as the linear solver type.
Solver::Options options;
options.max_num_iterations = iterations;
options.linear_solver_type = ceres::DENSE_QR;
options.minimizer_progress_to_stdout = true;

Problem problem;
while (a.next()) {
     problem.AddResidualBlock(new AutoDiffCostFunction<const model_t::case1_t, 1, 1, 1, 1>((const model_t::case1_t *)case1_f), NULL,
                  &(*m1)[0], &(*m2)[0], &(*m3)[0]);
            }
           
set_bounds(problem, *m1, 0.5, 1.0);
set_bounds(problem, *m2, M2lowValue, M2highValue);
set_bounds(problem, *m3, M3lowValue, M3highValue);

Solver::Summary summary;
Solve(options, &problem, &summary);

Thank you.

Regards,
Adit

Sameer Agarwal

unread,
Oct 18, 2017, 4:38:38 PM10/18/17
to ceres-...@googlegroups.com
Adit,

The solver computes internal state and updates it every iteration as it runs for more than 1 iteration, for example the trust region radius/LM damping parameter. If you run the solver for one iteration over and over again, it resets the solver/internal state every time you call Solve. So for example the trust region radius is never updated. This is why you are getting much different and likely worse results.

The thing to do if you want access to the parameters during the optimization is to write an IterationCallback object which will be called at the end of every iteration. You will also need to set Solver::Options::update_state_every_iteration = true. which will ensure that the values in your parameter blocks are updated every iteration as opposed to at the end of the solve.

Sameer



--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/14c79e3b-372c-45a1-874f-086c0d12f9eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Adit

unread,
Oct 18, 2017, 4:56:15 PM10/18/17
to Ceres Solver
Thank you Sameer. That clearly explains it.

Thanks. - Adit
Reply all
Reply to author
Forward
0 new messages