lingo说模型的定义不正确,实在找不出错误,感激不尽!
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/11 21:34:05
lingo说模型的定义不正确,实在找不出错误,感激不尽!
model:
sets:
areas/1..5/:index; Hamilton路径号;
link(areas,areas):distance,x; 邻接矩阵和决策矩阵;
endsets
data:
distance=0,300,600,0,0,300,0,300,200,0,600,300,0,0,500,0,200,0,0,200,0,0,500,200,0; 输入19×19的邻接矩阵(此处没有列出);
enddata
n=@size(areas);
min=@sum(link(i,j)|i#ne#j:distance(i,j)*x(i,j));
@for(areas(i):index(i)>=1;); 地区编号非约束;
@for(areas(i):
@sum(areas(j)|j#ne#i:x(j,i))=1; 入度为1约束;
@sum(areas(j)|j#ne#i:x(i,j))=1;); 出度为1约束;
@for(areas(j)|j#gt#i#and#j#ne#i:index(j)>=index(i)+x(i,j)-n*(1-x(i,j))+(n-1)*x(j,i);); 标号约束(除起始点外标号);
@for(link:@bin(x)); 0-1约束;
@for(areas(i)|i#gt#1:index(i)=1+(n-1)*x(i,1);); 终点标号约束;
end
model:
sets:
areas/1..5/:index; Hamilton路径号;
link(areas,areas):distance,x; 邻接矩阵和决策矩阵;
endsets
data:
distance=0,300,600,0,0,300,0,300,200,0,600,300,0,0,500,0,200,0,0,200,0,0,500,200,0; 输入19×19的邻接矩阵(此处没有列出);
enddata
n=@size(areas);
min=@sum(link(i,j)|i#ne#j:distance(i,j)*x(i,j));
@for(areas(i):index(i)>=1;); 地区编号非约束;
@for(areas(i):
@sum(areas(j)|j#ne#i:x(j,i))=1; 入度为1约束;
@sum(areas(j)|j#ne#i:x(i,j))=1;); 出度为1约束;
@for(areas(j)|j#gt#i#and#j#ne#i:index(j)>=index(i)+x(i,j)-n*(1-x(i,j))+(n-1)*x(j,i);); 标号约束(除起始点外标号);
@for(link:@bin(x)); 0-1约束;
@for(areas(i)|i#gt#1:index(i)=1+(n-1)*x(i,1);); 终点标号约束;
end
改成这样 有一个括号位置错了
model:
sets:
areas/1..5/:index; !Hamilton路径号;
link(areas,areas):distance,x; !邻接矩阵和决策矩阵;
endsets
data:
distance=0,300,600,0,0,300,0,300,200,0,600,300,0,0,500,0,200,0,0,200,0,0,500,200,0; !输入19×19的邻接矩阵(此处没有列出);
enddata
n=@size(areas);
min=@sum(link(i,j)|i#ne#j:distance(i,j)*x(i,j));
@for(areas(i):index(i)>=1;); !地区编号非约束;
@for(areas(i):
@sum(areas(j)|j#ne#i:x(j,i))=1; !入度为1约束;
@sum(areas(j)|j#ne#i:x(i,j))=1; !出度为1约束;
@for(areas(j)|j#gt#i#and#j#ne#i:index(j)>=index(i)+x(i,j)-n*(1-x(i,j))+(n-1)*x(j,i))); !标号约束(除起始点外标号);
@for(link:@bin(x)); !0-1约束;
@for(areas(i)|i#gt#1:index(i)=1+(n-1)*x(i,1)); !终点标号约束;
end
model:
sets:
areas/1..5/:index; !Hamilton路径号;
link(areas,areas):distance,x; !邻接矩阵和决策矩阵;
endsets
data:
distance=0,300,600,0,0,300,0,300,200,0,600,300,0,0,500,0,200,0,0,200,0,0,500,200,0; !输入19×19的邻接矩阵(此处没有列出);
enddata
n=@size(areas);
min=@sum(link(i,j)|i#ne#j:distance(i,j)*x(i,j));
@for(areas(i):index(i)>=1;); !地区编号非约束;
@for(areas(i):
@sum(areas(j)|j#ne#i:x(j,i))=1; !入度为1约束;
@sum(areas(j)|j#ne#i:x(i,j))=1; !出度为1约束;
@for(areas(j)|j#gt#i#and#j#ne#i:index(j)>=index(i)+x(i,j)-n*(1-x(i,j))+(n-1)*x(j,i))); !标号约束(除起始点外标号);
@for(link:@bin(x)); !0-1约束;
@for(areas(i)|i#gt#1:index(i)=1+(n-1)*x(i,1)); !终点标号约束;
end