Clear Filters
Clear Filters

Enforce condition in lsqnoneg

133 views (last 30 days)
sanjay
sanjay on 5 Jul 2024 at 8:20
Edited: Matt J on 7 Jul 2024 at 20:29
I working on inverse problem which is rank deficient and for that i am using tikhonov regularization , for minization i am using lsqnoneg to resolve it which is giving me good result but now i have to enforce a condition in each iteration of minimzation of lsqnoneg, however lsqnoneg oterations are automatic i cant control it manually althohg i used fmincon but it is not giving me the same results can some one help what algorithm should i use so that i can enforce my conditon during optimization iterations and it gives results like lsqnoneg,
Tikh_Output.IA_recovered_line_1 = lsqnonneg(Combined_Coeff_Matrix,Combined_projection_line_1);
Tikh_Output.IA_recovered_line_2 = lsqnonneg(Combined_Coeff_Matrix,Combined_projection_line_2);
here is my code
  18 Comments
Torsten
Torsten on 6 Jul 2024 at 9:30
Edited: Torsten on 6 Jul 2024 at 9:33
As I said: You can't change solution variables during the optimization process in MATLAB optimizers. The changes must be initiated by your definition of the objective function or by the definition of your constraints. So neither "lsqlin" or "fmincon" can help you in this respect.
But if you want the optimal solution that satisfies x(1) >= x(1601), ... , x(1600) >= x(1601), then the constraint-based solution with "lsqlin" should be correct in my opinion (althogh the result you get might not be as expected).
Do you get the same results with lsqnonneg and lsqlin if you work without the A*x <= b constraint and only set the lower bounds vector lb to zeros(1601,1) ?
sanjay
sanjay on 6 Jul 2024 at 9:44
Yes i tried without constraint then the reconstruction results are coming same in lsqin and lsqnoneg,

Sign in to comment.

Accepted Answer

Matt J
Matt J on 6 Jul 2024 at 11:32
Edited: Matt J on 6 Jul 2024 at 11:35
Suppose your original problem is,
Rewrite the problem by making the change of variables x=Q*z where z>=0 and
Q=eye(1601); Q(:,end)=1;
Then the problem becomes,
which you can solve with lsqnonneg. After solving for z, you can retrieve x with x=Q*z.
  22 Comments
Torsten
Torsten on 7 Jul 2024 at 20:13
Edited: Torsten on 7 Jul 2024 at 20:20
Both approaches (using lsqlin with lb = 0 and A*x <= b or using lsqnonneg for optimization in z where x is determined after the optimization as x = Q*z) are correct and should give the same result (at least ||C*x-d|| and ||C*Q*z-d|| should be the same)). Test it.
If you don't trust in the appoach with the coordinate transformation
z(i) = x(i) - x(1601) (1 <= i <= 1600)
z(1601) = x(1601)
or explicitly rewritten in x
x(i) = z(i) + z(1601) (1 < = i <= 1600)
x(1601) = z(1601)
or rewritten in matrix form
x = Q*z
use the approach in x.
I don't know what you mean by "recover my X and then apply this condition".
Matt J
Matt J on 7 Jul 2024 at 20:24
Edited: Matt J on 7 Jul 2024 at 20:29
i am enforcing the condition which X(1)>=X(1601),X(2)>=X(1601),,,,,,,,X(1600)>=X(1601) where this condition is satisfied using Q and z approach?
Yes. Torsten already said it, but just for emphasis, the condition X(1)>=X(1601),X(2)>=X(1601),,,,,,,,X(1600)>=X(1601) means the very same thing as the condition z>=0. Therefore, if you have optimized over z subject to z>=0, you have done the very same thing as when you optimize over X subject to the constraints X(1)>=X(1601),X(2)>=X(1601),,,,,,,,X(1600)>=X(1601).

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!