q-optimize / c3

Toolset for control, calibration and characterization of physical systems
https://c3-toolset.readthedocs.io/
Apache License 2.0
66 stars 36 forks source link

`lbfgs_grad_free` does not process iterations/function-call limits #188

Open lazyoracle opened 2 years ago

lazyoracle commented 2 years ago

Describe the bug

From @alex-simm:

Does anyone know how to stop an optimisation that I run with lbfgs_grad_free? I have set "maxiter"=1000, "gtol"= 1e-3, but the optimiser goes way beyond that and doesn't stop.

Using maxfun as an option leads to:

No, that gives "Unknown solver options: maxfun"

To Reproduce

Steps to reproduce the behavior. This can be in the form of a code snippet or some config files or a notebook to produce a minimum viable example of the bug.

Expected behavior

A clear and concise description of what you expect(ed) to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Environment (please complete the following information)

Additional context

From @nwittler:

lbfgs has a maxfun option. The code for lbfgs_grad_free however is just minimize(fun=fun, x0=x_init, options=options). According to the docs, this could result in several methods being used. Try explicitly method="L-BFGS-B" with the maxfun option.