Lingo程序错误代码11 求解

2024-12-04 22:52:37
推荐回答(1个)
回答1:

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
没得语法错误了