初学glpk遇到的问题:glpk无法找到正确的解???

OOo,TeX,KO,ABI,GIMP,Picasa,ProE,QCAD,Inkscape,Kicad,Eagle
回复
头像
stlxv
论坛版主
帖子: 8274
注册时间: 2006-05-03 0:39
来自: المريخ
送出感谢: 0
接收感谢: 1 次

初学glpk遇到的问题:glpk无法找到正确的解???

#1

帖子 stlxv » 2006-09-22 13:25

lp1.mod文件内容如下:

代码: 全选

var x1>=0;
var x2>=0;
var x3>=0;
var x4>=0;
var x5>=0;
var x6>=0;
var x7>=0;
var x8>=0;

maximize z: x1+x2+x3+x4;

s.t. st1: x5+x6+x7+x8>=2500000;
s.t. st2: x1+x5<=380000;
s.t. st3: x2+x6<=265200;
s.t. st4: x3+x7<=408100;
s.t. st5: x4+x8<=130100;
s.t. st6: 2.85*x1-1.42*x2+4.27*x3-18.49*x4>=0;
s.t. st7: 2.85*x5-1.42*x6+4.27*x7-18.49*x8>=0;
s.t. st8: 16.5*x1+2*x2-4*x3+17*x4>=0;
s.t. st9: 7.5*x5-7*x6-13*x7+8*x8>=0;

end;
解的结果如下:

代码: 全选

stlxv@stlxvcomputer:~/Samples/MathProg$ glpsol -m lp1.mod
Reading model section from lp1.mod...
22 lines were read
Generating z...
Generating st1...
Generating st2...
Generating st3...
Generating st4...
Generating st5...
Generating st6...
Generating st7...
Generating st8...
Generating st9...
Model has been successfully generated
lpx_simplex: original LP has 10 rows, 8 columns, 32 non-zeros
lpx_simplex: presolved LP has 9 rows, 8 columns, 28 non-zeros
lpx_adv_basis: size of triangular part = 9
      0:   objval =   0.000000000e+00   infeas =   1.000000000e+00 (0)
      4:   objval =   0.000000000e+00   infeas =   6.692774085e-01 (0)
PROBLEM HAS NO FEASIBLE SOLUTION
lpx_simplex: cannot recover undefined or non-optimal solution
Time used:   0.0 secs
Memory used: 0.1M (151504 bytes)
奇怪……居然找不到解……

这个模型我原先用mathematica解过的,一下子解就出来了……

这是用mathematica得到的解:

代码: 全选

{933400., {x1 -> 264938., x2 -> 135702., x3 -> 408100., x4 -> 124660., 
    x5 -> 115062., x6 -> 129498., x7 -> 0., x8 -> 5440.01}}
P.S. 建议开个行业软件的板块~
头像
stlxv
论坛版主
帖子: 8274
注册时间: 2006-05-03 0:39
来自: المريخ
送出感谢: 0
接收感谢: 1 次

#2

帖子 stlxv » 2006-09-22 13:29

附mathematica解的代码:

代码: 全选

Maximize[{x1 + x2 + x3 + x4, (* objective function *)
    x5 + x6 + x7 + x8 >= 250000, (* conditions *)
    x1 + x5 <= 380000,
    x2 + x6 <= 265200,
    x3 + x7 <= 408100,
    x4 + x8 <= 130100,
    2.85*x1 - 1.42*x2 + 4.27*x3 - 18.49*x4 >= 0,
    2.85*x5 - 1.42*x6 + 4.27*x7 - 18.49*x8 >= 0,
    16.5*x1 + 2*x2 - 4*x3 + 17*x4 >= 0,
    7.5*x5 - 7*x6 - 13.0*x7 + 8*x8 >= 0,
    x1 >= 0, x2 >= 0, x3 >= 0, x4 >= 0, x5 >= 0, x6 >= 0, x7 >= 0, x8 >= 0},
  {x1, x2, x3, x4, x5, x6, x7, x8}    (* vars *)
  ] 
回复

回到 “办公、图像、机械电子设计等”