在GAMS美元中使用变量 [英] Use variable in GAMS dollar

查看:225
本文介绍了在GAMS美元中使用变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个GAMS代码,我想要一个if语句.我已经读过有关美元状况的资料,我认为这可以对我有所帮助.阅读 GAMS用户指南 ,它说:

I have a GAMS code where I want an if statement. I've read about dollar condition and I thought it could help me. Reading GAMS user guide, it says:

美元状况

本节介绍了美元运算符,这是GAMS最强大的功能之一.美元运算符在逻辑条件下运行.如果条件是逻辑条件,则术语$(condition)可以读作使条件有效".

This section introduces the dollar operator , which is one of the most powerful features of GAMS. The dollar operator operates with a logical condition. The term $(condition) can be read as 'such that condition is valid' where condition is a logical condition.

注意: 美元逻辑条件不能包含变量.但是,允许使用可变属性(例如.l和.m).

Attention: The dollar logical conditions cannot contain variables. Variable attributes (like .l and .m) are permitted however.

$运算符用于对条件赋值,表达式和方程式进行建模.以下小节提供了一个示例,以阐明其用法.下一节将单独讨论使用美元条件分别为条件赋值,表达式和方程建模的主题.

The dollar operator is used to model conditional assignments, expressions, and equations. The following subsection provides an example that will clarify its use. The next section will deal individually with the topic of using dollar conditions to model conditional assignments, expressions, and equations respectively.

我已经在我的代码中尝试过,但是仍然发现总是相同的错误:

I have tryed it in my code, but still I found always the same error:

*** C:\ route \ Filename.gms中的错误53

*** Error 53 in C:\route\Filename.gms

不允许进行内源$操作

这是我的实际代码:

ACUMULADO_FIN_GRUPOS(k,l,t)..

GA(k,l,t)$(GA(k,l,t) GE GT(k,l)) =E= 0 ;

(如果变量的值大于或等于另一个变量,我想将其值更改为0).我也尝试使用.l属性:

(I want to change value of a variable to 0 if it is greater or equal to another variable). I have also tryed with .l attribute:

ACUMULADO_FIN_GRUPOS(k,l,t)..

GA(k,l,t)$(GA(k,l,t).l GE GT(k,l).l) =E= 0 ;

但是随后出现下一个错误(仅在.l定义中)

but then next error appears (just in the .l definition)

*** C:\ route \ Filename.gms中的错误8

*** Error 8 in C:\route\Filename.gms

')'预期

请,有人可以帮忙吗?

提前谢谢!

推荐答案

我已经看到我以前的代码不正确,正确的方法是:

I have seen that my previous code was not correct, the correct way is:

ACUMULADO_FIN_GRUPOS(k,l,t)..

GA(k,l,t)$(GA.l(k,l,t) GE GT.l(k,l)) =E= 0 ;

,其中.l之前是设置的定义.

with the .l previous to set definition.

这篇关于在GAMS美元中使用变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆