# set minimize function/value-tolerance

Hi,

can I somehow set function/value tolerances in sages minimizer? From sage's help(minimize) I don't see how.

sage: help(minimize)
minimize(func, x0, gradient=None, hessian=None, algorithm='default', **args)


The Problem: even for a trivial function with a 'shallow' minimum, say,

sage: f=(x-1)^10
sage: minimize(f,[.5])
Optimization terminated successfully.
Current function value: 0.000000
Iterations: 11
Function evaluations: 12
(0.790308276599)


That's not optimal. Sage seems to have some rather moderate default tolerances preset.

B.t.w. that's not the case in SciPy:

~> ipython -pylab -wthread
In : from scipy.optimize import fmin
In : def f(x):
...:     return (x-1.)**10
In : fmin(f,.5)
Optimization terminated successfully.
Current function value: 0.000000
Iterations: 16
Function evaluations: 32
Out: array([ 1.])


So, Python's default tolerance is much stricter, even though, in principle, in that case I could change default tolerances.

In : help(fmin)
fmin(func, x0, args=(), xtol=0.0001, ftol=0.0001, maxiter=None, maxfun=None, full_output=0, disp=1, retall=0, callback=None)


Finally, not speaking of Mathematica ;):

In:= NMinimize[(x - 1)^10, x]
Out= {1.11155*10^-68, {x -> 1.}}


Xaver

edit retag close merge delete

Sort by » oldest newest most voted

If you use the algorithm="simplex" option, it uses the optimize.fmin command, and passes any arguments you specify into fmin. The simplex method is default for python functions, but the bfgs method is default for symbolic expressions.

sage: minimize(f,[.5],algorithm='simplex')
Optimization terminated successfully.
Current function value: 0.000000
Iterations: 16
Function evaluations: 32
(1.0)
sage: def callback(xk):
....:     print xk
....:
sage: minimize(f,[.5],algorithm='simplex',callback=callback)
[ 0.575]
[ 0.675]
[ 0.875]
[ 1.075]
[ 0.975]
[ 0.975]
[ 1.]
[ 1.]
[ 1.]
[ 1.]
[ 1.]
[ 1.]
[ 1.]
[ 1.]
[ 1.]
Optimization terminated successfully.
Current function value: 0.000000
Iterations: 16
Function evaluations: 32
(1.0)

more