PatWie / CppNumericalSolvers

a lightweight header-only C++17 library of numerical optimization methods for nonlinear functions based on Eigen
MIT License
872 stars 201 forks source link

LBFGS *seems* to stop prematurely #96

Closed rjmoraes closed 6 years ago

rjmoraes commented 6 years ago

I am using the LBFGS solver to optimize a problem with approx. 10000 optimization variables.

The only stopping criterion I set is the maximum number of iterations to 200. All other stopping criteria I set to 0 (e.g. the default).

I thought that by doing that the optimizer would only stop after reaching the maximum number of iterations.

However, the optimizer stops before, with the message "Convergence criteria not reached.". This, as far as I understand, internally means Status::Continue. Therefore, I believe the optimizer should have not stopped.

It might not be an actual issue, but perhaps a misunderstanding of how the library should work.

So, firstly, is that an issue that the optimizer stops with the aforementioned message?

Secondly, is that an issue that the optimizer stops even if only stopping criteria (i.e. maximum number of iterations) has not been met?

PatWie commented 6 years ago
  1. yes, if so
  2. the optimizer should not stop before any stopping criteria is met.

Do you have a MWE. So far these checks look ok: https://github.com/PatWie/CppNumericalSolvers/search?utf8=%E2%9C%93&q=checkConvergence&type=

rjmoraes commented 6 years ago

I am afraid I cannot to provide a MWE. My objective function is based on a relatively complex solution of a PDE and the gradient is computed via adjoint. I would not call it "minimal." :)

I understand how hard it would be to find a fix for a problem you cannot reproduce, but if you give me some hints I can debug it myself and try to understand what is going on.

From the search link above I see that for some solver you do

Super::m_status = checkConvergence(..);

and for others you do

this->m_status = checkConvergence(...); which should not be a problem if m_status is only defined in the base class - which I guess it is the case: m_status seems to be only declared in ISolver. (Just trying to find something fishy...)

PatWie commented 6 years ago

Cannot reproduce.