[SciPy-dev] Patching fmin_l_bfgs_b in scipy.optimize

Gilles Rochefort gilles.rochefort@gmail....
Tue Dec 16 18:59:58 CST 2008


Hi,

I had some troubles getting a stable version of fmin_l_bfgs_b. I got a 
segmentation fault
as soon as I turned a different value than -1 to iprint argument.

As far as I understood, this iprint parameter is directly related to 
some fortran printing/writing logs.
It prints iteration, norm of gradient on screen and also in a file 
called iterate.dat .. Even recompiling
the whole stuff from lapack, atlas etc.. (using gfortran only) up to 
scipy doesn't solve the problem.

Because I definitely gave up the idea to fix the bug by recompiling,  I 
decided to patch the way python
interacts with lbfgsb fortran procedure. So, I disabled the fortran 
iprint and add some iprint functionnality
in pure python code directly in lbfgsb.py (scipy/optimize).  Doing so, I 
get rid of the useless iterate.dat file too.

While patching, I followed by adding some few things :
- an optional stopping rule based on maximum number of iterations. I 
think this is more usefull than
 the number of function evaluations because the fortran code performs a 
linesearch procedure inside the lbfgsb ones.
- a callback procedure which allows to inspect solution, criterion, and 
gradient at current iterate.

Maybe my patch should be usefull for someone,
so I decided to share it with the scipy community.

Gilles.

PS:
I provide two files  :
lbfgsb.py -- the full python script to put in scipy/optimize
scipy-optimize-lbfgsb-12162008.patch -- a patch file

-------------- next part --------------
A non-text attachment was scrubbed...
Name: lbfgsb.py
Type: text/x-python
Size: 10287 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-dev/attachments/20081217/411427ef/attachment-0001.py 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scipy-optimize-lbfgs-12162008.patch
Type: text/x-patch
Size: 3466 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-dev/attachments/20081217/411427ef/attachment-0001.bin 


More information about the Scipy-dev mailing list