Matlab中用linprog做线性规划时的问题 30
做一个有18个变量的线性规划问题,结果出现了这个提示,而且结果超过了我的限制,为什么啊?Exiting:Oneormoreoftheresiduals,dualityga...
做一个有18个变量的线性规划问题,结果出现了这个提示,而且结果超过了我的限制,为什么啊?
Exiting: One or more of the residuals, duality gap, or total relative error
has grown 100000 times greater than its minimum value so far:
the primal appears to be infeasible (and the dual unbounded).
(The dual residual < TolFun=1.00e-008.)
完整的代码如下:
C = -[5.86; 0.98; 0.95; 0.27; 2.39; 8.30; 0.22; 2.26; 2.01; 0.74; 0.95; 0.33; 24.45; 17.49; 13.82; 4.38; 11.32; 3.28];
A = [1.75 3 1.88 2.8 2.46 1 2.4 0.75 3.5 14.5 4 6.95 2.2 6.5 12.5 16.7 7 60;
1 0.5 0.5 2 1.5 1.5 1 1 1 2 1 1 0.3 0.5 0.8 0.3 2 27];
B = [10000; 80];
LB = [29 4 2 4 15 12 0 20 2 0 0 1 14 5 13 0 8 0];
UB = [49 16 12 8 27 33 4 35 8 1 3 5 24 13 26 7 28 3];
[X, fval] = linprog(C, A, B, [], [], LB, UB); 展开
Exiting: One or more of the residuals, duality gap, or total relative error
has grown 100000 times greater than its minimum value so far:
the primal appears to be infeasible (and the dual unbounded).
(The dual residual < TolFun=1.00e-008.)
完整的代码如下:
C = -[5.86; 0.98; 0.95; 0.27; 2.39; 8.30; 0.22; 2.26; 2.01; 0.74; 0.95; 0.33; 24.45; 17.49; 13.82; 4.38; 11.32; 3.28];
A = [1.75 3 1.88 2.8 2.46 1 2.4 0.75 3.5 14.5 4 6.95 2.2 6.5 12.5 16.7 7 60;
1 0.5 0.5 2 1.5 1.5 1 1 1 2 1 1 0.3 0.5 0.8 0.3 2 27];
B = [10000; 80];
LB = [29 4 2 4 15 12 0 20 2 0 0 1 14 5 13 0 8 0];
UB = [49 16 12 8 27 33 4 35 8 1 3 5 24 13 26 7 28 3];
[X, fval] = linprog(C, A, B, [], [], LB, UB); 展开
展开全部
C前面加了一个负号,说明原来是求最大值的,对吗?
我在A前面也加了一个负号,不知对不对,求解出来了。
clc;clear
C = -[5.86; 0.98; 0.95; 0.27; 2.39; 8.30; 0.22; 2.26; 2.01; 0.74; 0.95; 0.33; 24.45; 17.49; 13.82; 4.38; 11.32; 3.28];
A = -[1.75 3 1.88 2.8 2.46 1 2.4 0.75 3.5 14.5 4 6.95 2.2 6.5 12.5 16.7 7 60;1 0.5 0.5 2 1.5 1.5 1 1 1 2 1 1 0.3 0.5 0.8 0.3 2 27];
B = [10000; 80];
LB = [29 4 2 4 15 12 0 20 2 0 0 1 14 5 13 0 8 0];
UB = [49 16 12 8 27 33 4 35 8 1 3 5 24 13 26 7 28 3];
[X, fval] = linprog(C, A, B, [], [], LB, UB)
结果:
Optimization terminated.
X =
49.0000
16.0000
12.0000
8.0000
27.0000
33.0000
4.0000
35.0000
8.0000
1.0000
3.0000
5.0000
24.0000
13.0000
26.0000
7.0000
28.0000
3.0000
fval =
-2.2871e+003
我在A前面也加了一个负号,不知对不对,求解出来了。
clc;clear
C = -[5.86; 0.98; 0.95; 0.27; 2.39; 8.30; 0.22; 2.26; 2.01; 0.74; 0.95; 0.33; 24.45; 17.49; 13.82; 4.38; 11.32; 3.28];
A = -[1.75 3 1.88 2.8 2.46 1 2.4 0.75 3.5 14.5 4 6.95 2.2 6.5 12.5 16.7 7 60;1 0.5 0.5 2 1.5 1.5 1 1 1 2 1 1 0.3 0.5 0.8 0.3 2 27];
B = [10000; 80];
LB = [29 4 2 4 15 12 0 20 2 0 0 1 14 5 13 0 8 0];
UB = [49 16 12 8 27 33 4 35 8 1 3 5 24 13 26 7 28 3];
[X, fval] = linprog(C, A, B, [], [], LB, UB)
结果:
Optimization terminated.
X =
49.0000
16.0000
12.0000
8.0000
27.0000
33.0000
4.0000
35.0000
8.0000
1.0000
3.0000
5.0000
24.0000
13.0000
26.0000
7.0000
28.0000
3.0000
fval =
-2.2871e+003
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询