I need to read 20 gdx files with the name from R2G1.gdx to R2G20.gdx,
Tried all I know but still fail. Please kindly comment on it. Thank
you in advance.
My code is:
set scen /R2G1*R2G20/;
set scen_r(scen);
alias (scen_all, scen);
set rg, tp;
$gdxin output\r2g1
$load rg tp
parameter pop(rg,tp);
loop (scen,
scen_r(scen_all)=no;
scen_r(scen)=yes
$set scen_s scen_r
display %scen_s%;
*here I got the display of each item like R2G1, then next loop R2G2…
Execute_load ‘output%scen_r.tl%.gdx’, pop;
Execute_load ‘output%scen_s%.gdx’, pop;
*neither above works.
display pop;
)
\
Since my work is demanding, I worked on it for the whole day.
Now I used another way (2 gms, 1 batch file) to process it which looks
urgely.
I would like to share my work below. I still hope some one can help me
on just
how to use each item of a set as part of name in $gdxin. Thank you.
main.gms
$onecho > iterreading.bat
set scen=R2G1, R2G2, R2G3, …, R2G20
for %%S in (%scen%) do gams emf_gdx_reading --scen_s=%%S
$offecho
$call iterreading.bat
$call gdxmerge merge*.gdx output=merge\mergeall.gdx
emf_gdx_reading.gms
set rg, tp;
$gdxin emf24%scen_s%.gdx
$load rg tp
parameter pop(tp,rg);
$gdxin emf24%scen_s%.gdx
$load pop
Execute_unload “merge\temp_%scen_s%.gdx” pop;
\
Marshal,
We have to do something similar to what you describe for a project we
are working on. The code we use to read a number of spreadsheets, do
some data validation, and combine the data into a single GDX file is
attached. Note that we don’t even try to combine this with the actual
model - the data extraction/validation/prep is a separate model that
we can debug independently from the model that will be using the data.
HTH to give you some ideas at least.
-Steve
On Thu, Mar 31, 2011 at 4:45 PM, Marshal wrote:
Since my work is demanding, I worked on it for the whole day.
Now I used another way (2 gms, 1 batch file) to process it which looks
urgely.
I would like to share my work below. I still hope some one can help me
on just
how to use each item of a set as part of name in $gdxin. Thank you.
main.gms
$onecho > iterreading.bat
set scen=R2G1, R2G2, R2G3, …, R2G20
for %%S in (%scen%) do gams emf_gdx_reading --scen_s=%%S
$offecho
$call iterreading.bat
$call gdxmerge merge*.gdx output=merge\mergeall.gdx
emf_gdx_reading.gms
set rg, tp;
$gdxin emf24%scen_s%.gdx
$load rg tp
parameter pop(tp,rg);
$gdxin emf24%scen_s%.gdx
$load pop
Execute_unload “merge\temp_%scen_s%.gdx” pop;
–
reader.gms (2.12 KB)