On Fri, Mar 29, 2019 at 7:03 AM Drew Parsons <dpars...@debian.org> wrote:
> Hi Gard, can you provide a simple test script so we can confirm that
> scipy works correctly after applying your L-BFGS-B patch?

Hi,

Attached is an improved patch, superseding the previous ones, for
using Debian's system LBFGSB library (build-depend on liblbfgsb-dev).

The patch can be tested with something like:

 from scipy.optimize import fmin_l_bfgs_b, rosen

 x0 = [0.2, -0.2, 0.1, -0.1]
 res = fmin_l_bfgs_b(rosen, x0, approx_grad=True, factr=10)
 print("Unbounded minimum:")
 print(res)

 res = fmin_l_bfgs_b(rosen, x0, approx_grad=True, factr=10,
bounds=len(x0)*[(-0.5, 0.5)])
 print("Bounded minimum:")
 print(res)

One can then compare the two outputs produced with the patch with the
ones produced without it.

The results may differ very slightly because the system LBFGSB uses LAPACK,
while the SciPy-bundled one uses LINPACK.


 Best,
 Gard
From: Gard Spreemann <gspreem...@gmail.com>
Date: Tue, 2 Apr 2019 11:25:26 +0200
Subject: Use system LBFGSB.

---
 scipy/optimize/setup.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scipy/optimize/setup.py b/scipy/optimize/setup.py
index 67d2576..58666e6 100644
--- a/scipy/optimize/setup.py
+++ b/scipy/optimize/setup.py
@@ -38,7 +38,9 @@ def configuration(parent_package='',top_path=None):
                                        numpy_nodepr_api['define_macros'])
         else:
             lapack['define_macros'] = numpy_nodepr_api['define_macros']
-    sources = ['lbfgsb.pyf', 'lbfgsb.f', 'linpack.f', 'timer.f']
+    lapack.setdefault('libraries', [])
+    lapack['libraries'].append('lbfgsb')
+    sources = ['lbfgsb.pyf']
     config.add_extension('_lbfgsb',
                          sources=[join('lbfgsb',x) for x in sources],
                          **lapack)

Reply via email to