[SciPy-User] constrained least square fitting using scipy.optimize.fmin_slsqp() function

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[SciPy-User] constrained least square fitting using scipy.optimize.fmin_slsqp() function

sudipta sinha
Hi All,

I am facing a problem for constrained linear least square fitting. In my case the matrix equation looks like [Y]nX1=[X]nXm[P]mX1, where Y and P are vectors and X is a matrix and n, m are dimension of the matrix. Further, there is a equality constraint on P which is Sum(P(i))=0.0. How do I proceed to solve that? Which function of python is suitable for this? I saw few of discussion on scipy.optimize.fmin_slsqp() function but the implementation of this function is not very straightforward. Therefore, I need your help. I am new in SCIPY. Please help me out in this regard.
_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: constrained least square fitting using scipy.optimize.fmin_slsqp() function

Jose Guzman
On 08/08/13 00:30, sudipta sinha wrote:
Hi All,

I am facing a problem for constrained linear least square fitting. In my case the matrix equation looks like [Y]nX1=[X]nXm[P]mX1, where Y and P are vectors and X is a matrix and n, m are dimension of the matrix. Further, there is a equality constraint on P which is Sum(P(i))=0.0. How do I proceed to solve that? Which function of python is suitable for this? I saw few of discussion on scipy.optimize.fmin_slsqp() function but the implementation of this function is not very straightforward. Therefore, I need your help. I am new in SCIPY. Please help me out in this regard.
_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Hi

Did you have a look to lmfit package (http://newville.github.io/lmfit-py/). I am trying some minimization with boundaries and constrains, and it seems that this is the way to go.  Do not know if somebody here has ever use it.

Best

Jose

-- 
Jose Guzman
http://www.ist.ac.at/~jguzman/

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: constrained least square fitting using scipy.optimize.fmin_slsqp() function

josef.pktd
On Tue, Aug 13, 2013 at 1:48 PM, Jose Guzman <[hidden email]> wrote:

> On 08/08/13 00:30, sudipta sinha wrote:
>
> Hi All,
>
> I am facing a problem for constrained linear least square fitting. In my
> case the matrix equation looks like [Y]nX1=[X]nXm[P]mX1, where Y and P are
> vectors and X is a matrix and n, m are dimension of the matrix. Further,
> there is a equality constraint on P which is Sum(P(i))=0.0. How do I proceed
> to solve that? Which function of python is suitable for this? I saw few of
> discussion on scipy.optimize.fmin_slsqp() function but the implementation of
> this function is not very straightforward. Therefore, I need your help. I am
> new in SCIPY. Please help me out in this regard.

If it's just a linear function and a linear constraint, then you could
just reparameterize the X matrix

X_new = X[:, :-1] - X[:, -1]
and p[-1] = - sum P_new

and use linalg.solve for example on X_new to give you the reduced P_new

if I read your equation correctly.

Josef

> _______________________________________________
> SciPy-User mailing list
> [hidden email]
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
> Hi
>
> Did you have a look to lmfit package (http://newville.github.io/lmfit-py/).
> I am trying some minimization with boundaries and constrains, and it seems
> that this is the way to go.  Do not know if somebody here has ever use it.
>
> Best
>
> Jose
>
> --
> Jose Guzman
> http://www.ist.ac.at/~jguzman/
>
>
> _______________________________________________
> SciPy-User mailing list
> [hidden email]
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user