BJH
BJH

Reputation: 453

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 (i.e. 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.

Upvotes: 8

Views: 9835

Answers (1)

user1834164
user1834164

Reputation: 397

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.

Upvotes: 7

Related Questions