ValueError:在fmin_l_bfgs_b中解压缩的值太多

时间:2013-03-02 03:53:11

标签: python

我运行以下代码来运行xfoil,以获得机翼中最佳权重值。

def four_dim_opt(x0, weight_limits, cl, file_path, xfoil_path):
opt_out = fmin_l_bfgs_b(run_xfoil_wcl, x0, args = (cl, file_path, xfoil_path), bounds =    weight_limits, epsilon = 0.01, approx_grad = True)
return opt_out

其中run_xfoil_wcl是拖曳值的函数返回系数(浮点数)。

我不断得到的错误是:

Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
four_dim_opt(x0, weight_limits, 1.2, file_path, xfoil_path)
File "H:/appliedlab4 - Copy(2).py", line 157, in four_dim_opt
opt_out = fmin_l_bfgs_b(run_xfoil_wcl, x0, args = (cl, file_path, xfoil_path), bounds =     weight_limits, epsilon = 0.01, approx_grad = True)
File "C:\Python27\lib\site-packages\scipy\optimize\lbfgsb.py", line 166, in fmin_l_bfgs_b
l,u = bounds[i]
ValueError: too many values to unpack

2 个答案:

答案 0 :(得分:1)

scipy.optimize.fmin_l_bfgs_bweight_limits参数导致错误,它应该是None或包含两个元素的列表:

  

weight_limits - (x,max)对x中每个元素的对,定义该参数的边界。当在该方向上没有约束时,使用None作为min或max之一。

答案 1 :(得分:1)

你在weight_limits传递给four_dim_opt的是什么? weight_limits的值传递给bounds,然后在错误消息的行中访问:

l,u = bounds[i]

这意味着weight_limits应该是一个列表或元组,列表中的每个项目也应该是一个列表或元组(正好保存两个值)。