Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 842
BJH Avatar asked Sep 04 '15 15:09

BJH


1 Answers

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.

like image 142
user1834164 Avatar answered Oct 17 '22 11:10

user1834164