User Tools

Site Tools


interfaces:creating_a_table_from_gdx_files_generated_by_different_scenario_runs

Creating a Table from gdx files generated by different Scenario Runs

The little programm below merges gdx files generated by different scenarion runs into one file with the data as columns and the scenario names as rows.

* create scenarios
* ----------------

$onecho > temp.gms
set i / i1*i10 /; parameter dat(i);
dat(i) = uniform(1,2); execute_unload 'Scen-A';
dat(i) = uniform(1,2); execute_unload 'Scen-B';
dat(i) = uniform(1,2); execute_unload 'Scen-C';
$offecho
$call =gams temp lo=%gams.lo% ide=%gams.ide% er=%gams.er%

* do reports accross scenarios
* ----------------------------

* --- merge some data for this report
$call =gdxmerge Scen-?.gdx

* --- extract domains from merged gdx
$onecho > temp.gms
set y,i,ii; alias(*,u);
$gdxin merged
$load y=merged_set_1 ii=i
i(u) = sum(y, ii(y,u));
execute_unload 'index';
$offecho
$call =gams temp lo=%gams.lo% ide=%gams.ide% er=%gams.er%

* --- now we start the report getting domains from index
*     and dat from merged
sets y scenarios
     i some index
parameter dat(y,i) merged data;

$gdxin index
$load y i
$gdxin merged
$load dat
$gdxin

display y,i,dat;
----     48 SET y  scenarios
Scen-A,    Scen-B,    Scen-C

----     48 SET i  some index
i1 ,    i2 ,    i3 ,    i4 ,    i5 ,    i6 ,    i7 ,    i8 ,    i9 ,    i10

----     48 PARAMETER dat  merged data
                i1          i2          i3          i4          i5     i6          i7          i8          i9         i10
Scen-A       1.172       1.843       1.550       1.301       1.292  1.224       1.350       1.856       1.067       1.500
Scen-B       1.998       1.579       1.991       1.762       1.131  1.640       1.160       1.250       1.669       1.435
Scen-C       1.360       1.351       1.131       1.150       1.589  1.831       1.231       1.666       1.776       1.304
interfaces/creating_a_table_from_gdx_files_generated_by_different_scenario_runs.txt · Last modified: 2007/08/10 08:58 (external edit)