【问题标题】:When I try to write a variable including different sets I get an error. How can I solve Gams Error 198?当我尝试编写包含不同集合的变量时,出现错误。如何解决 Gams 错误 198?
【发布时间】:2021-05-11 19:13:06
【问题描述】:

当我尝试将变量用作 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)

【问题讨论】:

  • 仅供参考:我在回复中添加了一个链接,这应该有助于解决您的问题。

标签: gams-math


【解决方案1】:

如果您收到错误 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-21
    • 2023-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-17
    • 2020-02-19
    • 1970-01-01
    相关资源
    最近更新 更多