I am trying to implement nested GAMS calls.
To be more concrete, I have a top-level GAMS file, say, root.GMS, which calls a PowerShell script, say myscript.ps1, with the following code:
Code: Select all
execute "powershell -File C:\gams\MyModel\myscript.ps1"
Code: Select all
$Years = (2013..2030)
foreach ($CurrentYr in $Years ) {
gams branch.GMS --year=$CurrentYr
}
One obvious solution would be to split root.GMS in two, and to use the save and restart facilities. The first part would include all the code up to the call to myscript.ps1 (call this root1.GMS), and the second part would include all the code from myscript.ps1. (call this root2.GMS).
The following PowerShell code should work then (assuming no parameters are defined in branch.GMS that are needed in root2.GMS):
Code: Select all
gams root1.GMS s=root1
$Years = (2013..2030)
foreach ($CurrentYr in $Years ) {
gams branch.GMS --year=$CurrentYr r=root1
}
gams root2.GMS r=root1