lingo中属性下标越界 10
model:sets:set1/1..4/;set2/1..16/;link1(set1,set1,set2):x;link2(set1,set1);endsetsmax...
model:
sets:
set1/1..4/;
set2/1..16/;
link1(set1,set1,set2):x;
link2(set1,set1);
endsets
max=@sum(link1(i,j,k):k*x(i,j,k));
@for(link1(i,j,k):@bin(x(i,j,k)));
x(1,1,1)=1;
x(1,2,2)+x(2,1,2)=1;
x(4,4,16)=1;
x(4,3,15)+x(3,4,15)=1;
@for(link1(i,j,k):x(1,4,k)=x(1,3,k-1)+x(2,4,k-1));
@for(link1(i,j,k):x(1,4,k)=x(1,3,k+1)+x(2,4,k+1));
@for(link1(i,j,k):x(4,1,k)=x(3,1,k-1)+x(4,2,k-1));
@for(link1(i,j,k):x(4,1,k)=x(3,1,k+1)+x(4,2,k+1));
@for(set1(j)|j#eq#2#and#j#eq#3:x(1,j,k)=x(1,j-1,k-1)+x(1,j+1,k-1)+x(2,j,k-1));
@for(set1(j)|j#eq#2#and#j#eq#3:x(1,j,k)=x(1,j-1,k+1)+x(1,j+1,k+1)+x(2,j,k+1));
@for(set1(j)|j#eq#2#and#j#eq#3:x(4,j,k)=x(4,j-1,k-1)+x(4,j+1,k-1)+x(3,j,k-1));
@for(set1(j)|j#eq#2#and#j#eq#3:x(4,j,k)=x(4,j-1,k+1)+x(4,j+1,k+1)+x(3,j,k+1));
@for(set1(i)|i#eq#2#and#i#eq#3:x(i,1,k)=x(i-1,1,k-1)+x(i+1,1,k-1)+x(i,2,k-1));
@for(set1(i)|i#eq#2#and#i#eq#3:x(i,1,k)=x(i-1,1,k+1)+x(i+1,1,k+1)+x(i,2,k+1));
@for(set1(i)|i#eq#2#and#i#eq#3:x(i,4,k)=x(i-1,4,k-1)+x(i+1,4,k-1)+x(i,3,k-1));
@for(set1(i)|i#eq#2#and#i#eq#3:x(i,4,k)=x(i-1,4,k+1)+x(i+1,4,k+1)+x(i,3,k+1));
@for(link2(i,j)|i#ge#2#and#i#le#3#and#j#ge#2#and#j#le#3:x(i,j,k)=x(i-1,j,k-1)+x(i+1,j,k-1)+x(i,j-1,k-1)+x(i,j+1,k-1));
@for(link2(i,j)|i#ge#2#and#i#le#3#and#j#ge#2#and#j#le#3:x(i,j,k)=x(i-1,j,k+1)+x(i+1,j,k+1)+x(i,j-1,k+1)+x(i,j+1,k+1));
@for(@sum(link2(i,j):x(i,j,k))=1);
end
对于4*4表格,分别填入1~16,在(1,1)处写1,(4,4)写16,每个数字必须与相邻数字共边,请问有几种填法,这个程序很有问题,不知道怎么改,求指教。 展开
sets:
set1/1..4/;
set2/1..16/;
link1(set1,set1,set2):x;
link2(set1,set1);
endsets
max=@sum(link1(i,j,k):k*x(i,j,k));
@for(link1(i,j,k):@bin(x(i,j,k)));
x(1,1,1)=1;
x(1,2,2)+x(2,1,2)=1;
x(4,4,16)=1;
x(4,3,15)+x(3,4,15)=1;
@for(link1(i,j,k):x(1,4,k)=x(1,3,k-1)+x(2,4,k-1));
@for(link1(i,j,k):x(1,4,k)=x(1,3,k+1)+x(2,4,k+1));
@for(link1(i,j,k):x(4,1,k)=x(3,1,k-1)+x(4,2,k-1));
@for(link1(i,j,k):x(4,1,k)=x(3,1,k+1)+x(4,2,k+1));
@for(set1(j)|j#eq#2#and#j#eq#3:x(1,j,k)=x(1,j-1,k-1)+x(1,j+1,k-1)+x(2,j,k-1));
@for(set1(j)|j#eq#2#and#j#eq#3:x(1,j,k)=x(1,j-1,k+1)+x(1,j+1,k+1)+x(2,j,k+1));
@for(set1(j)|j#eq#2#and#j#eq#3:x(4,j,k)=x(4,j-1,k-1)+x(4,j+1,k-1)+x(3,j,k-1));
@for(set1(j)|j#eq#2#and#j#eq#3:x(4,j,k)=x(4,j-1,k+1)+x(4,j+1,k+1)+x(3,j,k+1));
@for(set1(i)|i#eq#2#and#i#eq#3:x(i,1,k)=x(i-1,1,k-1)+x(i+1,1,k-1)+x(i,2,k-1));
@for(set1(i)|i#eq#2#and#i#eq#3:x(i,1,k)=x(i-1,1,k+1)+x(i+1,1,k+1)+x(i,2,k+1));
@for(set1(i)|i#eq#2#and#i#eq#3:x(i,4,k)=x(i-1,4,k-1)+x(i+1,4,k-1)+x(i,3,k-1));
@for(set1(i)|i#eq#2#and#i#eq#3:x(i,4,k)=x(i-1,4,k+1)+x(i+1,4,k+1)+x(i,3,k+1));
@for(link2(i,j)|i#ge#2#and#i#le#3#and#j#ge#2#and#j#le#3:x(i,j,k)=x(i-1,j,k-1)+x(i+1,j,k-1)+x(i,j-1,k-1)+x(i,j+1,k-1));
@for(link2(i,j)|i#ge#2#and#i#le#3#and#j#ge#2#and#j#le#3:x(i,j,k)=x(i-1,j,k+1)+x(i+1,j,k+1)+x(i,j-1,k+1)+x(i,j+1,k+1));
@for(@sum(link2(i,j):x(i,j,k))=1);
end
对于4*4表格,分别填入1~16,在(1,1)处写1,(4,4)写16,每个数字必须与相邻数字共边,请问有几种填法,这个程序很有问题,不知道怎么改,求指教。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询