How to keep it compact

Problems with syntax of GAMS
Post Reply
Lenilein78
User
User
Posts: 9
Joined: 6 years ago
Location: Stuttgart, Germany

How to keep it compact

Post by Lenilein78 »

Good Morning GAMS lovers!

I have a small question regarding syntax of variables and parameters expressions: whenever I define a parameter and want to write an expression for that parameter I need to write again "Parameter" before defining the next parameter (see below in bold). Else GAMSide indicates me on its colourful way that there is a syntax issue.
For compactness reasons in long codes I would like to have the possibility to not write "Parameter" or "Variable" every time after an expression...do you know any workaround for that?

Parameter
AH Maximum absolute humidity in hood in g water.(kg dry air)-1 ;
AH = 4.8101*exp(0.0577*dp);
Parameter
l(c) latent heat for the steam condensation at pr(c) in kJ.kg-1;
l(c)= 1.6807*pr(c)*pr(c)-40.975*pr(c)+2270.9 ;

Merci!
GabrielYin
User
User
Posts: 72
Joined: 6 years ago
Location: Dallas, TX, USA
Contact:

Re: How to keep it compact

Post by GabrielYin »

Hi,

If you only need to reduce the times you write the term "Parameter", it is very easy:

Code: Select all

Parameter
AH Maximum absolute humidity in hood in g water.(kg dry air)-1 
l(c) latent heat for the steam condensation at pr(c) in kJ.kg-1;

l(c)= 1.6807*pr(c)*pr(c)-40.975*pr(c)+2270.9 ;
AH = 4.8101*exp(0.0577*dp);
In the first expression of parameter, just skip the semicolon. After the definition of all desired parameters, assign them all as well.

BTW, the first parameter you used here is actually should be defined as "Scalar" since it has no index, though it will not generate any error.

Cheers.
Gabriel
Post Reply