简体   繁体   中英

Set convergence tolerance for scipy.optimize.minimize(method='L-BFGS-B')

This page ( http://docs.scipy.org/doc/scipy/reference/optimize.minimize-lbfgsb.html ) describes the solver options one can pass to the L-BFGS-B' method of scipy's optimization package. I am trying to set the solver exit tolerance.

The docs mention two options, the one I would have preffered to use is 'factr', where the solver exits when: (f^k - f^{k+1})/max{|f^k|,|f^{k+1}|,1} <= factr * eps (where epsilon is machine precision). However when I run my code is get a warning:

OptimizeWarning: Unknown solver options: factr

So I presumed this option has been deprecated in favour of ftol (not sure why it would be though?). ftol being a specified number (ie diff <= n rather than <= n * machine_error).

That's fine by me, however the exit message I get for the solver is

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH

which suggests the L-BFGS-B routine is still using some value of factr which I do not know, and seemingly can't specify. Might be an overlooked mistake in the code, might be I've missed some way of passing options. Does anyone who uses this popular solver know a workaround?

Thanks

I've opened an issue on scipy github repository as well.

Internally, factr is still computed ( in this line of code ).

You can simply use something like

myfactr = 1e2
r = scipy.optimize.minimize(..., options={'ftol' : myfactr * np.finfo(float).eps)

if you still want to specify rather a value for factr instead of ftol directly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM