简体   繁体   中英

Why my scipy.optimize.minimize fails?

I try with fmin_bfgs to find the local minimum of the absolute function abs(x) . The initial point is set to 100.0; the expected answer is 0.0. However, I get:

In [184]: op.fmin_bfgs(lambda x:np.abs(x),100.0)
Warning: Desired error not necessarily achieved due to precision loss.
         Current function value: 100.000000
         Iterations: 0
         Function evaluations: 64
         Gradient evaluations: 20
Out[184]: array([100.0])

Why?

Methods like fmin_bfgs and fmin_slsqp require smooth (continuous derivative) functions in order to provide reliable results. abs(x) has a dicontinuous derivative at its minimum. A method like the Nelder-Mead simplex, which doesn't require continuous derivatives, might provide better results in this case.

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