[SciPy-user] Re: SciPy-user Digest, Vol 22, Issue 3

Steve Schmerler elcorto at gmx.net
Tue Jun 28 07:23:45 CDT 2005

```Hi,

or you can use mpfit for constrained optimization which is a (quite
fast) pure Python implementation of MINPACK's LMFIT routine.

http://cars9.uchicago.edu/software/python/index.html -> mpfit.py

http://www.scipy.org/mailinglists/mailman?fn=scipy-user/2005-February/004104.html

I did some little bugfixes in this code (see attachment) and used it for
some time without problems.

cheers,
steve

Christian Kristukat wrote:
> aurelien.gourrier at free.fr wrote:
>
>> Hi all,
>>
>> Can anyone tell me if there is a possibility to use constraints on the
>> leastsq
>> method ? I need to do some bounded minimization of gaussians or
>> lorentzians on
>> 1-D data and couldn't find any way out so far...
>
>
> One method I'm using to add simple bounds is to map the parameters to
> some limits before calculating the residuals.
>
> def residuals(a):
>     # mapping +/-inf to +/-1
>     t = a/(abs(a)+1.0)
>
>     # amin/amax are 1D arrays containing the bounds
>     # map -1/+1 to amin/amax
>     a = (amin+amax)/2.0+(amax-amin)/2.0*t
>
>     # avealuate the function
>     newy = func(a)
>
>     return  y-newy
>
> Regards, Christian
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mpfit.py
Type: text/x-python
Size: 91220 bytes
Desc: not available
Url : http://www.scipy.net/pipermail/scipy-user/attachments/20050628/0f8a11f9/mpfit-0001.py
```