[SciPy-User] Weird error in fmin_l_bfgs_b
Jose Gomez-Dans
jgomezdans at gmail.com
Fri Jul 1 06:36:48 EDT 2011
Hi,
I'm getting an error in scipy.optimize.fmin_l_bfgs_b, apparently related to
the fortran wrapper. This is strange, because exactly the same problem works
well with the TNC solver. I have a function that returns both a scalar value
(that will be minimised) and the derivative of the function at that point.
The error in the L-BFG-S solver is
File "/usr/lib/python2.7/dist-packages/scipy/optimize/lbfgsb.py", line 181,
in fmin_l_bfgs_b
isave, dsave)
ValueError: failed to initialize intent(inout) array -- input not fortran
contiguous
My code looks like this:
# x0 is the starting point, a 1d array
>>> solution, x, info = scipy.optimize.fmin_tnc( cost_function, x0,
args=([operators]), bounds=bounds )
# Using fmin_tnc works well, solution is what I expect it to be
>> solution, cost, information = scipy.optimize.fmin_l_bfgs_b (
cost_function, solution, bounds=bounds, args=[ operators ], iprint=101 )
2011-07-01 11:34:24,703 - eoldas.Model - INFO - 46 days, 46 quantised days
tnc: Version 1.3, (c) 2002-2003, Jean-Sebastien Roy (js at jeannot.org)
tnc: RCS ID: @(#) $Jeannot: tnc.c,v 1.205 2005/01/28 18:27:31 js Exp $
NIT NF F GTG
0 1 1.988301629303336E+02 8.17118991E+06
tnc: fscale = 0.000249879
1 5 1.338514420154698E+01 1.82689516E+04
tnc: fscale = 0.00528464
2 9 9.476573219561992E+00 2.21390020E+04
3 19 6.684083971679802E+00 3.88897225E+03
4 69 6.274247682836059E+00 2.43671753E+03
tnc: |fn-fn-1] = 4.5037e-13 -> convergence
5 120 6.274247682835608E+00 2.43671753E+03
tnc: Converged (|f_n-f_(n-1)| ~= 0)
RUNNING THE L-BFGS-B CODE
* * *
Machine precision = 1.084D-19
N = 46 M = 10
L = -2.0000D-01 -2.0000D-01 -2.0000D-01 -2.0000D-01 -2.0000D-01 -2.0000D-01
-2.0000D-01 -2.0000D-01 -2.0000D-01 -2.0000D-01 -2.0000D-01 -2.0000D-01
-2.0000D-01 -2.0000D-01 -2.0000D-01 -2.0000D-01 -2.0000D-01 -2.0000D-01
-2.0000D-01 -2.0000D-01 -2.0000D-01 -2.0000D-01 -2.0000D-01 -2.0000D-01
-2.0000D-01 -2.0000D-01 -2.0000D-01 -2.0000D-01 -2.0000D-01 -2.0000D-01
-2.0000D-01 -2.0000D-01 -2.0000D-01 -2.0000D-01 -2.0000D-01 -2.0000D-01
-2.0000D-01 -2.0000D-01 -2.0000D-01 -2.0000D-01 -2.0000D-01 -2.0000D-01
-2.0000D-01 -2.0000D-01 -2.0000D-01 -2.0000D-01
X0 = 5.6013D-02 1.1717D-01 1.9201D-01 2.7557D-01 3.7013D-01 4.5702D-01
5.3491D-01 6.0661D-01 6.7624D-01 7.4649D-01 8.0318D-01 8.5203D-01
8.8633D-01 9.0102D-01 8.9914D-01 8.7521D-01 8.2816D-01 7.6529D-01
7.0559D-01 6.5371D-01 6.0520D-01 5.5814D-01 5.0991D-01 4.4783D-01
3.7790D-01 3.0041D-01 2.1894D-01 1.5147D-01 1.0832D-01 8.3926D-02
6.6473D-02 4.8621D-02 3.2567D-02 2.0086D-02 1.0881D-02 2.4890D-03
8.8000D-04 -4.2729D-03 -4.6658D-03 -5.5940D-03 -4.1690D-03 -1.2577D-02
-2.2529D-02 -2.9114D-02 -1.5938D-02 1.9755D-02
U = 1.2000D+00 1.2000D+00 1.2000D+00 1.2000D+00 1.2000D+00 1.2000D+00
1.2000D+00 1.2000D+00 1.2000D+00 1.2000D+00 1.2000D+00 1.2000D+00
1.2000D+00 1.2000D+00 1.2000D+00 1.2000D+00 1.2000D+00 1.2000D+00
1.2000D+00 1.2000D+00 1.2000D+00 1.2000D+00 1.2000D+00 1.2000D+00
1.2000D+00 1.2000D+00 1.2000D+00 1.2000D+00 1.2000D+00 1.2000D+00
1.2000D+00 1.2000D+00 1.2000D+00 1.2000D+00 1.2000D+00 1.2000D+00
1.2000D+00 1.2000D+00 1.2000D+00 1.2000D+00 1.2000D+00 1.2000D+00
1.2000D+00 1.2000D+00 1.2000D+00 1.2000D+00
At X0 0 variables are exactly at the bounds
Traceback (most recent call last):
File "example_identity.py", line 199, in <module>
main ( sys.argv )
File "example_identity.py", line 166, in main
solution, cost, information = scipy.optimize.fmin_l_bfgs_b (
cost_function, solution, bounds=bounds, args=[ operators ], iprint=101 )
File "/usr/lib/python2.7/dist-packages/scipy/optimize/lbfgsb.py", line
181, in fmin_l_bfgs_b
isave, dsave)
ValueError: failed to initialize intent(inout) array -- input not fortran
contiguous
Any clues of where to look for issues?
Thanks!
jose
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20110701/4449b33c/attachment.html>
More information about the SciPy-User
mailing list