compile-time variable/Parameter Topic is solved

Problems with syntax of GAMS
Post Reply
irahmati
User
User
Posts: 11
Joined: 2 years ago

compile-time variable/Parameter

Post by irahmati »

Hello guys
Hope you all are fine and healthy.
This is probably a novice question and I hope you don't mind.

What is the difference between a 'parameter' and a 'compile-time variable' ?
I have seen codes starting with compile-time variables, such as:

$set P 130

I don't get what facility it may bring in contrast with defining 'P' as a normal parameter. Specially since using 'P' in the code is a bit harder since it should be referred to as %P%.
Thanks for your consideration
Iman
User avatar
dirkse
Moderator
Moderator
Posts: 214
Joined: 7 years ago
Location: Fairfax, VA

Re: compile-time variable/Parameter

Post by dirkse »

Iman,

A compile-time variable is a mechanism for text substitution. For example, your GAMS code can look like this:

set I;
$gdxin data_%CASENAME%
$load I
$gdxin
blah blah blah
solve m using nlp min z;
execute_unlload 'results_%CASENAME%', blah, blah, blah;

and you can run the GAMS model like this gams xxx.gms --CASENAME=baseline etc

A parameter is a GAMS symbol and more than just some text.

-Steve
irahmati
User
User
Posts: 11
Joined: 2 years ago

Re: compile-time variable/Parameter

Post by irahmati »

Dear Steve,
Thank you very much for the reply.
Also, I'd like to thank you for your answer to someone else's post about the error msg in EMP: "key expected ....... but instance not in variable rim".
Your reply worked for me as well. I truly appreciate your generous efforts,
You're a SAVIOR

Iman

dirkse wrote: 2 years ago Iman,

A compile-time variable is a mechanism for text substitution. For example, your GAMS code can look like this:

set I;
$gdxin data_%CASENAME%
$load I
$gdxin
blah blah blah
solve m using nlp min z;
execute_unlload 'results_%CASENAME%', blah, blah, blah;

and you can run the GAMS model like this gams xxx.gms --CASENAME=baseline etc

A parameter is a GAMS symbol and more than just some text.

-Steve
Post Reply