永发信息网

lingo 找错 for循环有问题(在线等)

答案:1  悬赏:60  手机版
解决时间 2021-07-18 22:53
  • 提问者网友:心牵心
  • 2021-07-18 10:01
lingo 找错 for循环有问题(在线等)
我是初学者,运行时显示错误为:subscript out of range on attribute 似乎说是指标超出范围,不是很懂!
model:
sets:
year/1..5/:n,n1,n2,n3,n4,q4;
endsets
data:
n1=122000000000,;
n2=29700000000,;
n3=10100000000,;
n4=3290000000,;
enddata
max = @sum(year:(-17.86*0.42*q4(i)*n3(i)/(0.8+0.42*q4(i)))*(@exp(-2/3*(0.8+0.42*q4(i)))-1)-(22.99*q4(i)*n4(i)/(0.8+q4(i)))*(@exp(-2/3*(0.8+q4(i)))-1));
@for(year(j):n1(j+1)=122000000000*(n3(j)[email protected](-2/3*(0.8+0.42*q4(j)))*110900*0.5+n4(j)[email protected](-2/3*(0.8+q4(j)))*110900)/(122000000000+n3(j)[email protected](-2/3*(0.8+0.42*q4(j)))*110900*0.5+n4(j)[email protected](-2/3*(0.8+q4(j)))*110900));
@for(year(k):n2(k+1)=n1(k)[email protected](-0.8));
@for(year(l):n3(l+1)=n2(l)[email protected](-0.8));
@for(year(m):n4(m+1)=n3(m)[email protected](-2/3*(0.8+0.42*q4(m)))[email protected](-0.8/3)+n4(m)[email protected](-2/3*(0.8+q4(m)))[email protected](-0.8/3));
end
最佳答案
  • 五星知识达人网友:洒脱疯子
  • 2021-07-18 10:59

改好的程序已经给出了,能够运行了,最主要的错误是j+1、k+1、l+1、m+1时超出范围,因为定义时j,k,l,m的最大值为5,而在限制条件中超出了范围!
model:
sets:
year/1..5/:n,n1,n2,n3,n4,q4;
endsets
data:
n1=122000000000,;
n2=29700000000,;
n3=10100000000,;
n4=3290000000,;
enddata
[email protected](year(i):(-17.86*0.42*q4(i)*n3(i)/(0.8+0.42*q4(i)))*(@exp(-2/3*(0.8+0.42*q4(i)))-1)-(22.99*q4(i)*n4(i)/(0.8+q4(i)))*(@exp(-2/3*(0.8+q4(i)))-1));
@for(year(j)|j#le#4:n1(j+1)=122000000000*(n3(j)[email protected](-2/3*(0.8+0.42*q4(j)))*110900*0.5+n4(j)[email protected](-2/3*(0.8+q4(j)))*110900)/(122000000000+n3(j)[email protected](-2/3*(0.8+0.42*q4(j)))*110900*0.5+n4(j)[email protected](-2/3*(0.8+q4(j)))*110900));
@for(year(k)|k#le#4:n2(k+1)=n1(k)[email protected](-0.8));
@for(year(l)|l#le#4:n3(l+1)=n2(l)[email protected](-0.8));
@for(year(m)|m#le#4:n4(m+1)=n3(m)[email protected](-2/3*(0.8+0.42*q4(m)))[email protected](-0.8/3)+n4(m)[email protected](-2/3*(0.8+q4(m)))[email protected](-0.8/3));
end


我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯