Solve linear system of equations with constains
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
1 vote
Share a link to this question
Hello everyone. I have a linear system of equations that make a matrix, L*x=R. x is composed on many variables, e.g. x=[x1 x2 x3 x4 ... xN]. I want to solve this system of equation with constraints x1>|x2|>|x3|>|x4|...>|xN|. Can I use lsqlin(L,R) with some additional input to realize it?
Many thanks.
Accepted Answer
2 votes
If you make the change of variables x(i)=u(i)-v(i) with linear constraints
u(i)>=0,
v(i)>=0,
u(i)+v(i)>=u(i+1)+v(i+1)
and modify your least squares objective from norm(L(u-v)-R)^2 to
norm(L(u-v)-R)^2 + C*( norm(u)^2 + norm(v)^2)
then for a sufficiently small choice of C>0, this should give an equivalent solution. It's not ideal, since it forces you to re-solve with multiple choices of C, but on the other hand, it allows you to pose this as a convex problem.
8 Comments
Xin
on 25 Feb 2018
Thanks for your answer. That seems to make a lot of sense. I am wondering how should I solve for u and v. Do I need to solve 2*N variable instead of N variables?
Matt J
on 25 Feb 2018
Yes. After you solve for u and v, you would map back to x just by using the change of variables formula x=u-v.
Xin
on 1 Mar 2018
Hi Matt. I really appreciate your help. I have given it a try and it seems that this is a bit confusing. A numerical example, let x(i)=1 and x(i-1)=2, then we can set up u(i)=100 v(i)=99; and u(i-1)=4 v(i-1)=2, which satisfy the relation. However, we could also switch it to u(i)=100 v(i)=95 and u(i-1)=4 v(i-1)=2, which gives you x(i)=5 x(i-1)=2 that does not satisfy the requirement.
Could you please elaborate the equation you give me. Thanks a lot.
Matt J
on 2 Mar 2018
Sorry, I meant
u(i)+v(i)>=u(i+1)+v(i+1)
I've edited my post accordingly.
Basically, the transformation x=u-v has no unique choice of [u,v], but the minimum-norm choice of [u,v] is unique and must satisfy either u=0 or v=0. Hence |x|=u+v and therefore
u(i)+v(i)>=u(i+1)+v(i+1)
is the same as
||x(i)|| >= ||x(i+1)||
Xin
on 2 Mar 2018
Thanks Matt. As for changing the objective function, do you know any matlab function that does so, for example lsqlin or linsolve etc. So far as I know lsqlin only minimize norm(L*x-R)^2.
Thanks!
Matt J
on 3 Mar 2018
The modified objective function is linear least squares in [u,v] so lsqlin still applies.
Xin
on 3 Mar 2018
I have looked into lsqlin function but did not find how to change the objective. Then how do I change the objective from min 0.5*(NORM(C*x-d)).^2 to min 0.5*(NORM(C*x-d)).^2+ C*( norm(u)^2 + norm(v)^2)?
Thanks!
It just requires a different choice of input matrices C,d. For example, the terms
( norm(u)^2 + norm(v)^2)
is the same as
norm( C*[u;v]-d )^2
where C=speye(2*N) and d=zeros(2*N,1).
More Answers (0)
Categories
Find more on Linear Least Squares in Help Center and File Exchange
See Also
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)