用lingo求解最短路问题,书上有两条语句没看懂,求大神指点.
Model:sets:cities/A,B1,B2,C1,C2,C3,D/;roads(cities,cities)/A,B1A,B2B1,C1B1,C2B1,C3B2,...
Model:
sets:
cities/A,B1,B2,C1,C2,C3,D/;
roads(cities,cities)/
A,B1 A,B2 B1,C1 B1,C2 B1,C3 B2,C1 B2,C2 B2,C3 C1,D C2,D C3,D/:w,x;
endsets
data:
w=2 4 3 3 1 2 3 1 1 3 4;
enddata
n=@size(cities);
min=@sum(roads:w*x);
@for(cities(i)|i#ne#1#and#i#ne#n:
@sum(roads(i,j):x(i,j))=@sum(roads(j,i):x(j,i)));
@sum(roads(i,j)|i#eq#1:x(i,j))=1;
end
倒数第二,第三句是啥意思,按答案理解应该是把x当成布尔变量来处理的吧,不过语句是什么意思来着 展开
sets:
cities/A,B1,B2,C1,C2,C3,D/;
roads(cities,cities)/
A,B1 A,B2 B1,C1 B1,C2 B1,C3 B2,C1 B2,C2 B2,C3 C1,D C2,D C3,D/:w,x;
endsets
data:
w=2 4 3 3 1 2 3 1 1 3 4;
enddata
n=@size(cities);
min=@sum(roads:w*x);
@for(cities(i)|i#ne#1#and#i#ne#n:
@sum(roads(i,j):x(i,j))=@sum(roads(j,i):x(j,i)));
@sum(roads(i,j)|i#eq#1:x(i,j))=1;
end
倒数第二,第三句是啥意思,按答案理解应该是把x当成布尔变量来处理的吧,不过语句是什么意思来着 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询