[SciPy-user] Scipy optimize fmin_l_bfgs_b gives me an obscure error

998 views
Skip to first unread message

Isaul Vargas

unread,
Jul 8, 2008, 4:31:51 PM7/8/08
to scipy...@scipy.org
I am using Scipy 0.6 on windows vista with python 2.5.2 (same thing happens in my linux setup), and when I use the function fmin_l_bfgs_b, I get this obscure error:

ValueError: failed to initialize intent(inout) array -- input not fortran contiguous

This is a part of the traceback within the function fmin_l_bfgs_b:
 197         _lbfgsb.setulb(m, x, low_bnd, upper_bnd, nbd, f, g, factr,
 198                        pgtol, wa, iwa, task, iprint, csave, lsave,
 199                        isave, dsave)


I have looked at the variables involved and they are all 1d arrays, so I don't see how fortran ordering would apply.

Any ideas on how to fix this?

Nils Wagner

unread,
Jul 8, 2008, 5:37:12 PM7/8/08
to SciPy Users List
Please can you submit your example ?

Nils
_______________________________________________
SciPy-user mailing list
SciPy...@scipy.org
http://projects.scipy.org/mailman/listinfo/scipy-user

Isaul Vargas

unread,
Jul 9, 2008, 7:17:58 PM7/9/08
to scipy...@scipy.org
Here is how my function looks like:

xt =  scipy.optimize.fmin_l_bfgs_b(obj_grad_func, xcur, args = (b,h,Beta,R,wR,wh,muh, alpha_b, beta_b, BN, sp), maxfun = 1000)


the args are mostly arrays except for BN and SP which are dicts that contain various flags.

In the debugger, I tried the following:
xcur is a 1,3 array with the values 1,1,0.
I check the flags of xcur and I see it is not fortran contiguous.
I do a copy: xcur2 = xcur.copy('f')
and now I get this error message:
*** error: failed in converting 10th argument `wa' of _lbfgsb.setulb to C/Fortra
n array

There is no variable 'wa' in any of my functions, so I am not sure why this failing.

Also, how do I setup the bounds, I am not clear on how to set it. I have a list of upper bounds (an array of 3 values) and a list of lower bounds Not sure how to set them.




Nils Wagner

unread,
Jul 10, 2008, 2:06:43 AM7/10/08
to SciPy Users List

For lower and upper bounda:

bounds = [(2000.,2100.),(1800.,1850.),(1600.,1630.)]
x_lbl,f,d = optimize.fmin_l_bfgs_b(func1, x0, fprime=None,
args=(), approx_grad=1, bounds=bounds)

Nils Wagner

unread,
Jul 10, 2008, 2:10:59 AM7/10/08
to SciPy Users List
On Wed, 9 Jul 2008 19:17:58 -0400
"Isaul Vargas" <isa...@gmail.com> wrote:
> Here is how my function looks like:
>
> xt = scipy.optimize.fmin_l_bfgs_b(obj_grad_func, xcur,
>args =
> (b,h,Beta,R,wR,wh,muh, alpha_b, beta_b, BN, sp), maxfun
>= 1000)
>
>
> the args are mostly arrays except for BN and SP which
>are dicts that contain
> various flags.
>
> In the debugger, I tried the following:
> xcur is a 1,3 array with the values 1,1,0.
> I check the flags of xcur and I see it is not fortran
>contiguous.
> I do a copy: xcur2 = xcur.copy('f')
> and now I get this error message:
> *** error: failed in converting 10th argument `wa' of
>_lbfgsb.setulb to
> C/Fortra
> n array
>
You can find the corresponding file (lbfgsb.pyf) in

scipy/scipy/optimize/lbfgsb


! -*- f90 -*-
python module _lbfgsb ! in
interface ! in :_lbfgsb
subroutine
setulb(n,m,x,l,u,nbd,f,g,factr,pgtol,wa,iwa,task,iprint,csave,lsave,isave,dsave)
! in :lbfsgb:routines.f
integer
intent(in),optional,check(len(x)>=n),depend(x) :: n=len(x)
integer intent(in) :: m
double precision dimension(n),intent(inout)
:: x
double precision
dimension(n),depend(n),intent(in) :: l
double precision
dimension(n),depend(n),intent(in) :: u
integer dimension(n),depend(n),intent(in) ::
nbd
double precision intent(inout) :: f
double precision
dimension(n),depend(n),intent(inout) :: g
double precision intent(in) :: factr
double precision intent(in) :: pgtol
double precision
dimension(2*m*n+4*n+12*m*m+12*m),depend(n,m),intent(inout)
:: wa
integer dimension(3 *
n),depend(n),intent(inout) :: iwa
character*60 intent(inout) :: task
integer intent(in) :: iprint
character*60 intent(inout) :: csave
logical dimension(4),intent(inout) :: lsave
integer dimension(44),intent(inout) :: isave
double precision dimension(29),intent(inout)
:: dsave
end subroutine setulb
end interface
end python module _lbfgsb

Nils

> There is no variable 'wa' in any of my functions, so I
>am not sure why this
> failing.
>
> Also, how do I setup the bounds, I am not clear on how
>to set it. I have a
> list of upper bounds (an array of 3 values) and a list
>of lower bounds Not
> sure how to set them.

Reply all
Reply to author
Forward
0 new messages