Hello, hope you are all doing fine. I am sorry if this question has been answered previously, however I couldnt find any solution.
Suppose I ran a model 20 times, each with different parameters and solutions. I want to compare the result variables’ levels for each run. I’m trying to do this automatically, as each run is stored in a different GDX - Results1,…,Results20. Is there a way to import those results for a different GAMS file, like in a loop:
SET
k ‘number of import files’ / k1*k20 /
PARAMETER
x(k);
for ( k=1 to 20 …
[And I would import each GDX file]
I really don’t want to dump this in an excel file, and process from it. Is there a way?
Thanks
Francisco
Hi Francisco,
You could use put_utility to do that.
E.g.
variable y;
set k / k1*k20 /;
*create 20 dummy gdx files containing variable x
loop(k,
y.l = ord(k);
* use put utility to send next execute_unload to gdx file y_1.gdx, y_2.gdx,...
put_utility 'gdxout' / 'y_' ord(k):0:0 '.gdx';
execute_unload y;
);
*declare parameter x with index k to store the variable levels
parameter x(k);
*declare helper with same dimension as original variable (here scalar)
scalar xx;
loop(k,
* use put utility to read fom gdx file y_1.gdx, y_2.gdx,... at next execute_load
put_utility 'gdxin' / 'y_' ord(k):0:0 '.gdx';
execute_load xx=y.l;
x(k) = xx;
);
display x;
I hope this helps!
Fred
Hey!
Thank you for your reply. I will try to implement this.