PatWie / CppNumericalSolvers

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

Treatment of NaNs #133

Closed izsahara closed 3 years ago

izsahara commented 3 years ago

Hi, thanks for sharing a great (and necessary) piece of code. Ive got a few questions regarding LBFGSB. Im using the v2 version, works fine on my case but i notice that my Solver-State x_delta and f_delta become considerably small leading to nan function values, Any suggestions on how I can trigger an early stop? or maybe even a restart?

EDIT: How do I instantiate a cppoptlib::solver::State struct such that i could override the DefaultStoppingSolverState()?

Thanks

PatWie commented 3 years ago

You can set the stopping-criteria in the ctor

https://github.com/PatWie/CppNumericalSolvers/blob/51ed3286641706dffd0653fa1639a0f70137893a/include/cppoptlib/solver/solver.h#L183-L184