[SciPy-user] scipy.optimise.lbfgsb /bounded optimization help

mclaugb mclaughlinbryan at yahoo.com
Sat Jan 27 16:36:36 CST 2007


I can make the function map to a scalar--though i thought multivariate 
algorithms used vector differentials between iterations.  Note, the error 
below is the same regardless of whether the function provides a scalar or 
vector.

i seem to be receiving this error:

x, f, d = lbfgsb.fmin_l_bfgs_b(Permmin, x0, approx_grad=1,args=params, 
bounds = [(.0001, 1000),(.0001, 1000)])
  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'
------------------------------
Here is the code:

def Permmin(x0, params):
    #x0 is input real and imaginary permittivity guess values, params 
contain freq, S11 Measured Values
    S11Measured = params[1]
    Freq = params[0]
    BeadPerm = params[2]
    InnerRad = params[4]
    OuterRad = params[5]

    #HodgGaussNonCon returns real and imaginary values for S11
    S11 = HodgGaussNonCon.HodgGauss(BeadPerm,Freq ,InnerRad,OuterRad,1e9,x0)
    S11diff = array([ S11.real - S11Measured.real, S11.imag - 
S11Measured.imag ]);
    return abs(S11diff)

xstart = [20,20]

#test values at 50Mhz
GammaMeas = .999964 -0.006289j

x0 = xstart

Freq = 50e6
BeadPerm = 2.08 +.00832j
Inner = .125/2
Outer = .2032

params = [GammaMeas, Freq, BeadPerm, Inner, Outer]

x, f, d = lbfgsb.fmin_l_bfgs_b(Permmin, x0, approx_grad=1,args=params, 
bounds = [(.0001, 1000),(.0001, 1000)])
--------------------------


"Robert Kern" <robert.kern at gmail.com> wrote in message 
news:45BBC662.6050202 at gmail.com...
> mclaugb wrote:
>> I have been using a Gauss-Newton algorithm but it is unconstrained and i
>> need a bounded, multivariate algorithm.
>>
>> Does anyone have any example code that uses the "lbfgsb" optimization
>> algorithm?  I have a function of two variables that is bounded to the
>> positive half-space and would like to use lbfgsb to minimize two 
>> variables.
>> i have tried to get it working for a 2 variable function case but have 
>> been
>> unsuccessful.  any example code would help me.
>
> You mean that your function f maps
>
>        f
>  RR^2 ---> RR^2
>
> ?
>
> Note that all of the minimizers in scipy (and even mpfit that you mention 
> below)
> only minimize functions that map to scalars; i.e.
>
>        f
>  RR^n ---> RR
>
> These are not multiobjective optimizers.
>
> Please clarify what you mean. Can you show us the code that you already 
> tried?
>
> -- 
> 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 





More information about the SciPy-user mailing list