[SciPy-user] Getting started with optimize.fmin_l_bfgs_b

Christian Kristukat ckkart at hoc.net
Wed Jun 29 07:17:13 CDT 2005

Nils Wagner wrote:
>> You could collect the values of x at each call of 'func' in a global 
>> list and plot them later.
> Please can you send me an example how to realize this task in my case. 
> Thanks in advance.

from scipy import *
import pylab

data = []
def func(x):
     global data
     data.append(x*1)  # to force a copy
     return x[0]-x[1], array(([1.0,-1.0]))

guess = 1.2, 1.3
bounds = [(-2.0,2.0), (-2.0,2.0) ]

best, val, d = optimize.fmin_l_bfgs_b(func, guess, bounds=bounds, iprint=-1)

print 'Position of the minimum',best, 'and its value',val

data = transpose(data)

Regards, Christian

More information about the SciPy-user mailing list