2013-03-02 59 views
-1

我運行以下代碼來運行xfoil,以獲得機翼中權重的最佳值。ValueError:fmin_l_bfgs_b中要解壓縮的值太多

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是阻力值的functionreturning係數(浮點)。

我不斷收到的錯誤是:

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 
+0

什麼是'weight_limits'?你似乎將太多的價值傳遞給它。 – Blender 2013-03-02 03:56:21

回答

1

weight_limits參數scipy.optimize.fmin_l_bfgs_b導致了錯誤,它應該是None或包含兩個元素的列表:

weight_limits - (min, max) pairs for each element in x, defining the bounds on that parameter. Use None for one of min or max when there is no bound in that direction.

1

你是什麼傳遞給four_dim_opt作爲您的weight_limits?對於weight_limits被傳遞到邊界的值,然後在該行訪問你的錯誤信息:列表中的每個項目

l,u = bounds[i] 

這意味着weight_limits預計將列表或元組,並且也應該是一個列表或元組(正好保存兩個值)。

相關問題