Message Boards Message Boards

Overdetermined Linear LeastSquares solution of AX=B with constraint [B]>0

LeastSquares[A,B] would give least square solution for an overdetermined linear system,e.g I have three variables (x,y,z) with 20 equation so A is a rectangular 20x3 matrix and B is 20x1 constant column matrix. But I have a constraint where the all elements of B[i]( [B]>0). But when solving by normal Leastsquares[A,B] solutions are X={a,b,c} such that when I again calculate Bth=A.X to check with actual B(experimental), few Bth elements are negative. So I need a solution in MATHEMATICA please that Is it possible to put a constraint such that the X are optimized in such a way in the LeastSquare so that all the elements Bth(=A.X)>0 or say any other constraint {where the solution elements of X are to be optimized along with least error/residuals} as per constraint..

POSTED BY: Bijan Deb
3 Replies

This can be set up as a quadratic programming problem, (minimize sum of squares of discrepancies) subject to linear constraints (nonnegativity of variables). Can use FindMinimum[{obj,constraints}, vars, Method->"QuadraticProgramming"].

POSTED BY: Daniel Lichtblau

Thanks for the idea. But I don't get it how to do it. Actually my problem is I want to solve AX=B with leastsquare with the linear inequality constraint AX>=0 or say AX>=c(any constant). Could you please provide how to write the syntax of the same . Here A is suppose a 20x3 matrix and B is 20x1 matrix. When I calculate LeastSquare[A,B] I get X which then again calculated AX, I got few values of AX<0 (elements of B as -ve) which as per my problem should not be. So How can I write the syntax program so that the X is optimized in such a way that AX>=0 or any constant is maintained along side solving leastsquare.

POSTED BY: Bijan Deb

Were you intending to post an actual example? Because I'm not going to cast about for one.

In the context of what I wrote above, the constraints part would probably be constraints=Thread[A.x>=2].

POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract