Hello,
I’m a new GAMs user and was trying to setup a simple system using excel to control some $include codes in my GAMs program. Here’s what I did:
1.) In excel setup a column of names in an excel document I call “dashboard.xlsx” (I also setup an index sheet):
CONTROLS name
filename1 1
filename2 1
filename3 1
filename4 0
filename5 0
filename6 0
The filenames1-6 are names of GAMs code files I would like to run $include on. But I want control over which $includes run via this excel sheet.
2.) Next in GAMs I read in the above as a parameter:
set func functions /filename1, filename2, filename3, filename4, filename5, filename6/;
parameter cfunctions(func) Read in items to be used to control model flow;
$call “gdxxrw input=dashboard.xlsx output=dashboard.gdx index=Index!a2”
$gdxin dashboard.gdx
$load cfunctions
3.) using “display” to check, I find that the set “cfunctions” only reads in “filename1, filename2, filename3” as those have a “1” value, but filenames4-6 are omitted. I believe this is what I want.
4.) Finally I was attempting to use $if statements to run $include:
$if cfunctions(“filename1”)=1
$include filename1.gms
$elseif cfunctions(“filename2”)=1
$include filename2.gms
$elseif cfunctions(“filename3”)=1
$include filename3.gms
$elseif cfunctions(“filename4”)=1
$include filename4.gms
$elseif cfunctions(“filename5”)=1
$include filename5.gms
$elseif cfunctions(“filename6”)=1
$include filename6.gms
(This is just one variant of the $if statements I have tried)
However, I get error $282, or “gams could not open the $include file”. My question is, is it possible to use excel to control $includes? If so what am I doing incorrectly? I’d appreciate any tips/tricks, thank you!