【发布时间】:2019-04-11 23:54:51
【问题描述】:
我有一个需要优化的一维函数。我的初始值为 20,边界为 (0,50)
x0=[20]bounds=(0,50)sol1=minimize(f,x0,method="SLSQP",bounds=bounds)
但是,这会产生 IndexError。
SLSQP Error: the length of bounds is not compatible with that of x0.
我在这里犯了什么错误?
【问题讨论】:
-
bounds=[(0,20)]? -
另外,你可能应该使用
minimize_scalar。
标签: python python-3.x optimization scipy