I have shifted from lsqnoneg to lsqlin because lsqnonneg does not support additional constraint is it right or wrong choice?
4 次查看(过去 30 天)
显示 更早的评论
Hi , i am working on laser absorption spectroscopy tomography and i am trying to find my X for AX = b form as b is my data and A is my coefficent matrix and i am using lsqnoeng as my solver , some how when i have to appy the constraint during the reconstruction of X ,then lsqnonneg does not support it, because of it i have shift to lsqlin and setting its lower bound zero or non zero , i am considering it will work like lsqnonneg solver , now i can easily apply constraint into it, but the problem is i am confused whether i did it rigth or wrong as for the better result in lsqlin i have to scale my data b with it maximum value other wise it give very bad results , or i should implement the lsqnoeng and then apply constraint into it , please guide me
15 个评论
Bruno Luong
2024-10-7
编辑:Bruno Luong
2024-10-7
I didn't see anything (It's so rare that Torsen makes a little mistake. :))
回答(1 个)
Matt J
2024-10-6
编辑:Matt J
2024-10-6
If your lsqlin can solve your problem, then there is usually never any reason to use lsqnonneg. lsqnonneg is for nonlinear least squares problems, while your problem is linear.
As Torsten said, in the absence of your code and input, we can only make guesses about the other difficulties . However, normalizing your data is always a good thing because the default optimoptions are chosen with the assumption that you don't have crazy large (or small) input data.
9 个评论
Bruno Luong
2024-10-7
@sanjay Please give a small example but representative MATLAB code to illustrate, still not sure if you have a linear constraint or not in your problem.
Bruno Luong
2024-10-7
编辑:Bruno Luong
2024-10-7
With constraints you have to scale both b and beq by the same scalr scaling factor:
If the scaling factors are different or if you only scale one of those then you solve different problem.
A = [2 3 ; 4 5];
X = [6;7];
b = A*X; % we want b corresponds to non negative unknown X
Aeq = [8 9];
beq = Aeq*X;
A\b
bscale = b/max(b);
beqbscale = beq/max(b);
lb = [0;0];
Xscaled = lsqlin(A, bscale, [], [], Aeq, beqbscale, lb, []);
X = max(b)*Xscaled
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Least Squares 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!