Constrained Linear Least square problem


Charlie
08-28-2004, 04:56 PM
I am not very good in mathematics. So, I have a very simple question. I hope someone will be kind enough to guide me preperly.

I want to solve constrained linear least square problem as it is solved by lsqlin function in matlab.

description of lsqlin is:

x = lsqlin(C,d,A,b) solves the linear system C*x=d in the least-squares sense subject to A*x<=b, where C is m-by-n.

Any Ideas on what will be the best way to do that. Can I use svdfit function to solve it? How should I represent the constraints?

vinter
09-27-2005, 09:04 AM
I have a similar problem, since I would like to fit a set of data (x,y) to a linear function for an astronomical problem. The only thing is, that I cannot allow a or b < 0 in y(:)=a+b*x(:), so the routine, fit() from NR, does not seem to be able to do it in its standard form.
Any good ideas?

I have tried Google, looked around here and have also tried hacking fit() in two ways. First:

if ((a.le.0.).or.(b.le.0.))then
chi2=100.*chi2
endif

Since it is often a, which tends to wrongfully become negative, I have also tried rerunning the code in cases where this happens with a forced zero:

t(:)=y(:)-0.-b*x(:)

I don't feel that any of these look very nice and neither do they seem to work very well, so does anyone have an idea of a routine (preferably NR and preferrably F90), which will do it? Thanks for any answer or suggestion!