Use variable in GAMS dollar

烂漫一生 提交于 2019-12-08 08:16:00

问题


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:

The Dollar 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.

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:

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

Endogenous $ operation not allowed

This is my actual code:

ACUMULADO_FIN_GRUPOS(k,l,t)..

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

(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 ;

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

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

')' expected

Please, could anyone help?

Thanks in advance!!


回答1:


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 ;

with the .l previous to set definition.



来源:https://stackoverflow.com/questions/37861471/use-variable-in-gams-dollar

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!