constrained least square fitting using scipy.optimize.fmin_slsqp() function
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.
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 SciPy-User@scipy.org 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/
On Tue, Aug 13, 2013 at 1:48 PM, Jose Guzman <sjm.guzman@gmail.com> 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 SciPy-User@scipy.org 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 SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
participants (3)
-
Jose Guzman -
josef.pktd@gmail.com -
sudipta sinha