Solving a system of linear inequalities

6 ビュー (過去 30 日間)
Cassandra Wong
Cassandra Wong 2016 年 7 月 27 日
コメント済み: Edward Szymkowiak 2018 年 3 月 29 日
Dear all, I need your help to solve a system of linear inequalities. The system is as follows
Fx = [x1+x2; x1+x2+x3+x6+x7; x2+x3+x4+x6; x3+x4+x5+x7; x4+x5; x2+x3+x6; x2+x4+x7]
and Fx >= 1
given that x1,x2,...x7 can either = 0 or 1 (whole number)
How to solve x1,x2 up to x7 in MATLAB?
Thanks in advance.
Best Regards
Cassandra
  1 件のコメント
Torsten
Torsten 2016 年 7 月 27 日
Choose
x1 = x2 = x3 =...= x7 = 1
Then
Fx >= 1 (componentwise)
is satisfied.
Best wishes
Torsten.

サインインしてコメントする。

回答 (1 件)

Bjorn Gustavsson
Bjorn Gustavsson 2016 年 7 月 27 日
編集済み: John D'Errico 2016 年 7 月 27 日
...or if you want all points that satisfy the conditions you could do:
D = {[0 1],[0 1],[0 1],[0 1],[0 1],[0 1],[0 1]};
[X1,X2,X3,X4,X5,X6,X7] = ndgrid(D{:});
IOK = (X1+X2>=1 & X1+X2+X3+X6+X7>=1 & X2+X3+X4+X6>=1 & X3+X4+X5+X7>=1 & X4+X5>=1 & X2+X3+X6>=1& X2+X4+X7>=1);
HTH
  4 件のコメント
John D'Errico
John D'Errico 2016 年 7 月 27 日
編集済み: John D'Errico 2016 年 7 月 27 日
The last [0 1] in your assignment of D was given as [01], with no space. So a pretty minor typo.
Edward Szymkowiak
Edward Szymkowiak 2018 年 3 月 29 日
I am having trouble decoding IOK. Here is a simpler version:
D = {[0 1 ],[0 1],[0 1 ] };
[X1,X2,X3] = ndgrid(D{:});
IOK = (X1+X2+X3>0 & -X1+X2-X3>0);
Every time I add another variable the dimension of IOK increases.
Is there some code to map IOK back into a readable form telling us what values of X(n) satisfy the system for n =1 to # of variables?
Thanks

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLinear Algebra についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by