【发布时间】:2016-08-23 22:59:54
【问题描述】:
我想最小化二维函数并拥有这样的 Python 代码:
def f(x,y):
return (x-1.0)**2 + (y-2.0)**2
res = minimize(f, x0 = [0.0,0.0], bounds = ((-5,5),(-5,5)), method = 'L-BFGS-B')
而且它不起作用,因为这样的错误(这是错误的最后一行):
TypeError: f() missing 1 required positional argument: 'y'
这是什么意思,我该如何解决?
【问题讨论】:
-
this answer 有帮助吗?