Lingo程序错误代码11 求解

sets:places/1..8/:level;!level(i)=thelevelofplace;link(places,places):distance,!Thedi... sets:places/1..8/:level;!level(i)=the level of place;link(places,places): distance,!The distance matrix x; !x(i,j)=1 if we ues link i,j;endsetsdata:!Distance matrix,it need not be symmetric;distance=0 10.7 10 9 18 28 30.5 43.310.7 0 3 8 20 17 20 3610 3 0 6.6 16 17 28 359 8 6.6 0 11.7 20 24 3718 20 16 11.7 0 25 12.3 2528 17 17 20 25 0 20 2030.5 20 28 24 12.3 20 0 2043.3 36 35 37 25 20 20 0;enddatan=@size(places);!The model size;!Minimize total distance of the links;min=@sum(link(i,j)|i#ne#j:distance(i,j)*x(i,j));!For place i;@for(places(i):!It must be entered;@sum(places(j)|j#ne#i:x(j,i))=1;!It must be departed;@sum(places(j)|j#ne#i:x(i,j))=1;!level(j)=level(i)+1,if we link j and i;@for(places(j)|j#gt#1#and#j#ne#i; level(j)>=level(i)+x(i,j) -(n-2)*(1-x(i,j))+(n-3)*x(j,i); ););!Make the x's 0/1;@for(link:@bin(x));!For the first and last stop;@for(places(i)|i#gt#1: level(i)<=n-1-(n-2)*x(1,i); level(i)>=1+(n-2)*x(i,1););End 展开
 我来答
bill8341
高粉答主

2017-05-27 · 关注我不会让你失望
知道大有可为答主
回答量:1.8万
采纳率:95%
帮助的人:3535万
展开全部
sets:
places/1..8/:level;
!level(i)=the level of place;
link(places,places): distance,x;
!The distance matrix x; !x(i,j)=1 if we ues link i,j;
endsets
data:
!Distance matrix,it need not be symmetric;
distance=0 10.7 10 9 18 28 30.5 43.3
10.7 0 3 8 20 17 20 36
10 3 0 6.6 16 17 28 35
9 8 6.6 0 11.7 20 24 37
18 20 16 11.7 0 25 12.3 25
28 17 17 20 25 0 20 20
30.5 20 28 24 12.3 20 0 20
43.3 36 35 37 25 20 20 0;
enddata
n=@size(places);
!The model size;!Minimize total distance of the links;
min=@sum(link(i,j)|i#ne#j:distance(i,j)*x(i,j));
!For place i;
@for(places(i):!It must be entered;
@sum(places(j)|j#ne#i:x(j,i))=1;
!It must be departed;
@sum(places(j)|j#ne#i:x(i,j))=1;
!level(j)=level(i)+1,if we link j and i;
@for(places(j)|j#gt#1#and#j#ne#i:level(j)>=level(i)+x(i,j)-(n-2)*(1-x(i,j))+(n-3)*x(j,i); ););
!Make the x's 0/1;
@for(link:@bin(x));
!For the first and last stop;
@for(places(i)|i#gt#1:level(i)<=n-1-(n-2)*x(1,i); level(i)>=1+(n-2)*x(i,1););
End
没得语法错误了
追问

请问为什么运算时会出现数据限制的提示呢?应该怎么改写程序?


找到问题了,是这句代码的原因:@for(link:@bin(x));

这句代码是什么意思呢?

推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式