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
展开
展开全部
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
没得语法错误了
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
没得语法错误了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询