[SciPy-dev] f2py vector valued functions and optimize.fmin_slsqp

Leon Adams skorpio11@gmail....
Sat May 16 11:29:33 CDT 2009


On Sat, May 16, 2009 at 11:32 AM, Rob Falck <robfalck@gmail.com> wrote:

> SLSQP is intended to optimize scalar valued functions.  If your function is
> vector valued you need to wrap it in a way such that a single scalar value
> (your performance index) is returned.
>
> On Sat, May 16, 2009 at 2:07 AM, Leon Adams <skorpio11@gmail.com> wrote:
>
>> Hi...
>>
>> I am experiencing some difficulties arriving at a soln for my optimization
>> problem.
>>
>> Background:
>>
>> My problem is cast as a minimizer problem but is very computer intense
>> (lots of loops).
>> My design soln was to wrap the looping parts in FORTRAN using f2py, use
>> python as a steering program
>> and optimize.fmin_slsqp as the optimizer.  Everything seems to work well
>> for scalar valued functions but not for vector valued functions involving
>> arrays.
>> Anytime an array is involved SLSQP returns with a success exit status [0]
>> without updating the input vector. That is no change is being made to the
>> input parameters.
>>
>> My question is: is it possible to wrap a vector valued fortran function
>> and still use SLSQP?
>>
>> Thanks in advance
>>
>> --
>> Leon Adams
>>
>> _______________________________________________
>> Scipy-dev mailing list
>> Scipy-dev@scipy.org
>> http://mail.scipy.org/mailman/listinfo/scipy-dev
>>
>>
>
>
> --
> - Rob Falck
>
>
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev
>
>
Thanks for the response.

I have wrapped the function to return the performance index. Don't know if
this is another symptom or the problem itself, but the soln terminates with:

Optimization terminated successfully.    (Exit mode 0)
            Current function value: 6.45723021956
            Iterations: 1
            Function evaluations: 20
            Gradient evaluations: 1

If the generating routine for the performance index is coded in straight
python I get:

Optimization terminated successfully.    (Exit mode 0)
            Current function value: 0.858946186765
            Iterations: 12
            Function evaluations: 245
            Gradient evaluations: 12

For some reason, the iterations stops at 1 when I try to use the f2py
imported libraries. Is it possible that it is getting hung up on the
Gradient evaluations??

-- 
Leon Adams
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-dev/attachments/20090516/27bcd72d/attachment.html 


More information about the Scipy-dev mailing list