作业帮 > 英语 > 作业

为什么下面程序用lingo运行时出现subscript out of range on attribute 求解释?

来源:学生作业帮 编辑:搜搜考试网作业帮 分类:英语作业 时间:2024/07/28 20:39:36
为什么下面程序用lingo运行时出现subscript out of range on attribute 求解释?
model:
sets:
cities/s,a1,a2,a3,b1,b2,c1,c2,t/:l;
roads(cities,cities)/
s,a1 s,a2 s,a3
a1,b1 a1,b2 a2,b1 a2,b2 a3,b1 a3,b2
b1,c1 b1,c2 b2,c1 b2,b2
c1,t c2,t/:d;
endsets
data:
d= 6 3 3
6 5 8 6 7 4
6 7 8 9
5 6;
l=0, , , , , , , ,;
enddata
@for(cities(i)|i#gt#1:
l(i)=@min(roads(j,i):l(j)+d(i,j)););
@free(i);@free(j);
end
为什么下面程序用lingo运行时出现subscript out of range on attribute 求解释?
你这个问题是什么 我只能这样给你改了
model:
sets:
cities/s,a1,a2,a3,b1,b2,c1,c2,t/:l;
roads(cities,cities)/
s,a1 s,a2 s,a3
a1,b1 a1,b2 a2,b1 a2,b2 a3,b1 a3,b2
b1,c1 b1,c2 b2,c1 b2,b2
c1,t c2,t/:d;
endsets
data:
d= 6 3 3
6 5 8 6 7 4
6 7 8 9
5 6;
enddata
calc:
l(1)=0;
@for(cities(i)|i#gt#1:
l(i)=@min(cities(j)|@in(roads,i,j):l(j)+d(i,j)););
endcalc
end
再问:   图3-22  最短路问题的模这是我看的一个教程的截图,我上边的程序和他的一样可没法运行,我把你修改后的程序运行了一下可以,但结果和教程中的结果不一样,能不能再解释一下。谢谢!
再答: 那个教程写的不对 别管他