数学建模社区-数学中国

标题: 有意者请入其实不算太难,LINGO 运输规划程序 [打印本页]

作者: nibini1    时间: 2011-5-20 21:38
标题: 有意者请入其实不算太难,LINGO 运输规划程序
结果是没有可行解,为何??数据太多吗???谢谢
在线等。。。那个表情是“:@”不知为何变表情了

  1. model:
  2. sets:
  3. warehouses/wh1..wh6/:capacity;
  4. vendors/v1..v18/:demand;
  5. links(warehouses,vendors):cost,volume;
  6. endsets
  7. !目标函数;
  8. min=@sum(links:cost*volume*1);
  9. !需求约束;
  10. @for(vendors(j)sum(warehouses(i):volume(i,j))=demand(j);
  11. !产量约束;
  12. @for(warehouses(i)sum(vendors(j):volume(i,j))<=capacity(i));
  13. @for(linksgin(volume));
  14. !数据;
  15. data:
  16. capacity=1000 800 800 800 1000 700;
  17. demand=260 400 1300 420 600 300 220 300 300 320 480 300 300 800 280 450 1200 700;
  18. cost=  0 1520  1100 1400 1400 1600 1630 5100 2800 2100  3380 2680 1850 1750 1150 1000 730  940
  19.      1520 0    2620 2330 1630 1830 3150 5330 3030 2330 3610 2910 1530 1980  780  1330 2250 2460
  20.      1100 2620 0    300 1600  1800 2730 5300 3000 2300 3580 2880 2050 1250  1850 1300 1830 2040
  21.      1400 2330 300  0   1300  1500 3030 5000 2700 2000 3280 2580 1750 950   1550 1000 2130 2340
  22.      1400 1630 1600 1300 0    200  3030 3700 1400 700  1980 1280 450  350   850  400  2130 2340
  23.      1600 1830 1800 1500 200  0    3230 3500 1200 500  1780 1080 650  550   1050 600  2330 2540;
  24. enddata
  25. end
复制代码


作者: nibini1    时间: 2011-5-20 22:08
有没有人呐。。。。。。。。。。。。。。。。。。。。。。。。。
作者: nibini1    时间: 2011-5-20 22:08
顶起呐,自己来
作者: nibini1    时间: 2011-5-20 22:11
给这么多分都没有帮我??



作者: 草船借箭    时间: 2011-7-18 16:37
model:

sets:

warehouses/wh1..wh6/:capacity;

vendors/v1..v18/:demand;

links(warehouses,vendors):cost,volume;

endsets
!数据;

data:

capacity=1000 800 800 800 1000 700;

demand=260 400 1300 420 600 300 220 300 300 320 480 300 300 800 280 450 1200 700;

cost=  0 1520  1100 1400 1400 1600 1630 5100 2800 2100  3380 2680 1850 1750 1150 1000 730  940

     1520 0    2620 2330 1630 1830 3150 5330 3030 2330 3610 2910 1530 1980  780  1330 2250 2460

     1100 2620 0    300 1600  1800 2730 5300 3000 2300 3580 2880 2050 1250  1850 1300 1830 2040

     1400 2330 300  0   1300  1500 3030 5000 2700 2000 3280 2580 1750 950   1550 1000 2130 2340

     1400 1630 1600 1300 0    200  3030 3700 1400 700  1980 1280 450  350   850  400  2130 2340

     1600 1830 1800 1500 200  0    3230 3500 1200 500  1780 1080 650  550   1050 600  2330 2540;

enddata

!目标函数;

min=@sum(links(i,j):cost(i,j)*volume(i,j)*1);

!需求约束;

@for(vendors(j)sum(warehouses(i):volume(i,j))=demand(j);

!产量约束;

@for(warehouses(i)sum(vendors(j):volume(i,j))<=capacity(i));

@for(links(i,j)gin(volume(i,j)));
end
改了一下,好像最后一个end有错,有点事,你先看看!
作者: I_know__!!!!    时间: 2011-7-30 11:26
这三个地方要改一下:
@for(vendors(j)sum(warehouses(i):volume(i,j))=demand(j);

!产量约束;

@for(warehouses(i)sum(vendors(j):volume(i,j))<=capacity(i));

@for(links(i,j)gin(volume(i,j)));


改为:
!需求约束;

@for(vendors(j):
@sum(warehouses(i):volume(i,j))=demand(j);

!产量约束;

@for(warehouses(i):
@sum(vendors(j):volume(i,j))<=capacity(i));

@for(links(i,j):
@gin(volume(i,j)));
但还是运行不了,可能是数据有误,能将题目拿出来看看?



作者: I_know__!!!!    时间: 2011-7-30 11:29
@便表情应该是全角与半角的转化问题,可能你是没有注意到它们间的转化。
作者: alair004    时间: 2012-2-6 15:20
Try to make the best use of my time3835660857163393
作者: xupengman    时间: 2012-3-6 09:18
确实不算难!就是不会!
作者: qlb061    时间: 2012-6-28 17:59
本帖最后由 qlb061 于 2012-6-28 18:20 编辑

有些语法错误,已经修改了;另外添加了CALC部分帮你诊断可能的错误,总供给无法满足所有需求!
  1. model:
  2. sets:
  3. warehouses/wh1..wh6/:capacity;
  4. vendors/v1..v18/:demand;
  5. links(warehouses,vendors):cost,volume;
  6. endsets
  7. !目标函数;
  8. min=@sum(links:cost*volume*1);
  9. !需求约束;
  10. @for(vendors(j):@sum(warehouses(i):volume(i,j))=demand(j));
  11. !产量约束;
  12. @for(warehouses(i):@sum(vendors(j):volume(i,j))<=capacity(i));
  13. @for(links:@gin(volume));
  14. !数据;
  15. data:
  16. capacity=1000 800 800 800 1000 700;
  17. demand=260 400 1300 420 600 300 220 300 300 320 480 300 300 800 280 450 1200 700;
  18. cost=  0 1520  1100 1400 1400 1600 1630 5100 2800 2100  3380 2680 1850 1750 1150 1000 730  940

  19.      1520 0    2620 2330 1630 1830 3150 5330 3030 2330 3610 2910 1530 1980  780  1330 2250 2460

  20.      1100 2620 0    300 1600  1800 2730 5300 3000 2300 3580 2880 2050 1250  1850 1300 1830 2040

  21.      1400 2330 300  0   1300  1500 3030 5000 2700 2000 3280 2580 1750 950   1550 1000 2130 2340

  22.      1400 1630 1600 1300 0    200  3030 3700 1400 700  1980 1280 450  350   850  400  2130 2340

  23.      1600 1830 1800 1500 200  0    3230 3500 1200 500  1780 1080 650  550   1050 600  2330 2540;

  24. enddata

  25. CALC:
  26.         @SET('TERSEO',1);
  27.         TOTALDEMAND=@SUM(VENDORS:DEMAND);
  28.         TOTALSUPPLY=@SUM(WAREHOUSES:CAPACITY);
  29.         @SOLVE();
  30.         @WRITE('TOTAL DEMAND IS: ',TOTALDEMAND,@NEWLINE(1));
  31.         @WRITE('TOTAL SUPPLY IS: ',TOTALSUPPLY,@NEWLINE(1));
  32.         @IFC(TOTALDEMAND #GT# TOTALSUPPLY:
  33.                 @WRITE('THE DEMANDS ARE TOO BIG TO BE MET!',@NEWLINE(2));
  34.                 @DEBUG();
  35.         );
  36.         @SET('TERSEO');
  37. ENDCALC

  38. end
复制代码

作者: 梦天涯M    时间: 2012-7-31 00:55
model:

sets:

warehouses/wh1..wh6/:capacity;

vendors/v1..v18/:demand;

links(warehouses,vendors):cost,volume;

endsets



min=@sum(links:cost*volume*1);



@for(vendors(j):
@sum(warehouses(i):volume(i,j))=demand(j));



@for(warehouses(i):
@sum(vendors(j):volume(i,j))<=capacity(i));

@for(links:
@gin(volume));

!数据;

data:

capacity=1000 800 800 800 1000 700;

demand=260 400 1300 420 600 300 220 300 300 320 480 300 300 800 280 450 1200 700;

cost=  0 1520  1100 1400 1400 1600 1630 5100 2800 2100  3380 2680 1850 1750 1150 1000 730  940

     1520 0    2620 2330 1630 1830 3150 5330 3030 2330 3610 2910 1530 1980  780  1330 2250 2460

     1100 2620 0    300 1600  1800 2730 5300 3000 2300 3580 2880 2050 1250  1850 1300 1830 2040

     1400 2330 300  0   1300  1500 3030 5000 2700 2000 3280 2580 1750 950   1550 1000 2130 2340

     1400 1630 1600 1300 0    200  3030 3700 1400 700  1980 1280 450  350   850  400  2130 2340

     1600 1830 1800 1500 200  0    3230 3500 1200 500  1780 1080 650  550   1050 600  2330 2540;

enddata

end





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