Clear Filters
Clear Filters

I have shifted from lsqnoneg to lsqlin because lsqnonneg does not support additional constraint is it right or wrong choice?

3 views (last 30 days)
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 Comments

Sign in to comment.

Answers (1)

Matt J
Matt J on 6 Oct 2024
Edited: Matt J on 6 Oct 2024
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 Comments
Bruno Luong
Bruno Luong on 7 Oct 2024
@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
Bruno Luong on 7 Oct 2024
Edited: Bruno Luong on 7 Oct 2024
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
ans = 2×1
6 7
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
bscale = b/max(b);
beqbscale = beq/max(b);
lb = [0;0];
Xscaled = lsqlin(A, bscale, [], [], Aeq, beqbscale, lb, []);
Minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
X = max(b)*Xscaled
X = 2×1
6.0000 7.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!