Question on double-dash parameters and the $call command

Problems with syntax of GAMS
Post Reply
henryhu.89
User
User
Posts: 15
Joined: 3 years ago

Question on double-dash parameters and the $call command

Post by henryhu.89 »

Hello,

I have been trying to use a .bat file with double-dashed parameters to execute a series of models (say, model1, model2 & model3). In addition, I wrote a shell program to execute the 4 models in sequence:

Code: Select all

$call '"E:\GAMS\36\gams.exe" folder1/model1.gms'
$call '"E:\GAMS\36\gams.exe" folder2/model2.gms'
$call '"E:\GAMS\36\gams.exe" folder3/model3.gms'
The double-dashed parameters are contained inside the "model#.gms" code and assigned to scalars which are also generated there. When running each model separately they work. However, when I try to use the .bat file to execute the model (also passing it inputs in the form of double-dashed variables), it seems that the models are not receiving this inputs. Inside the model files I have used "set global" and I found this statement in the GAMs manual: $setGlobal -> Available in the input file where they are defined, in all parent files and in all include files.

It seems to me that the statement is saying that the double-dashed parameters should be defined everywhere so long as I use "$setGlobal", which doesn't seem to be the case (unless I am missing something). My question is: can I pass double-dashed parameters to multiple separate models through a shell-loop like the code above? Thanks in advance for any tips/recommendations.
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: Question on double-dash parameters and the $call command

Post by bussieck »

I don't fully understand your setup. But here are a few remarks, that might be helpful:
  • --xxx=yyy on the command line creates a scoped compile time variable xxx with value yyy
  • You can pass a compile time variable on to another GAMS process (that is e.g. spawned with $call) by adding --xxx=%xxx% to the call
So if your bat (I usually use cmd files) looks as follows:

Code: Select all

gams mymodel --data=abc
gams mymodel --data=def
gams mymodel --data=ghi
gams mymodel --data=jkl
Then you can pass on "data" in your GAMS model mymodel.gms (which calls your three submodels) like this:

Code: Select all

$call '"E:\GAMS\36\gams.exe" folder1/model1.gms --data=%data%'
$call '"E:\GAMS\36\gams.exe" folder2/model2.gms --data=%data%'
$call '"E:\GAMS\36\gams.exe" folder3/model3.gms --data=%data%'
Hope this helps,
-Michael
henryhu.89
User
User
Posts: 15
Joined: 3 years ago

Re: Question on double-dash parameters and the $call command

Post by henryhu.89 »

Ah! That makes sense, I guess I need to tell GAMs to pass on these variables in the subsequent "$call" command. Thanks for the tip, this was helpful!
Post Reply