数学建模社区-数学中国

标题: 200908网友求助《程序排错》 [打印本页]

作者: yduckey    时间: 2009-8-7 14:28
标题: 200908网友求助《程序排错》
本帖最后由 为你奋斗 于 2009-12-3 16:05 编辑 sets:
row/1..10/:M;
col/1..4/;
link(row,col):x,l;
endsets
data:
l=9.4 10 9.8 9.9
  9.8 9.4 10 9.6
  10 9.5 9.4 10
  9.5 9.9 9.7 10
  9.4 9.7 9.3 9.9
  9.9 9.9 9.1 9.4
  10 10 9.3 9.8
  10 10 9.9 9.8
  9.4 9.8 10 9.9
  9.7 9.5 9.6 9.8;
enddata
max=@sum(link:x*l);
@sum(row:M)=4;
@for(row(i): @sum(col(j):x(i,j))-M(i)<=3);
@for(row(i): @sum(col(j):x(i,j))-4*M(i)>=0);
@for(col(j): @sum(row(i):x(i,j))=6);
@for(link(i,j): @sum(link:x*1)=236.2);
@for(row(i)bin(M(i)));
@for(link(i,j)bin(X(i,j)));
end

帮忙看看哪里错了吧……实在找不出来了   谢谢谢谢!!!

作者: olh2008    时间: 2009-8-7 14:42
好像这一句有问题:  @for(link(i,j): @sum(link:x*1)=236.2);
还有你的目标函数是不是 max=@sum(link:x*l)?
作者: olh2008    时间: 2009-8-7 14:43
直接用sum的语句就可以了,不必再用for
作者: yduckey    时间: 2009-8-7 14:48
本帖最后由 yduckey 于 2009-8-7 14:52 编辑

3# olh2008
如果把那个控制条件去掉,直接把目标函数改为236.2=sum(link:x*l);
对吗?
可以这么写不?
作者: olh2008    时间: 2009-8-7 15:37
那就没有目标函数了,Lingo会给出一个符合约束的解
作者: danli    时间: 2009-8-7 18:39
MODEL:
sets:
row/1..10/:M;
col/1..4/;
link(row,col):x,l;
endsets
data:
l=9.4 10 9.8 9.9
  9.8 9.4 10 9.6
  10 9.5 9.4 10
  9.5 9.9 9.7 10
  9.4 9.7 9.3 9.9
  9.9 9.9 9.1 9.4
  10 10 9.3 9.8
  10 10 9.9 9.8
  9.4 9.8 10 9.9
  9.7 9.5 9.6 9.8;
enddata
max=@sum(link:x*l];
@sum(row:M)=4;
@sum(col(j):x(i,j))-M(i)<=3;
@for(row(i): 4*M(i)-@sum(col(j):x(i,j))<=0);
@for(col(j): @sum(row(i):x(i,j))=6);
@sum(link:x*1)=236.2;
@for(row(i)bin(M(i)));
@for(link(i,j)bin(X(i,j)));
end
不知道这样行不行,你运行试一下
作者: fc013    时间: 2009-8-7 19:19
sets:
row/1..10/:M;
col/1..4/;
link(row,col):x,l;
endsets
data:
l=9.4 10 9.8 9.9
  9.8 9.4 10 9.6
  10 9.5 9.4 10
  9.5 9.9 9.7 10
  9.4 9.7 9.3 9.9
  9.9 9.9 9.1 9.4
  10 10 9.3 9.8
  10 10 9.9 9.8
  9.4 9.8 10 9.9
  9.7 9.5 9.6 9.8;
enddata
max=@sum(link:x*l);
@sum(row:M)=4;
@for(row(i): @sum(col(j):x(i,j))-M(i)<=3);
@for(row(i): @sum(col(j):x(i,j))-4*M(i)>=0);
@for(col(j): @sum(row(i):x(i,j))=6);
@for(row(i)bin(M(i)));
@for(link(i,j)bin(X(i,j)));
end
作者: fouvy    时间: 2009-8-8 01:07
你的程序
sets:
row/1..10/:M;
col/1..4/;
link(row,col):x,l;
endsets
data:
l=9.4 10 9.8 9.9
  9.8 9.4 10 9.6
  10 9.5 9.4 10
  9.5 9.9 9.7 10
  9.4 9.7 9.3 9.9
  9.9 9.9 9.1 9.4
  10 10 9.3 9.8
  10 10 9.9 9.8
  9.4 9.8 10 9.9
  9.7 9.5 9.6 9.8;
enddata
max=@sum(link:x*l);
@sum(row:M)=4;
@for(row(i): @sum(col(j):x(i,j))-M(i)<=3);
@for(row(i): @sum(col(j):x(i,j))-4*M(i)>=0);
@for(col(j): @sum(row(i):x(i,j))=6);
@for(link(i,j): @sum(link:x*1)=236.2);
@for(row(i)bin(M(i)));
@for(link(i,j)bin(X(i,j)));
end


81没有可行解
LINGO was unable to find a solution that simultaneously satisfies all the constraints. Check the model抯 consistency. Try dropping constraints until the problem goes away to get an idea of where the trouble may lie. Also, check the solution report. Constraints contributing to the infeasibility will have a nonzero dual price.

92没有最优解或可行解
If you'e solved a model and brought another model window to the front, LINGO prints this message to remind you that the solution you'e asked for may not belong to the frontmost model window. LINGO also prints this message whenever you attempt to examine a nonoptimal solution; for instance, when you'e interrupted the solver, or when LINGO couldnt any find a feasible answer. In the latter case, correct any errors in the model and re-solve.
   No feasible solution found.
   Extended solver steps:                               0
   Total solver iterations:                             0


                                           Variable           Value
                                              M( 1)        1.000000
                                              M( 2)        1.000000
                                              M( 3)        1.000000
                                              M( 4)        1.000000
                                              M( 5)        1.000000
                                              M( 6)        1.000000
                                              M( 7)        1.000000
                                              M( 8)        1.000000
                                              M( 9)        1.000000
                                             M( 10)        1.000000
                                           X( 1, 1)        1.000000
                                           X( 1, 2)        1.000000
                                           X( 1, 3)        1.000000
                                           X( 1, 4)        1.000000
                                           X( 2, 1)        1.000000
                                           X( 2, 2)        1.000000
                                           X( 2, 3)        1.000000
                                           X( 2, 4)        1.000000
                                           X( 3, 1)        1.000000
                                           X( 3, 2)        1.000000
                                           X( 3, 3)        1.000000
                                           X( 3, 4)        1.000000
                                           X( 4, 1)        1.000000
                                           X( 4, 2)        1.000000
                                           X( 4, 3)        1.000000
                                           X( 4, 4)        1.000000
                                           X( 5, 1)        1.000000
                                           X( 5, 2)        1.000000
                                           X( 5, 3)        1.000000
                                           X( 5, 4)        1.000000
                                           X( 6, 1)        1.000000
                                           X( 6, 2)        1.000000
                                           X( 6, 3)        1.000000
                                           X( 6, 4)        1.000000
                                           X( 7, 1)        1.000000
                                           X( 7, 2)        1.000000
                                           X( 7, 3)        1.000000
                                           X( 7, 4)        1.000000
                                           X( 8, 1)        1.000000
                                           X( 8, 2)        1.000000
                                           X( 8, 3)        1.000000
                                           X( 8, 4)        1.000000
                                           X( 9, 1)        1.000000
                                           X( 9, 2)        1.000000
                                           X( 9, 3)        1.000000
                                           X( 9, 4)        1.000000
                                          X( 10, 1)        1.000000
                                          X( 10, 2)        1.000000
                                          X( 10, 3)        1.000000
                                          X( 10, 4)        1.000000
                                           L( 1, 1)        9.400000
                                           L( 1, 2)        10.00000
                                           L( 1, 3)        9.800000
                                           L( 1, 4)        9.900000
                                           L( 2, 1)        9.800000
                                           L( 2, 2)        9.400000
                                           L( 2, 3)        10.00000
                                           L( 2, 4)        9.600000
                                           L( 3, 1)        10.00000
                                           L( 3, 2)        9.500000
                                           L( 3, 3)        9.400000
                                           L( 3, 4)        10.00000
                                           L( 4, 1)        9.500000
                                           L( 4, 2)        9.900000
                                           L( 4, 3)        9.700000
                                           L( 4, 4)        10.00000
                                           L( 5, 1)        9.400000
                                           L( 5, 2)        9.700000
                                           L( 5, 3)        9.300000
                                           L( 5, 4)        9.900000
                                           L( 6, 1)        9.900000
                                           L( 6, 2)        9.900000
                                           L( 6, 3)        9.100000
                                           L( 6, 4)        9.400000
                                           L( 7, 1)        10.00000
                                           L( 7, 2)        10.00000
                                           L( 7, 3)        9.300000
                                           L( 7, 4)        9.800000
                                           L( 8, 1)        10.00000
                                           L( 8, 2)        10.00000
                                           L( 8, 3)        9.900000
                                           L( 8, 4)        9.800000
                                           L( 9, 1)        9.400000
                                           L( 9, 2)        9.800000
                                           L( 9, 3)        10.00000
                                           L( 9, 4)        9.900000
                                          L( 10, 1)        9.700000
                                          L( 10, 2)        9.500000
                                          L( 10, 3)        9.600000
                                          L( 10, 4)        9.800000

                                                Row    Slack or Surplus
                                                  1        0.000000
                                                  2       -1.000000
                                                  3        1.000000
                                                  4        1.000000
                                                  5        1.000000
                                                  6        1.000000
                                                  7        1.000000
                                                  8        1.000000
                                                  9        1.000000
                                                 10        1.000000
                                                 11        1.000000
                                                 12        1.000000
                                                 13       -1.000000
                                                 14       -1.000000
                                                 15       -1.000000
                                                 16       -1.000000
                                                 17       -1.000000
                                                 18       -1.000000
                                                 19       -1.000000
                                                 20       -1.000000
                                                 21       -1.000000
                                                 22       -1.000000
                                                 23       -1.000000
                                                 24       -1.000000
                                                 25       -1.000000
                                                 26       -1.000000
                                                 27       -1.000000
                                                 28       -1.000000
                                                 29       -1.000000
                                                 30       -1.000000
                                                 31       -1.000000
                                                 32       -1.000000
                                                 33       -1.000000
                                                 34       -1.000000
                                                 35       -1.000000
                                                 36       -1.000000
                                                 37       -1.000000
                                                 38       -1.000000
                                                 39       -1.000000
                                                 40       -1.000000
                                                 41       -1.000000
                                                 42       -1.000000
                                                 43       -1.000000
                                                 44       -1.000000
                                                 45       -1.000000
                                                 46       -1.000000
                                                 47       -1.000000
                                                 48       -1.000000
                                                 49       -1.000000
                                                 50       -1.000000
                                                 51       -1.000000
                                                 52        0.000000
                                                 53        0.000000
                                                 54        0.000000
                                                 55        0.000000
                                                 56        0.000000
                                                 57        0.000000
                                                 58        0.000000
                                                 59        0.000000
                                                 60        0.000000
                                                 61        0.000000
                                                 62        0.000000
                                                 63        0.000000
                                                 64        0.000000
                                                 65        0.000000
                                                 66        0.000000





欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5