用MATLAB求解一个包含9个变量的242个线性不等式的系统

问题描述 投票:0回答:1

我有一个242线性不等式的系统,有9个变量(x1,...,x9),像这样:

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

有了约束:

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

如何使用MATLAB代码处理此问题?

先感谢您。

matlab linear-programming
1个回答
0
投票

这不是直接回答你的问题。您可以下载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
© www.soinside.com 2019 - 2024. All rights reserved.