为了账号安全,请及时绑定邮箱和手机立即绑定

鲍威尔方法 Scipy 中的边界

鲍威尔方法 Scipy 中的边界

PHP
芜湖不芜 2023-11-09 10:35:59
让我们最小化函数f =lambda x: (x+1)**2 在 scipy 中使用鲍威尔方法如果我们使用scipy.optimize.minimize(f, 1, method='Powell', bounds=None)回报是   direc: array([[1.]])     fun: array(0.) message: 'Optimization terminated successfully.'    nfev: 20     nit: 2  status: 0 success: True       x: array(-1.)即最小值应为-1。如果我们提供界限scipy.optimize.minimize(f, 1, method='Powell', bounds=[(0,2)])返回又是   direc: array([[1.]])     fun: array(0.) message: 'Optimization terminated successfully.'    nfev: 20     nit: 2  status: 0 success: True       x: array(-1.)现在这是错误的!正确答案应该是 0。这就像不考虑边界一样。我正在使用 scipy '1.4.1' 和 python 3.7.6。有人有任何线索吗?
查看完整描述

2 回答

?
红糖糍粑

TA贡献1815条经验 获得超6个赞

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])


查看完整回答
反对 回复 2023-11-09
?
有只小跳蛙

TA贡献1824条经验 获得超8个赞

我想补充一点,我也注意到鲍威尔方法倾向于探索越界参数。



查看完整回答
反对 回复 2023-11-09
  • 2 回答
  • 0 关注
  • 77 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信