scipy.optimize.lbfgsb help please!!!

M

mclaugb

Does anyone out there have a piece of code that demonstrates the use of the
lbfgsb multivariate, bounded solver in the scipy.optimize toolkit? An
example would get me started because my code below does not seem to work.
Thanks alot,
Bryan


I have tried to use the LBFGSB optimisation algorithm with these parameters:

xstart = [20,-20]


x, f, d = lbfgsb.fmin_l_bfgs_b(Permmin, x0, Jacobi, params, 0,
[(0,100),(0,-50)] , 10, 1e7, 1e-5, 1e-8, -1, 500)

I am getting this error:

" x, f, d = lbfgsb.fmin_l_bfgs_b(Permmin, x0, Jacobi, params, 0,
[(.001,100),(-50,-.001)] , 10, 1e7, 1e-5, 1e-8, -1, 500)
File "C:\Python24\lib\site-packages\scipy\optimize\lbfgsb.py", line 197,
in fmin_l_bfgs_b
isave, dsave)
ValueError: failed to initialize intent(inout) array -- expected elsize=8
but got 4 -- input 'l' not compatible to 'd'
"

Permmin is a function that simply returns a vector array [xmin, ymin]

Jacobi returns an array [[A,B],[C,D]] which is the 2x2 Jacobi matrix

The rest of the parameters seem okay...
 
R

Robert Kern

mclaugb said:
Does anyone out there have a piece of code that demonstrates the use of the
lbfgsb multivariate, bounded solver in the scipy.optimize toolkit? An
example would get me started because my code below does not seem to work.

You will probably get better/faster/more answers on the scipy-user mailing list.

http://www.scipy.org/Mailing_Lists
Permmin is a function that simply returns a vector array [xmin, ymin]

This is your problem. The function to minimize must return a scalar, not a
vector. This is not a multi-objective optimizer.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 
M

mclaugb

Just to clarify--this is a multivariate algorithm. I changed the function
Permmin to simply take the absolute value of (xmin, ymin) so that it returns
one value. Unfortunately, the error remains--it still returns this error:

" x, f, d = lbfgsb.fmin_l_bfgs_b(Permmin, x0, Jacobi, params,
bounds=[(.001,100),(-50,-.001)] , maxfun=500)
File "C:\Python24\lib\site-packages\scipy\optimize\lbfgsb.py", line 197,
in fmin_l_bfgs_b
isave, dsave)
ValueError: failed to initialize intent(inout) array -- expected elsize=8
but got 4 -- input 'l' not compatible to 'd'"



Robert Kern said:
mclaugb said:
Does anyone out there have a piece of code that demonstrates the use of
the
lbfgsb multivariate, bounded solver in the scipy.optimize toolkit? An
example would get me started because my code below does not seem to work.

You will probably get better/faster/more answers on the scipy-user mailing
list.

http://www.scipy.org/Mailing_Lists
Permmin is a function that simply returns a vector array [xmin, ymin]

This is your problem. The function to minimize must return a scalar, not a
vector. This is not a multi-objective optimizer.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma
that is made terrible by our own mad attempt to interpret it as though it
had
an underlying truth."
-- Umberto Eco
 
R

Robert Kern

mclaugb said:
Just to clarify--this is a multivariate algorithm.

Yes. That means that the domain of the objective function is multivariate. The
image is still a scalar.

RR^n -f-> RR
I changed the function
Permmin to simply take the absolute value of (xmin, ymin) so that it returns
one value. Unfortunately, the error remains--it still returns this error:

Let's take this to the scipy-user list. Can you reduce your code down to a
small, complete example that demonstrates the problem? Without more information,
we can't help you. Also, we'll need to know what version of scipy you are using.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 
R

Robert Kern

mclaugb said:
" x, f, d = lbfgsb.fmin_l_bfgs_b(Permmin, x0, Jacobi, params,
bounds=[(.001,100),(-50,-.001)] , maxfun=500)
File "C:\Python24\lib\site-packages\scipy\optimize\lbfgsb.py", line 197,
in fmin_l_bfgs_b
isave, dsave)
ValueError: failed to initialize intent(inout) array -- expected elsize=8
but got 4 -- input 'l' not compatible to 'd'"

And also tell us your platform. I suspect this is a 64-bit problem.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top