当我尝试编写包含不同集合的变量时,出现错误。如何解决游戏错误 198?

时间:2021-05-11 19:13:06

标签: gams-math

当我尝试将变量用作 v(i+1 , j+1) 时出现错误。 如果我之前仅将 v(i , j) 定义为变量,如何在 GAMS 代码中编写 v(i+1 , j+1) ?

代码中相关部分如下:

variable v(t,f);

eqn3(f,p,t) ..   v(t,f)=g= r(t,p)+ (0.2*0.4*H(p)*v(t+1,f+1) + v(t+1,f)*((1-(0.4)*H(p))*(1-0.8)+(0.4)*H(p)*0.8)+ v(t+1,f-1)*((1-(0.4)*H(p))*0.8); 

我在 eqn3 的以下部分收到错误 198:v(t+1 , f+1)v(t+1, f )v(t+1 , f-1)

1 个答案:

答案 0 :(得分:0)

如果您收到错误 198,您实际上应该看到的比数字多一点。像这样:

  198 Set used in 'ord' or lag is not ordered.
         Hint: Some of the elements of the set were used before this
         was initialized and the order was different from the order used
         in this set. Try to initialize the set earlier.

您是否尝试遵循该提示?

一般来说,在提出此类问题时,您应该尝试在此处分享一个可重现的最小示例。在这里为您提供一些帮助会很有帮助。

编辑:从您现在添加的代码块可以看出,集合 t 似乎是问题所在。虽然,您没有展示这是如何生成的。以下是一些通常会触发此错误的原因以及可以做些什么来避免它:

https://www.gams.com/35/docs/UG_FixingErrors.html#UG_FixingErrors_ErrorO

相关问题