# [SciPy-user] Getting started with optimize.fmin_l_bfgs_b

Nils Wagner nwagner at mecha.uni-stuttgart.de
Wed Jun 29 04:43:55 CDT 2005

```Hi all,

How can I solve the following LP problem with scipy ?

Minimize f(x_1,x_2) = x_1-x_2

subject to

-2 \le x_1 \le 2
-2 \le x_2 \le 2

The solution is x_1 = -2 , x_2 = 2

My implementation fails

from scipy import *

def func(x):
return x[0]-x[1]

guess = 1.2, 1.0
bounds = [(-2.0,2.0), (-2.0,2.0) ]
best, val, d = optimize.fmin_l_bfgs_b(func, guess, bounds=bounds)

Traceback (most recent call last):
File "bfgs_b.py", line 8, in ?
best, val, d = optimize.fmin_l_bfgs_b(func, guess, bounds=bounds)
File
"/usr/local/lib/python2.4/site-packages/scipy/optimize/lbfgsb.py", line
183, in fmin_l_bfgs_b
f[0], g = func_and_grad(x)
File
"/usr/local/lib/python2.4/site-packages/scipy/optimize/lbfgsb.py", line
135, in func_and_grad
f, g = func(x, *args)
TypeError: unpack non-sequence

How can I resolve the problem ?

Nils

```

More information about the SciPy-user mailing list