Let's minimise the function
f =lambda x: (x+1)**2
using Powell method in scipy
If we use
scipy.optimize.minimize(f, 1, method='Powell', bounds=None)
the return is
direc: array([[1.]])
fun: array(0.)
message: 'Optimization terminated successfully.'
nfev: 20
nit: 2
status: 0
success: True
x: array(-1.)
i.e. the minimum is at -1 as it should. If we provide the bounds
scipy.optimize.minimize(f, 1, method='Powell', bounds=[(0,2)])
the return is again
direc: array([[1.]])
fun: array(0.)
message: 'Optimization terminated successfully.'
nfev: 20
nit: 2
status: 0
success: True
x: array(-1.)
which is now WRONG! The correct answer should be 0. It is like if the bounds are not taken int account. I am using scipy '1.4.1' and python 3.7.6. Someone has any clue?
With scipy 1.4.x the Powell method cannot handle constraints nor bounds, as you can see here. Updating to scipy 1.5.x, it can handle bounds, see here:
In [11]: scipy.optimize.minimize(f, x0=1.0, method='Powell', bounds=[(0.0,2.0)])
Out[11]:
direc: array([[1.64428414e-08]])
fun: array(1.)
message: 'Optimization terminated successfully.'
nfev: 103
nit: 2
status: 0
success: True
x: array([2.44756652e-12])