【问题标题】:Solving a system of 242 linear inequalities with 9 variables using MATLAB使用 MATLAB 求解具有 9 个变量的 242 个线性不等式系统
【发布时间】:2017-12-25 20:53:02
【问题描述】:

我有一个包含 9 个变量(x1、...、x9)的 242 个线性不等式系统,如下所示:

0 <= f1(x1,...,x9) <= 20
0 <= f2(x1,...,x9) <= 20
...
0 <= f242(x1,...,x9) <= 20

有约束:

0 <= x1,...,x9 <= 30

如何使用 MATLAB 代码解决此问题?

提前谢谢你。

【问题讨论】:

  • @sascha 我读到了linprog,但是从问题的表达中我看到,不需要目标函数,那么我该如何跳过f?
  • 使用零向量或任何其他(因为您没有指定您正在寻找的可能解决方案)。

标签: matlab linear-programming


【解决方案1】:

这不是直接回答您的问题。您可以下载 GNU GLPK 和 Gusek Editor 并尝试为您的需求建模。

如果 MATLAB 还支持 MathProg、GAMS 等数学编程语言,那么您可以对线性方程组进行建模并在没有任何目标函数的情况下求解(正如 @sascha 评论的那样)。

/* MathProg Example : With trivial inequalities  */

param m, integer, > 0, default 242;
param n, integer, > 0, default 9;
set INEQUALITIES := 1..m;
set VARS := 1..n;
var x{j in VARS}, >= 0, <= 30;

s.t. phi{i in INEQUALITIES}: i - sum{j in VARS} x[j]  <= 20;

solve;

for{j in VARS} {
        printf"x[%2d] = %2d\n", j, x[j];
}

end;

内部生成的方程如下所示:

Minimize
 obj: 0 x(1)

Subject To
 phi(1): - x(1) - x(2) - x(3) - x(4) - x(5) - x(6) - x(7) - x(8) - x(9)
 <= 19
 phi(2): - x(1) - x(2) - x(3) - x(4) - x(5) - x(6) - x(7) - x(8) - x(9)
 <= 18
 phi(3): - x(1) - x(2) - x(3) - x(4) - x(5) - x(6) - x(7) - x(8) - x(9)
 phi(242): - x(1) - x(2) - x(3) - x(4) - x(5) - x(6) - x(7) - x(8)
 - x(9) <= -222

Bounds
 0 <= x(1) <= 30
 0 <= x(2) <= 30
 0 <= x(3) <= 30
 0 <= x(4) <= 30
 0 <= x(5) <= 30
 0 <= x(6) <= 30
 0 <= x(7) <= 30
 0 <= x(8) <= 30
 0 <= x(9) <= 30

End

在求解模型时,解决方案如下所示:

>C:\gusek\glpsol.exe --cover --clique --gomory --mir -m "vijay.mod"    
GLPSOL: GLPK LP/MIP Solver, v4.64
Parameter(s) specified in the command line:
 --cover --clique --gomory --mir -m vijay.mod
Reading model section from vijay.mod...
vijay.mod:17: warning: final NL missing before end of file
17 lines were read
Generating phi...
Model has been successfully generated
GLPK Simplex Optimizer, v4.64
242 rows, 9 columns, 2178 non-zeros
Preprocessing...
222 rows, 9 columns, 1998 non-zeros
Scaling...
 A: min|aij| =  1.000e+00  max|aij| =  1.000e+00  ratio =  1.000e+00
Problem data seem to be well scaled
Constructing initial basis...
Size of triangular part is 222
      0: obj =   0.000000000e+00 inf =   2.475e+04 (222)
    222: obj =   0.000000000e+00 inf =   0.000e+00 (0) 2
OPTIMAL LP SOLUTION FOUND
Time used:   0.0 secs
Memory used: 0.5 Mb (538071 bytes)
x[ 1] = 30
x[ 2] = 30
x[ 3] = 30
x[ 4] = 30
x[ 5] = 30
x[ 6] = 30
x[ 7] = 30
x[ 8] = 12
x[ 9] =  0
Model has been successfully processed
>Exit code: 0    Time: 0.212

【讨论】:

    猜你喜欢
    • 2017-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-20
    • 2012-03-31
    • 1970-01-01
    相关资源
    最近更新 更多