yixuan / LBFGSpp

A header-only C++ library for L-BFGS and L-BFGS-B algorithms
https://lbfgspp.statr.me/
MIT License
532 stars 101 forks source link

the line search routine reached the maximum number of iterations #14

Closed hyl317 closed 1 year ago

hyl317 commented 4 years ago

Hi, thanks for writing this library! While using it, I encountered the following runtime error,

terminate called after throwing an instance of 'std::runtime_error' what(): the line search routine reached the maximum number of iterations Aborted (core dumped)

My objective function has 200 free parameters; admittedly, this is not a very easy task. However, I wrote python prototype before for this task and used scipy.optimize with LFBG method and it works fine. I also checked my gradient against numerically computed gradient and they agree. What confuses me a bit is that, after seeing this error, I set param.max_iterations = 0; which, according to the doc, should allow the optim to continue until an error occurs or convergence. But I am still getting the same error saying maximum number of iterations reached. I wonder if something else is happening? Thanks a lot!

yixuan commented 4 years ago

Hi @hyl317, the error message is about the line search procedure, not the overall iterations. The parameter to control it is param.max_linesearch.

GPrathap commented 3 years ago

Hi @yixuan, Is there is a proper way to handle these kinds of errors rather than handling runtime exceptions?

yixuan commented 1 year ago

This commit has removed major runtime exceptions when maximum number of line searches is reached, which should resolve most of the issues above.

There remain some exceptions in the code, which are mostly "serious" issues that are hard to proceed.

Let me first mark this as closed. Feel free to reopen if further issues occur.