diff options
28 files changed, 1033 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..2d726c6 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,109 @@ +lbfgsb (3.0+dfsg.3-11) unstable; urgency=medium + + * Simplify build flags. (Closes: #1015469) + * Standards-version 4.6.1.0. No changes needed. + + -- Gard Spreemann <gspr@nonempty.org> Wed, 20 Jul 2022 13:24:01 +0200 + +lbfgsb (3.0+dfsg.3-10) unstable; urgency=medium + + [ Debian Janitor ] + * Trim trailing whitespace. + + [ Gard Spreemann ] + * Standards-version 4.6.0.1. No changes needed. + * Started upstream metadata. + * Change log file disabling patch to preserve upstream ABI. + + -- Gard Spreemann <gspr@nonempty.org> Mon, 13 Dec 2021 15:11:19 +0100 + +lbfgsb (3.0+dfsg.3-9) unstable; urgency=medium + + * New-style dh compat level. + * Add patch based on SciPy to prevent bounds violation. (Closes: #966448) + * Let gbp cosmetically reformat patches. + * Add patch based on SciPy to fix NaN propagation. + * Add patches based on SciPy to prevent time printing and log files. + * Move to Salsa. + + -- Gard Spreemann <gspr@nonempty.org> Thu, 30 Jul 2020 11:01:06 +0200 + +lbfgsb (3.0+dfsg.3-8) unstable; urgency=medium + + * Relax compilation flags for tests to allow them to run on more + architectures. + * Standards-version 4.5.0. No changes needed. + * Avoid build-depending on dh-exec, requires dh 13. + + -- Gard Spreemann <gspr@nonempty.org> Thu, 23 Apr 2020 23:21:49 +0200 + +lbfgsb (3.0+dfsg.3-7) unstable; urgency=medium + + * Man page stub for -examples package. + * Add superficial test that just checks that the upstream examples run. + + -- Gard Spreemann <gspr@nonempty.org> Mon, 26 Aug 2019 17:20:47 +0200 + +lbfgsb (3.0+dfsg.3-6) unstable; urgency=medium + + * Reorder linking flag for tests. + + -- Gard Spreemann <gspr@nonempty.org> Wed, 21 Aug 2019 09:55:26 +0200 + +lbfgsb (3.0+dfsg.3-5) unstable; urgency=medium + + * Remove broken symbols file. + + -- Gard Spreemann <gspr@nonempty.org> Thu, 18 Jul 2019 13:48:32 +0200 + +lbfgsb (3.0+dfsg.3-4) unstable; urgency=medium + + * Standards-version 4.4.0. No changes needed. + * Compat level 12. + * Add symbols file. + * Rules-Requires-Root: no + * Change maintainer email address. + + -- Gard Spreemann <gspr@nonempty.org> Wed, 17 Jul 2019 09:03:37 +0200 + +lbfgsb (3.0+dfsg.3-3) unstable; urgency=medium + + * Statically linked test binary should link with LAPACK. + * Allow tests to print to stderr. + + -- Gard Spreemann <gspreemann@gmail.com> Sun, 17 Jun 2018 23:58:46 +0200 + +lbfgsb (3.0+dfsg.3-2) unstable; urgency=medium + + * compat level 10. + * Standards-version 4.1.4. No changes needed. + * Introduce tests. + * Correct installation path for -doc package. + * Install doc-base control file. + + -- Gard Spreemann <gspreemann@gmail.com> Wed, 13 Jun 2018 10:43:30 +0200 + +lbfgsb (3.0+dfsg.3-1) unstable; urgency=medium + + * Remove repack script and have uscan read Files-Excluded from + debian/copyright instead. + + -- Gard Spreemann <gspreemann@gmail.com> Mon, 19 Sep 2016 18:30:54 +0200 + +lbfgsb (3.0+dfsg.2-1) unstable; urgency=medium + + * Remove unused blas.f and linpack.f during repack. + * -examples package with example programs (compiled and source) and + output from upstream. + * -doc package split off from main lib package. + * Multi-arch support for the library packages. + * Explicitly set compile flags. + * Enable hardening. + + -- Gard Spreemann <gspreemann@gmail.com> Fri, 20 May 2016 18:04:05 +0200 + +lbfgsb (3.0+dfsg.1-1) unstable; urgency=medium + + * Initial packaging. Closes: #811069 + + -- Gard Spreemann <gspreemann@gmail.com> Wed, 11 May 2016 12:12:59 +0200 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..b54d482 --- /dev/null +++ b/debian/control @@ -0,0 +1,112 @@ +Source: lbfgsb +Maintainer: Gard Spreemann <gspr@nonempty.org> +Section: math +Priority: optional +Standards-Version: 4.6.1.0 +Build-Depends: debhelper-compat (= 13), gfortran, libblas-dev, liblapack-dev +Rules-Requires-Root: no +Homepage: https://users.iems.northwestern.edu/~nocedal/lbfgsb.html +Vcs-Browser: https://salsa.debian.org/gspr/lbfgsb +Vcs-Git: https://salsa.debian.org/gspr/lbfgsb.git -b debian/sid + +Package: liblbfgsb0 +Section: libs +Architecture: any +Multi-Arch: same +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Limited-memory quasi-Newton bound-constrained optimization + Fortran library implementing limited-memory quasi-Newton + bound-constrained optimization as described in [1,2,3]. + . + This package contains the library itself. + . + [1] R. H. Byrd, P. Lu and J. Nocedal. A Limited Memory Algorithm for + Bound Constrained Optimization, (1995), SIAM Journal on Scientific + and Statistical Computing , 16, 5, pp. 1190-1208. + . + [2] C. Zhu, R. H. Byrd and J. Nocedal. L-BFGS-B: Algorithm 778: + L-BFGS-B, FORTRAN routines for large scale bound constrained + optimization (1997), ACM Transactions on Mathematical Software, Vol + 23, Num. 4, pp. 550 - 560. + . + [3] J.L. Morales and J. Nocedal. L-BFGS-B: Remark on Algorithm 778: + L-BFGS-B, FORTRAN routines for large scale bound constrained + optimization (2011), to appear in ACM Transactions on Mathematical + Software. + +Package: liblbfgsb-dev +Section: libdevel +Architecture: any +Multi-Arch: same +Depends: ${misc:Depends}, liblbfgsb0 (= ${binary:Version}) +Suggests: liblbfgsb-doc, liblbfgsb-examples +Description: Limited-memory quasi-Newton bound-constrained optimization (static library) + Fortran library implementing limited-memory quasi-Newton + bound-constrained optimization as described in [1,2,3]. + . + This package contains the static library. + . + [1] R. H. Byrd, P. Lu and J. Nocedal. A Limited Memory Algorithm for + Bound Constrained Optimization, (1995), SIAM Journal on Scientific + and Statistical Computing , 16, 5, pp. 1190-1208. + . + [2] C. Zhu, R. H. Byrd and J. Nocedal. L-BFGS-B: Algorithm 778: + L-BFGS-B, FORTRAN routines for large scale bound constrained + optimization (1997), ACM Transactions on Mathematical Software, Vol + 23, Num. 4, pp. 550 - 560. + . + [3] J.L. Morales and J. Nocedal. L-BFGS-B: Remark on Algorithm 778: + L-BFGS-B, FORTRAN routines for large scale bound constrained + optimization (2011), to appear in ACM Transactions on Mathematical + Software. + +Package: liblbfgsb-doc +Section: doc +Architecture: all +Multi-Arch: foreign +Depends: ${misc:Depends} +Description: Limited-memory quasi-Newton bound-constrained optimization (documentation) + Fortran library implementing limited-memory quasi-Newton + bound-constrained optimization as described in [1,2,3]. + . + This package contains the documentation describing the library and + algorithm. + . + [1] R. H. Byrd, P. Lu and J. Nocedal. A Limited Memory Algorithm for + Bound Constrained Optimization, (1995), SIAM Journal on Scientific + and Statistical Computing , 16, 5, pp. 1190-1208. + . + [2] C. Zhu, R. H. Byrd and J. Nocedal. L-BFGS-B: Algorithm 778: + L-BFGS-B, FORTRAN routines for large scale bound constrained + optimization (1997), ACM Transactions on Mathematical Software, Vol + 23, Num. 4, pp. 550 - 560. + . + [3] J.L. Morales and J. Nocedal. L-BFGS-B: Remark on Algorithm 778: + L-BFGS-B, FORTRAN routines for large scale bound constrained + optimization (2011), to appear in ACM Transactions on Mathematical + Software. + +Package: liblbfgsb-examples +Section: libs +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Limited-memory quasi-Newton bound-constrained optimization (examples) + Fortran library implementing limited-memory quasi-Newton + bound-constrained optimization as described in [1,2,3]. + . + This package contains some example programs, their source code and + example output as provided by upstream. + . + [1] R. H. Byrd, P. Lu and J. Nocedal. A Limited Memory Algorithm for + Bound Constrained Optimization, (1995), SIAM Journal on Scientific + and Statistical Computing , 16, 5, pp. 1190-1208. + . + [2] C. Zhu, R. H. Byrd and J. Nocedal. L-BFGS-B: Algorithm 778: + L-BFGS-B, FORTRAN routines for large scale bound constrained + optimization (1997), ACM Transactions on Mathematical Software, Vol + 23, Num. 4, pp. 550 - 560. + . + [3] J.L. Morales and J. Nocedal. L-BFGS-B: Remark on Algorithm 778: + L-BFGS-B, FORTRAN routines for large scale bound constrained + optimization (2011), to appear in ACM Transactions on Mathematical + Software. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..9baab05 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,41 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: L-BFGS-B +Files-Excluded: x.* ._* OUTPUTS/._* ../._Lbfgsb.3.0 linpack.f blas.f +Source: http://users.iems.northwestern.edu/~nocedal/lbfgsb.html + The pristine upstream source contains prebuilt binaries and various metadata + files, as well as unused copied of LINPACK and BLAS. These are removed. + +Files: * +Copyright: 2011 Ciyou Zhu, Richard Byrd, Jorge Nocedal, Jose Luis Morales +License: BSD-3-clause + +Files: debian/* +Copyright: 2013-2022 Gard Spreemann <gspr@nonempty.org> +License: BSD-3-clause + +Files: debian/tests/*.f90 +Copyright: Ciyou Zhu, Richard Byrd, Jorge Nocedal, Jose Luis Morales +License: BSD-3-clause + +License: BSD-3-clause + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the <organization> nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + . + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/debian/liblbfgsb-dev.install b/debian/liblbfgsb-dev.install new file mode 100644 index 0000000..2d2db83 --- /dev/null +++ b/debian/liblbfgsb-dev.install @@ -0,0 +1,2 @@ +build/liblbfgsb.so usr/lib/${DEB_HOST_MULTIARCH}/ +build/liblbfgsb.a usr/lib/${DEB_HOST_MULTIARCH}/ diff --git a/debian/liblbfgsb-doc.doc-base b/debian/liblbfgsb-doc.doc-base new file mode 100644 index 0000000..34a46a8 --- /dev/null +++ b/debian/liblbfgsb-doc.doc-base @@ -0,0 +1,7 @@ +Document: liblbfgsb-doc +Title: L-BFGS-B manual +Abstract: This manual describes the algorithm behind, and the implementation of L-BFGS-B. +Section: Science/Mathematics + +Format: PDF +Files: /usr/share/doc/liblbfgsb/*.pdf diff --git a/debian/liblbfgsb-doc.install b/debian/liblbfgsb-doc.install new file mode 100644 index 0000000..e92aec8 --- /dev/null +++ b/debian/liblbfgsb-doc.install @@ -0,0 +1 @@ +*.pdf usr/share/doc/liblbfgsb/
\ No newline at end of file diff --git a/debian/liblbfgsb-examples.1 b/debian/liblbfgsb-examples.1 new file mode 100644 index 0000000..16ba52c --- /dev/null +++ b/debian/liblbfgsb-examples.1 @@ -0,0 +1,12 @@ +.TH "liblbfgsb-examples" 1 +.SH NAME +liblbfgsb-examples \- example programs using the L-BFGS-B library +.SH SYNOPSIS +.B lbfgsb-examples_* +.SH DESCRIPTION +The +.B lbfgsb-examples_* +programs are the compiled versions of the corresponding L-BFGS-B +library examples whose source files are installed in +/usr/share/doc/liblbfgsb-examples. The compiled programs do not in +themselves serve a purpose. diff --git a/debian/liblbfgsb-examples.docs b/debian/liblbfgsb-examples.docs new file mode 100644 index 0000000..ff77c49 --- /dev/null +++ b/debian/liblbfgsb-examples.docs @@ -0,0 +1,2 @@ +driver*.f* +OUTPUTS/output_*
\ No newline at end of file diff --git a/debian/liblbfgsb-examples.install b/debian/liblbfgsb-examples.install new file mode 100644 index 0000000..b2e3043 --- /dev/null +++ b/debian/liblbfgsb-examples.install @@ -0,0 +1,6 @@ +build/lbfgsb-examples_driver1_77 usr/bin/ +build/lbfgsb-examples_driver1_90 usr/bin/ +build/lbfgsb-examples_driver2_77 usr/bin/ +build/lbfgsb-examples_driver2_90 usr/bin/ +build/lbfgsb-examples_driver3_77 usr/bin/ +build/lbfgsb-examples_driver3_90 usr/bin/
\ No newline at end of file diff --git a/debian/liblbfgsb-examples.links b/debian/liblbfgsb-examples.links new file mode 100644 index 0000000..a416ae6 --- /dev/null +++ b/debian/liblbfgsb-examples.links @@ -0,0 +1,6 @@ +usr/share/man/man1/liblbfgsb-examples.1 usr/share/man/man1/lbfgsb-examples_driver1_77.1 +usr/share/man/man1/liblbfgsb-examples.1 usr/share/man/man1/lbfgsb-examples_driver1_90.1 +usr/share/man/man1/liblbfgsb-examples.1 usr/share/man/man1/lbfgsb-examples_driver2_77.1 +usr/share/man/man1/liblbfgsb-examples.1 usr/share/man/man1/lbfgsb-examples_driver2_90.1 +usr/share/man/man1/liblbfgsb-examples.1 usr/share/man/man1/lbfgsb-examples_driver3_77.1 +usr/share/man/man1/liblbfgsb-examples.1 usr/share/man/man1/lbfgsb-examples_driver3_90.1 diff --git a/debian/liblbfgsb-examples.manpages b/debian/liblbfgsb-examples.manpages new file mode 100644 index 0000000..340553b --- /dev/null +++ b/debian/liblbfgsb-examples.manpages @@ -0,0 +1 @@ +debian/liblbfgsb-examples.1 diff --git a/debian/liblbfgsb0.install b/debian/liblbfgsb0.install new file mode 100644 index 0000000..0d8cfeb --- /dev/null +++ b/debian/liblbfgsb0.install @@ -0,0 +1 @@ +build/liblbfgsb.so.0 usr/lib/${DEB_HOST_MULTIARCH}/ diff --git a/debian/patches/0003-Prevent-bound-violation.patch b/debian/patches/0003-Prevent-bound-violation.patch new file mode 100644 index 0000000..04a4acc --- /dev/null +++ b/debian/patches/0003-Prevent-bound-violation.patch @@ -0,0 +1,27 @@ +From: Gard Spreemann <gspr@nonempty.org> +Date: Thu, 30 Jul 2020 10:15:21 +0200 +Subject: Prevent bound violation. + +This is based on SciPy's commits + cb9ed45d1a25d77204c737a8e1489dfb9606241f + e5ffa787555a60caf2ed9d0046a9ab782457fea4 +--- + lbfgsb.f | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/lbfgsb.f b/lbfgsb.f +index 008370d..7c6b7fc 100644 +--- a/lbfgsb.f ++++ b/lbfgsb.f +@@ -2569,8 +2569,11 @@ c Line search is impossible. + if (stp .eq. one) then + call dcopy(n,z,1,x,1) + else ++c take step and prevent rounding error beyond bound + do 41 i = 1, n + x(i) = stp*d(i) + t(i) ++ if (nbd(i).eq.1.or.nbd(i).eq.2) x(i) = max(x(i), l(i)) ++ if (nbd(i).eq.2.or.nbd(i).eq.3) x(i) = min(x(i), u(i)) + 41 continue + endif + else diff --git a/debian/patches/0004-Fix-NaN-propagation.patch b/debian/patches/0004-Fix-NaN-propagation.patch new file mode 100644 index 0000000..dae12ec --- /dev/null +++ b/debian/patches/0004-Fix-NaN-propagation.patch @@ -0,0 +1,26 @@ +From: Gard Spreemann <gspr@nonempty.org> +Date: Thu, 30 Jul 2020 10:25:38 +0200 +Subject: Fix NaN propagation. + +This is based on SciPy commit + 4eb242fabeef7d1871d21936bee275be4fda1844 +--- + lbfgsb.f | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/lbfgsb.f b/lbfgsb.f +index 7c6b7fc..501879b 100644 +--- a/lbfgsb.f ++++ b/lbfgsb.f +@@ -2977,6 +2977,11 @@ c ************ + sbgnrm = zero + do 15 i = 1, n + gi = g(i) ++ if (gi.ne.gi) then ++c NaN value in gradient: propagate it ++ sbgnrm = gi ++ return ++ endif + if (nbd(i) .ne. 0) then + if (gi .lt. zero) then + if (nbd(i) .ge. 2) gi = max((x(i)-u(i)),gi) diff --git a/debian/patches/0005-Disable-printing-of-time.patch b/debian/patches/0005-Disable-printing-of-time.patch new file mode 100644 index 0000000..9f84bf4 --- /dev/null +++ b/debian/patches/0005-Disable-printing-of-time.patch @@ -0,0 +1,23 @@ +From: Gard Spreemann <gspr@nonempty.org> +Date: Thu, 30 Jul 2020 10:30:09 +0200 +Subject: Disable printing of time. + +Per SciPy commit + 04cd360b25c4bb1b831895f51b653ac282afc78c +--- + lbfgsb.f | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/lbfgsb.f b/lbfgsb.f +index 501879b..59f0a97 100644 +--- a/lbfgsb.f ++++ b/lbfgsb.f +@@ -2873,8 +2873,6 @@ c ************ + if (info .eq. -8) write (6,9018) + if (info .eq. -9) write (6,9019) + endif +- if (iprint .ge. 1) write (6,3007) cachyt,sbtime,lnscht +- write (6,3008) time + if (iprint .ge. 1) then + if (info .eq. -4 .or. info .eq. -9) then + write (itfile,3002) diff --git a/debian/patches/0006-Stop-generating-iteration-log-files.patch b/debian/patches/0006-Stop-generating-iteration-log-files.patch new file mode 100644 index 0000000..efff3f1 --- /dev/null +++ b/debian/patches/0006-Stop-generating-iteration-log-files.patch @@ -0,0 +1,113 @@ +From: Gard Spreemann <gspr@nonempty.org> +Date: Mon, 13 Dec 2021 14:56:07 +0100 +Subject: Stop generating iteration log files + +Based on SciPy commit c3c54c15eafe7fa7a2b7a499cb64f38f1a7ee057 +--- + lbfgsb.f | 37 ++----------------------------------- + 1 file changed, 2 insertions(+), 35 deletions(-) + +diff --git a/lbfgsb.f b/lbfgsb.f +index 59f0a97..18d4715 100644 +--- a/lbfgsb.f ++++ b/lbfgsb.f +@@ -140,8 +140,6 @@ c 0<iprint<99 print also f and |proj g| every iprint iterations; + c iprint=99 print details of every iteration except n-vectors; + c iprint=100 print also the changes of active set and final x; + c iprint>100 print details of every iteration including x and g; +-c When iprint > 0, the file iterate.dat will be created to +-c summarize the iteration. + c + c csave is a working string of characters of length 60. + c +@@ -426,8 +424,6 @@ c 0<iprint<99 print also f and |proj g| every iprint iterations; + c iprint=99 print details of every iteration except n-vectors; + c iprint=100 print also the changes of active set and final x; + c iprint>100 print details of every iteration including x and g; +-c When iprint > 0, the file iterate.dat will be created to +-c summarize the iteration. + c + c csave is a working string of characters of length 60. + c +@@ -547,10 +543,8 @@ c 'info' records the termination information. + info = 0 + + itfile = 8 +- if (iprint .ge. 1) then +-c open a summary file 'iterate.dat' +- open (8, file = 'iterate.dat', status = 'unknown') +- endif ++c Originally a file named iterate.dat was created. We disable ++c this behavior in Debian. + + c Check the input arguments for errors. + +@@ -646,7 +640,6 @@ c Compute the infinity norm of the (-) projected gradient. + + if (iprint .ge. 1) then + write (6,1002) iter,f,sbgnrm +- write (itfile,1003) iter,nfgv,sbgnrm,f + endif + if (sbgnrm .le. pgtol) then + c terminate the algorithm. +@@ -1361,8 +1354,6 @@ c 0<iprint<99 print also f and |proj g| every iprint iterations; + c iprint=99 print details of every iteration except n-vectors; + c iprint=100 print also the changes of active set and final x; + c iprint>100 print details of every iteration including x and g; +-c When iprint > 0, the file iterate.dat will be created to +-c summarize the iteration. + c + c sbgnrm is a double precision variable. + c On entry sbgnrm is the norm of the projected gradient at x. +@@ -2705,9 +2696,6 @@ c ************ + write (6,7001) epsmch + write (6,*) 'N = ',n,' M = ',m + if (iprint .ge. 1) then +- write (itfile,2001) epsmch +- write (itfile,*)'N = ',n,' M = ',m +- write (itfile,9001) + if (iprint .gt. 100) then + write (6,1004) 'L =',(l(i),i = 1,n) + write (6,1004) 'X0 =',(x(i),i = 1,n) +@@ -2798,8 +2786,6 @@ c the truncated Newton step has been used. + imod = mod(iter,iprint) + if (imod .eq. 0) write (6,2001) iter,f,sbgnrm + endif +- if (iprint .ge. 1) write (itfile,3001) +- + iter,nfgv,nseg,nact,word,iback,stp,xstep,sbgnrm,f + + 1004 format (/,a4, 1p, 6(1x,d11.4),/,(4x,1p,6(1x,d11.4))) + 2001 format +@@ -2873,23 +2859,6 @@ c ************ + if (info .eq. -8) write (6,9018) + if (info .eq. -9) write (6,9019) + endif +- if (iprint .ge. 1) then +- if (info .eq. -4 .or. info .eq. -9) then +- write (itfile,3002) +- + iter,nfgv,nseg,nact,word,iback,stp,xstep +- endif +- write (itfile,3009) task +- if (info .ne. 0) then +- if (info .eq. -1) write (itfile,9011) +- if (info .eq. -2) write (itfile,9012) +- if (info .eq. -3) write (itfile,9013) +- if (info .eq. -4) write (itfile,9014) +- if (info .eq. -5) write (itfile,9015) +- if (info .eq. -8) write (itfile,9018) +- if (info .eq. -9) write (itfile,9019) +- endif +- write (itfile,3008) time +- endif + endif + + 1004 format (/,a4, 1p, 6(1x,d11.4),/,(4x,1p,6(1x,d11.4))) +@@ -3152,8 +3121,6 @@ c 0<iprint<99 print also f and |proj g| every iprint iterations; + c iprint=99 print details of every iteration except n-vectors; + c iprint=100 print also the changes of active set and final x; + c iprint>100 print details of every iteration including x and g; +-c When iprint > 0, the file iterate.dat will be created to +-c summarize the iteration. + c + c info is an integer variable. + c On entry info is unspecified. diff --git a/debian/patches/replace-linpack-with-lapack.patch b/debian/patches/replace-linpack-with-lapack.patch new file mode 100644 index 0000000..a875ea2 --- /dev/null +++ b/debian/patches/replace-linpack-with-lapack.patch @@ -0,0 +1,86 @@ +From: Gard Spreemann <gspr@nonempty.org> +Date: Thu, 30 Jul 2020 09:57:45 +0200 +Subject: replace-linpack-with-lapack + +The library code originally uses LINPACK (from an embedded +copy). Since LINPACK has largely been superseded by LAPACK, this patch +replaces calls to the former with equivalent calls to the +latter. Specifically, dpofa is replaced by dpotrf, and dtrsl is +replaced by dtrtrs. +--- + lbfgsb.f | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/lbfgsb.f b/lbfgsb.f +index 9c9e7d9..54fd1f9 100644 +--- a/lbfgsb.f ++++ b/lbfgsb.f +@@ -1185,7 +1185,7 @@ c solve Jp2=v2+LD^(-1)v1. + p(i2) = v(i2) + sum + 20 continue + c Solve the triangular system +- call dtrsl(wt,m,col,p(col+1),11,info) ++ call dtrtrs('U', 'T', 'N', col, 1, wt, m, p(col+1), col, info) + if (info .ne. 0) return + + c solve D^(1/2)p1=v1. +@@ -1197,7 +1197,7 @@ c PART II: solve [ -D^(1/2) D^(-1/2)*L' ] [ p1 ] = [ p1 ] + c [ 0 J' ] [ p2 ] [ p2 ]. + + c solve J^Tp2=p2. +- call dtrsl(wt,m,col,p(col+1),01,info) ++ call dtrtrs('U', 'N', 'N', col, 1, wt, m, p(col+1), col, info) + if (info .ne. 0) return + + c compute p1=-D^(-1/2)(p1-D^(-1/2)L'p2) +@@ -2135,7 +2135,7 @@ c [(-L_a +R_z)L'^-1 S'AA'S*theta ] + + c first Cholesky factor (1,1) block of wn to get LL' + c with L' stored in the upper triangle of wn. +- call dpofa(wn,m2,col,info) ++ call dpotrf('U', col, wn, m2, info) + if (info .ne. 0) then + info = -1 + return +@@ -2143,7 +2143,7 @@ c with L' stored in the upper triangle of wn. + c then form L^-1(-L_a'+R_z') in the (1,2) block. + col2 = 2*col + do 71 js = col+1 ,col2 +- call dtrsl(wn,m2,col,wn(1,js),11,info) ++ call dtrtrs('U', 'T', 'N', col, 1, wn, m2, wn(1,js), col, info) + 71 continue + + c Form S'AA'S*theta + (L^-1(-L_a'+R_z'))'L^-1(-L_a'+R_z') in the +@@ -2158,7 +2158,7 @@ c upper triangle of (2,2) block of wn. + + c Cholesky factorization of (2,2) block of wn. + +- call dpofa(wn(col+1,col+1),m2,col,info) ++ call dpotrf('U', col, wn(col+1,col+1), m2, info) + if (info .ne. 0) then + info = -2 + return +@@ -2227,7 +2227,7 @@ c store T in the upper triangle of the array wt. + c Cholesky factorize T to J*J' with + c J' stored in the upper triangle of wt. + +- call dpofa(wt,m,col,info) ++ call dpotrf('U', col, wt, m, info) + if (info .ne. 0) then + info = -3 + endif +@@ -3208,12 +3208,12 @@ c Compute wv:=K^(-1)wv. + + m2 = 2*m + col2 = 2*col +- call dtrsl(wn,m2,col2,wv,11,info) ++ call dtrtrs('U', 'T', 'N', col2, 1, wn, m2, wv, col2, info) + if (info .ne. 0) return + do 25 i = 1, col + wv(i) = -wv(i) + 25 continue +- call dtrsl(wn,m2,col2,wv,01,info) ++ call dtrtrs('U', 'N', 'N', col2, 1, wn, m2, wv, col2, info) + if (info .ne. 0) return + + c Compute d = (1/theta)d + (1/theta**2)Z'W wv. diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..cd4d11e --- /dev/null +++ b/debian/patches/series @@ -0,0 +1,6 @@ +replace-linpack-with-lapack.patch +silence.patch +0003-Prevent-bound-violation.patch +0004-Fix-NaN-propagation.patch +0005-Disable-printing-of-time.patch +0006-Stop-generating-iteration-log-files.patch diff --git a/debian/patches/silence.patch b/debian/patches/silence.patch new file mode 100644 index 0000000..7d34a63 --- /dev/null +++ b/debian/patches/silence.patch @@ -0,0 +1,43 @@ +From: Gard Spreemann <gspr@nonempty.org> +Date: Thu, 30 Jul 2020 09:57:45 +0200 +Subject: silence + +The library's documentation indicates that it will only write out +messages when the iprint flag is greater than zero. There are two +places where writing still happens unconditionally, which this patch +fixes. + +A similar patch was also applied by the SciPy project (see their issue +3238). +--- + lbfgsb.f | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +diff --git a/lbfgsb.f b/lbfgsb.f +index 54fd1f9..008370d 100644 +--- a/lbfgsb.f ++++ b/lbfgsb.f +@@ -2550,7 +2550,9 @@ c Determine the maximum step length. + if (gd .ge. zero) then + c the directional derivative >=0. + c Line search is impossible. +- write(6,*)' ascent direction in projection gd = ', gd ++ if (iprint .ge. 0) then ++ write(6,*)' ascent direction in projection gd = ', gd ++ endif + info = -4 + return + endif +@@ -3279,8 +3281,10 @@ c + 55 continue + if ( dd_p .gt.zero ) then + call dcopy( n, xp, 1, x, 1 ) +- write(6,*) ' Positive dir derivative in projection ' +- write(6,*) ' Using the backtracking step ' ++ if (iprint .ge. 0) then ++ write(6,*) ' Positive dir derivative in projection ' ++ write(6,*) ' Using the backtracking step ' ++ endif + else + go to 911 + endif diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..a706e04 --- /dev/null +++ b/debian/rules @@ -0,0 +1,52 @@ +#!/usr/bin/make -f + +SONAME=liblbfgsb.so.0 + +export DEB_BUILD_MAINT_OPTIONS = hardening=+all +include /usr/share/dpkg/buildflags.mk + +%: + dh $@ + +build/%.o: %.f + gfortran $(FCFLAGS) -fPIC -o $@ -c $< + +build/liblbfgsb.so: build/lbfgsb.o build/timer.o + gfortran $(FCFLAGS) -shared $(LDFLAGS) -Wl,-soname,$(SONAME) \ + -o build/$(SONAME) $^ -lblas -llapack + ln -s $(SONAME) $@ + +build/liblbfgsb.a: build/lbfgsb.o build/timer.o + ar cr $@ $^ + +build/lbfgsb-examples_driver1_77: driver1.f build/liblbfgsb.so + gfortran $(FCFLAGS) $(LDFLAGS) -o $@ $< -llbfgsb -Lbuild + +build/lbfgsb-examples_driver1_90: driver1.f90 build/liblbfgsb.so + gfortran $(FCFLAGS) $(LDFLAGS) -o $@ $< -llbfgsb -Lbuild + +build/lbfgsb-examples_driver2_77: driver2.f build/liblbfgsb.so + gfortran $(FCFLAGS) $(LDFLAGS) -o $@ $< -llbfgsb -Lbuild + +build/lbfgsb-examples_driver2_90: driver2.f90 build/liblbfgsb.so + gfortran $(FCFLAGS) $(LDFLAGS) -o $@ $< -llbfgsb -Lbuild + +build/lbfgsb-examples_driver3_77: driver3.f build/liblbfgsb.so + gfortran $(FCFLAGS) $(LDFLAGS) -o $@ $< -llbfgsb -Lbuild + +build/lbfgsb-examples_driver3_90: driver3.f90 build/liblbfgsb.so + gfortran $(FCFLAGS) $(LDFLAGS) -o $@ $< -llbfgsb -Lbuild + +execute_before_dh_auto_build: + mkdir -p build + +override_dh_auto_build: build/liblbfgsb.so build/liblbfgsb.a \ + build/lbfgsb-examples_driver1_77 build/lbfgsb-examples_driver1_90 \ + build/lbfgsb-examples_driver2_77 build/lbfgsb-examples_driver2_90 \ + build/lbfgsb-examples_driver3_77 build/lbfgsb-examples_driver3_90 + +execute_before_dh_auto_clean: + rm -rf build + +override_dh_compress: + dh_compress -X.pdf -X.f -X.f90 -Xoutput_ diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/tests/control b/debian/tests/control new file mode 100644 index 0000000..05b8cfd --- /dev/null +++ b/debian/tests/control @@ -0,0 +1,7 @@ +Tests: tests.sh +Depends: gfortran, libblas-dev, liblapack-dev, liblbfgsb-dev, shunit2 +Restrictions: allow-stderr + +Tests: examples-superficial-tests.sh +Depends: liblbfgsb-examples, shunit2 +Restrictions: allow-stderr, superficial
\ No newline at end of file diff --git a/debian/tests/examples-superficial-tests.sh b/debian/tests/examples-superficial-tests.sh new file mode 100755 index 0000000..a420715 --- /dev/null +++ b/debian/tests/examples-superficial-tests.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +names="/usr/bin/lbfgsb-examples_driver1_77 \ + /usr/bin/lbfgsb-examples_driver1_90 \ + /usr/bin/lbfgsb-examples_driver2_77 \ + /usr/bin/lbfgsb-examples_driver2_90 \ + /usr/bin/lbfgsb-examples_driver3_77 \ + /usr/bin/lbfgsb-examples_driver3_90" + +testExamplesSuperficially() { + set -u + + cd $AUTOPKGTEST_TMP + + for name in $names + do + set -x + $name + ret=$? + set +x + assertEquals 0 $ret + done +} + +. shunit2 diff --git a/debian/tests/test1.f90 b/debian/tests/test1.f90 new file mode 100644 index 0000000..a70f9ef --- /dev/null +++ b/debian/tests/test1.f90 @@ -0,0 +1,106 @@ +! Simple self-test based on the driver*.f90 examples. Returns 1 in +! the incorrect value is reached. Only other change is the removal of +! long headers and comments. +! +! Copyright Ciyou Zhu, Richard Byrd, Jorge Nocedal, Jose Luis +! Morales. 3-clause BSD license. + + program driver + + implicit none +! + integer, parameter :: n = 25, m = 5, iprint = 1 + integer, parameter :: dp = kind(1.0d0) + real(dp), parameter :: factr = 1.0d+7, pgtol = 1.0d-5 +! + character(len=60) :: task, csave + logical :: lsave(4) + integer :: isave(44) + real(dp) :: f + real(dp) :: dsave(29) + integer, allocatable :: nbd(:), iwa(:) + real(dp), allocatable :: x(:), l(:), u(:), g(:), wa(:) + +! Declare a few additional variables for this sample problem + + real(dp) :: t1, t2 + integer :: i + +! Allocate dynamic arrays + + allocate ( nbd(n), x(n), l(n), u(n), g(n) ) + allocate ( iwa(3*n) ) + allocate ( wa(2*m*n + 5*n + 11*m*m + 8*m) ) +! + do 10 i=1, n, 2 + nbd(i) = 2 + l(i) = 1.0d0 + u(i) = 1.0d2 + 10 continue + +! Next set bounds on the even-numbered variables. + + do 12 i=2, n, 2 + nbd(i) = 2 + l(i) = -1.0d2 + u(i) = 1.0d2 + 12 continue + +! We now define the starting point. + + do 14 i=1, n + x(i) = 3.0d0 + 14 continue + + write (6,16) + 16 format(/,5x, 'Solving sample problem.', & + /,5x, ' (f = 0.0 at the optimal solution.)',/) + +! We start the iteration by initializing task. + + task = 'START' + +! The beginning of the loop + + do while(task(1:2).eq.'FG'.or.task.eq.'NEW_X'.or. & + task.eq.'START') + +! This is the call to the L-BFGS-B code. + + call setulb ( n, m, x, l, u, nbd, f, g, factr, pgtol, & + wa, iwa, task, iprint,& + csave, lsave, isave, dsave ) + + if (task(1:2) .eq. 'FG') then + + f=.25d0*( x(1)-1.d0 )**2 + do 20 i=2, n + f = f + ( x(i)-x(i-1 )**2 )**2 + 20 continue + f = 4.d0*f + +! Compute gradient g for the sample problem. + + t1 = x(2) - x(1)**2 + g(1) = 2.d0*(x(1) - 1.d0) - 1.6d1*x(1)*t1 + do 22 i=2, n-1 + t2 = t1 + t1 = x(i+1) - x(i)**2 + g(i) = 8.d0*t2 - 1.6d1*x(i)*t1 + 22 continue + g(n) = 8.d0*t1 + + end if + end do + if (abs(f) < 1e-6) then + stop 0 + else + stop 1 + end if + + +! end of loop do while + + + end program driver + diff --git a/debian/tests/test2.f90 b/debian/tests/test2.f90 new file mode 100644 index 0000000..23c80ba --- /dev/null +++ b/debian/tests/test2.f90 @@ -0,0 +1,139 @@ +! Simple self-test based on the driver*.f90 examples. Returns 1 in +! the incorrect value is reached. Only other change is the removal of +! long headers and comments. +! +! Copyright Ciyou Zhu, Richard Byrd, Jorge Nocedal, Jose Luis +! Morales. 3-clause BSD license. + + program driver + + + implicit none + + + integer, parameter :: n = 25, m = 5, iprint = -1 + integer, parameter :: dp = kind(1.0d0) + real(dp), parameter :: factr = 0.0d0, pgtol = 0.0d0 + + character(len=60) :: task, csave + logical :: lsave(4) + integer :: isave(44) + real(dp) :: f + real(dp) :: dsave(29) + integer, allocatable :: nbd(:), iwa(:) + real(dp), allocatable :: x(:), l(:), u(:), g(:), wa(:) +! + real(dp) :: t1, t2 + integer :: i + + allocate ( nbd(n), x(n), l(n), u(n), g(n) ) + allocate ( iwa(3*n) ) + allocate ( wa(2*m*n + 5*n + 11*m*m + 8*m) ) + + do 10 i=1, n,2 + nbd(i)=2 + l(i)=1.0d0 + u(i)=1.0d2 + 10 continue + +! Next set bounds on the even numbered variables. + + do 12 i=2, n,2 + nbd(i)=2 + l(i)=-1.0d2 + u(i)=1.0d2 + 12 continue + +! We now define the starting point. + + do 14 i=1, n + x(i)=3.0d0 + 14 continue + +! We now write the heading of the output. + + write (6,16) + 16 format(/,5x, 'Solving sample problem.', & + /,5x, ' (f = 0.0 at the optimal solution.)',/) + + +! We start the iteration by initializing task. +! + task = 'START' + +! ------- the beginning of the loop ---------- + + do while( task(1:2).eq.'FG'.or.task.eq.'NEW_X'.or. & + task.eq.'START') + +! This is the call to the L-BFGS-B code. + + call setulb(n,m,x,l,u,nbd,f,g,factr,pgtol,wa,iwa,task,iprint, & + csave,lsave,isave,dsave) + + if (task(1:2) .eq. 'FG') then + +! the minimization routine has returned to request the +! function f and gradient g values at the current x. + +! Compute function value f for the sample problem. + + f =.25d0*(x(1) - 1.d0)**2 + do 20 i=2,n + f = f + (x(i) - x(i-1)**2)**2 + 20 continue + f = 4.d0*f + +! Compute gradient g for the sample problem. + + t1 = x(2) - x(1)**2 + g(1) = 2.d0*(x(1) - 1.d0) - 1.6d1*x(1)*t1 + do 22 i= 2,n-1 + t2 = t1 + t1 = x(i+1) - x(i)**2 + g(i) = 8.d0*t2 - 1.6d1*x(i)*t1 + 22 continue + g(n)=8.d0*t1 +! + else +! + if (task(1:5) .eq. 'NEW_X') then +! + + if (isave(34) .ge. 99) & + task='STOP: TOTAL NO. of f AND g EVALUATIONS EXCEEDS LIMIT' + + if (dsave(13) .le. 1.d-10*(1.0d0 + abs(f))) & + task='STOP: THE PROJECTED GRADIENT IS SUFFICIENTLY SMALL' + + + write (6,'(2(a,i5,4x),a,1p,d12.5,4x,a,1p,d12.5)') 'Iterate' & + , isave(30),'nfg =',isave(34),'f =',f,'|proj g| =',dsave(13) + +! If the run is to be terminated, we print also the information +! contained in task as well as the final value of x. + + if (task(1:4) .eq. 'STOP') then + write (6,*) task + write (6,*) 'Final X=' + write (6,'((1x,1p, 6(1x,d11.4)))') (x(i),i = 1,n) + end if + + end if + end if + + end do + + if (abs(f) < 1e-6) then + stop 0 + else + stop 1 + end if +! ---------- the end of the loop ------------- + +! If task is neither FG nor NEW_X we terminate execution. + + end program driver + +!======================= The end of driver2 ============================ + diff --git a/debian/tests/tests.sh b/debian/tests/tests.sh new file mode 100755 index 0000000..9be2ae1 --- /dev/null +++ b/debian/tests/tests.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +names="test1 test2" + +oneTimeSetUp() { + set -u + cp debian/tests/test*.f90 $AUTOPKGTEST_TMP +} + +testSO() { + cwd=$(pwd) + cd $AUTOPKGTEST_TMP + for name in $names + do + echo "Building." + set -x + gfortran -O2 -o $name $name.f90 -llbfgsb + ret=$? + set +x + assertEquals 0 $ret + + echo "Running." + ./$name + ret=$? + assertEquals 0 $ret + done + cd $cwd +} + +testStatic() { + cwd=$(pwd) + cd $AUTOPKGTEST_TMP + for name in $names + do + echo "Building (statically linked)." + set -x + gfortran $name.f90 -O2 -static -llbfgsb -llapack -lblas -lgfortran -o $name-static + ret=$? + set +x + assertEquals 0 $ret + + echo "Running (statically linked)." + ./$name-static + ret=$? + assertEquals 0 $ret + done + cd $cwd +} + +. shunit2 diff --git a/debian/upstream/metadata b/debian/upstream/metadata new file mode 100644 index 0000000..d39dea8 --- /dev/null +++ b/debian/upstream/metadata @@ -0,0 +1,24 @@ +Reference: +- Title: A Limited Memory Algorithm for Bound Constrained Optimization + Author: R. H. Byrd, P. Lu and J. Nocedal + Journal: SIAM Journal on Scientific and Statistical Computing + Year: 1995 + Volume: 16 + Number: 5 + Pages: 1190-1208 +- Title: 'L-BFGS-B: Algorithm 778: L-BFGS-B, FORTRAN routines for large scale bound + constrained optimization' + Author: C. Zhu, R. H. Byrd and J. Nocedal + Journal: ACM Transactions on Mathematical Software + Year: 1997 + Volume: 23 + Number: 4 + Pages: 550-560 +- Title: 'Remark on Algorithm 778: L-BFGS-B, FORTRAN routines for large scale bound + constrained optimization' + Author: J.L. Morales and J. Nocedal + Journal: ACM Transactions on Mathematical Software + Year: 2011 + Volume: 38 + Number: 1 + Pages: 1-4 diff --git a/debian/watch b/debian/watch new file mode 100644 index 0000000..db539dc --- /dev/null +++ b/debian/watch @@ -0,0 +1,5 @@ +version=3 + +opts="dversionmangle=s/\+dfsg\.\d+$//,filenamemangle=s/\S+\/v?(\S+)\.tar\.gz/lbfgsb-$1\.tar\.gz/" \ + http://users.iems.northwestern.edu/~nocedal/lbfgsb.html \ + Software/Lbfgsb\.(.+)\.tar\.(?:bz2|gz|xz)
\ No newline at end of file |