[SciPy-User] Problem using optimize.fmin_slsqp
Tue Nov 30 10:01:03 CST 2010
2010/11/29 Paweł Kwaśniewski <email@example.com>:
> Sorry, I didn't have time during the weekend to sit and write this down, but
> I tried several things and I think I'm a bit closer to solving my problem.
> Skipper, how should I provide the code and data? I don't want to put
> everything into e-mail text and flood everyone with my (not so nice) code.
> Is it OK to send an attached zip with the files?
How long is your code? Can you boil it down to a small example that
replicates the problem? With a subsample of the data or a random
> So, I managed to avoid the error I had before by giving additional input to
> optimize.fmin_slsqp, namely - providing epsilon for the approximation of the
> Jacobian matrix and/or the approximation of first derivative of the
> function. I'm not sure how to choose an optimal value for it, so I just
> tried several, with different results. Later, I checked what is the default
> value for epsilon in this function (I found the source code for fmin_slsqp
> and printed this and that...) - it's very small: 1.49e-8. I was trying
> something in the range of 1 or 10. Now if I left the default value or gave
> for example 1e-3, I got this:
> epsilon = 1.00e-03
> NIT FC OBJFUN GNORM
> python: malloc.c:4631: _int_malloc: Assertion `(unsigned long)(size) >=
> (unsigned long)(nb)' failed.
> So I got a different error, clearly something with memory allocation, if I
> understand well. I suspect the problem may be caused by the fact that the
> domain of my fitting function is in the range of 1e8. Giving very small
> epsilon (used as dx to calculate the derivative) may raise some kind of
> problems related to finite precision of the machine. Since the Jacobian is
> not calculated during my fit (I put a print statement in the approx_jacobian
> function, the file is in
> /usr/lib/python2.6/site-packages/scipy/optimize/slsqp.py - no output from
> there), it's the approx_fprime() which makes the problem (defined in
> /usr/lib/python2.6/site-packages/scipy/optimize/optimize.py - checked that
> with print -it works).
> My conclusion is that it's a bug (unhandled exception I guess) of the
> approx_fprime() function. I also noticed, that when I give the error
> generating value of epsilon and run the code for the first time with it, it
> gives the >*** glibc detected *** python: double free or corruption (!prev):
> 0x08df6240 *** error. If I try again to run the code with the same values it
> spits out:
>>python: malloc.c:4631: _int_malloc: Assertion `(unsigned long)(size) >=
>> (unsigned long)(nb)' failed.
> This behavior I don't understand.
I can't see why the approx_fprime itself should cause a seg fault. As
you mentioned, it could be a scaling issue (?), but regardless I don't
think this should happen.
More information about the SciPy-User