永发信息网

lingo 下标变量集合超出范围

答案:2  悬赏:20  手机版
解决时间 2021-03-19 04:18
  • 提问者网友:雾里闻花香
  • 2021-03-18 04:58
model:
sets:
si/1..6/:;
sj/1..7/:;

lij(si,sj):x;
endsets
data:
enddata
max=@sum(lij(i,j):x(i,j));
!定义x(i,j)是0-1变量;
@for(lij(i,j):@bin(x(i,j)));
!每一行取掉的棋子;
@for(lij(i,j):6>@sum(sj(j):x(1,j)));
@for(lij(i,j):6>@sum(sj(j):x(2,j)));
@for(lij(i,j):6>@sum(sj(j):x(3,j)));
@for(lij(i,j):6>@sum(sj(j):x(4,j)));
@for(lij(i,j):6>@sum(sj(j):x(5,j)));
@for(lij(i,j):6>@sum(sj(j):x(6,j)));
!每一列去掉的棋子;
@for(lij(i,j):5>@sum(si(i):x(i,1)));
@for(lij(i,j):5>@sum(si(i):x(i,2)));
@for(lij(i,j):5>@sum(si(i):x(i,3)));
@for(lij(i,j):5>@sum(si(i):x(i,4)));
@for(lij(i,j):5>@sum(si(i):x(i,5)));
@for(lij(i,j):5>@sum(si(i):x(i,6)));
@for(lij(i,j):5>@sum(si(i):x(i,7)));
!左斜线取子;
@for(lij(i,j):(x(i,j)+x(i+1,j+1)+x(i+2,j+2)+x(i+3,j+3)+x(i+4,j+4)+x(i+5,j+5)<5));
@for(lij(i,j):(x(i,j)+x(i+1,j+1)+x(i+2,j+2)+x(i+3,j+3)+x(i+4,j+4)<4));
!右斜线取子;
@for(lij(i,j):(x(i,j)+x(i-1,j+1)+x(i-2,j+2)+x(i-3,j+3)+x(i-4,j+4)+x(i-5,j+5))<5);
@for(lij(i,j):(x(i,j)+x(i-1,j+1)+x(i-2,j+2)+x(i-3,j+3)+x(i-4,j+4))<4);
end

就是最后左斜线和右斜线的没办法处理
最佳答案
  • 五星知识达人网友:往事埋风中
  • 2021-03-18 06:26
程序没问题~可能只是软件变量限制…答案我算出来了… T 0.000000 X( A1) 150.0000 X( A2) 85.00000 X( A3) 150.0000 X( A4) 145.0000 X( A5) 130.0000 X( A6) 0.000000 Y( A1) 140.0000 Y( A2) 85.00000 Y( A3) 155.0000 Y( A4) 50.00000 Y( A5) 150.0000 Y( A6) 0.000000 Q( A1) 4.2410...

程序没问题~可能只是软件变量限制…答案我算出来了… T 0.000000 X( A1) 150.0000 X( A2) 85.00000 X( A3) 150.0000 X( A4) 145.0000 X( A5) 130.0000 X( A6) 0.000000 Y( A1) 140.0000 Y( A2) 85.00000 Y( A3) 155.0000 Y( A4) 50.00000 Y( A5) 150.0000 Y( A6) 0.000000 Q( A1) 4.241000 Q( A2) 4.119000 Q( A3) 3.848000 Q( A4) 2.775000 Q( A5) 4.014000 Q( A6) 0.9080000 M( A1) 0.000000 M( A2) 0.000000 M( A3) 0.000000 M( A4) 0.000000 M( A5) 0.000000 M( A6) 0.000000 Row Slack or Surplus 1 7186.000 2 8061.000 3 436.0000 4 42036.00 5 7186.000 6 9061.000 7 4761.000 8 6186.000 9 14386.00 10 9061.000 11 10986.00 12 361.0000 13 46461.00 14 8061.000 15 4761.000 16 10986.00 17 10161.00 18 23461.00 19 436.0000 20 6186.000 21 361.0000 22 10161.00 23 39336.00 24 42036.00 25 14386.00 26 46461.00 27 23461.00 28 39336.00 29 0.5707895 30 0.2060285 31 0.4053332 32 0.1581078 33 0.5707895 34 0.2742298 35 0.2312193 36 0.3208201 37 0.2085955 38 0.2742298 39 0.1573335 40 0.2023483 41 0.1473466 42 0.2060285 43 0.2312193 44 0.1573335 45 0.1745847 46 0.1637929 47 0.4053332 48 0.3208201 49 0.2023483 50 0.1745847 51 0.1588337 52 0.1581078 53 0.2085955 54 0.1473466 55 0.1637929 56 0.1588337 57 10.00000 58 75.00000 59 10.00000 60 15.00000 61 30.00000 62 160.0000 63 20.00000 64 75.00000 65 5.000000 66 110.0000 67 10.00000 68 160.0000 69 0.000000 70 0.2828427
全部回答
  • 1楼网友:妄饮晩冬酒
  • 2021-03-18 07:44
你变量名和指标都重复了 当然不行了 你的集操作很有问题 model: !daya,dayb; sets: day/1..4/:; link(day,day):r,w,d,x; link1(day,day,day); endsets data: r=780,0,0,0, 1560,780,0,0, 2340,1560,780,0, 3120,2340,1560,780; w=588,90000,90000,90000, 1176,588,90000,90000, 1764,1176,588,90000, 2352,1764,1176,588; d=20,0,0,0, 35,20,0,0, 90,25,17,0, 120,120,30,50; enddata [obj]max=0.10*@sum(link(a,b):r(a,b)*x(a,b))-0.1*@sum(link(a,b):w(a,b)*x(a,b))-0.1*500*@sum(link(a,b):d(a,b)+0.1*x(a,b)-x(a,b)); @sum(link(a,b):x(a,b))+@sum(link1(a,b,k):x(k,b))-@sum(link1(a,b,k):x(a,k))<=400; @sum(day(b):x(1,b))<=400; @for(link(a,b):x(a,b)<=123); @for(link(a,b):@gin(x(a,b))); end
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯