# Enforce condition in lsqnoneg

조회 수: 4 (최근 30일)
sanjay 2024년 7월 5일
편집: Matt J 2024년 7월 7일
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이전 댓글 16개 표시이전 댓글 16개 숨기기
Torsten 2024년 7월 6일
편집: Torsten 2024년 7월 6일
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 2024년 7월 6일
Yes i tried without constraint then the reconstruction results are coming same in lsqin and lsqnoneg,

댓글을 달려면 로그인하십시오.

### 채택된 답변

Matt J 2024년 7월 6일
편집: Matt J 2024년 7월 6일
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이전 댓글 20개 표시이전 댓글 20개 숨기기
Torsten 2024년 7월 7일
편집: Torsten 2024년 7월 7일
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 2024년 7월 7일
편집: Matt J 2024년 7월 7일
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).

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Linear Least Squares에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by