Export results of different scenarios by using put

Hi All,

My model has 46 different scenarios, and I would like to write the results to an excel file. basically what I would like to have in my excel is like this one

Scenario 1 Scenario 2 Scenario 3 Scenario 4 ……
Obj Function Results Results Results Results
TCG 1 Results Results Results Results
TCG 2 Results Results Results Results
TCG 3 Results Results Results Results
…
Tgn 1 Results Results Results Results
Tgn 2 Results Results Results Results
Tgn 3 Results Results Results Results
….
fgn 1 Results Results Results Results
fgn 2 Results Results Results Results
fgn 3 Results Results Results Results

The code that I wrote is this but it only gives me one result for one iteration

file results / results1.xls/;
Model netgas /all/;
loop(sc,
sub_scen(sc)=yes;
Solve netgas using mip minimizing z;
display G.l,gn.l,CG.l,y.l,deltax.l,gdeltax.l,x.l,f.l;
put results;
put /‘Scenario’///
put sub_scen.ts:46;
put /@1#4 ‘Objective Function’/
zzz.l/;
put /‘Total cumulative generation’/;
loop(q, put TCG.l(q) /);
put /‘Total generation’/;
loop(q, put tgn.l(q)/);
put /‘Total cumulative generation’/;
loop(q, put fgn.l(q)/);
sub_scen(sc)=no;
);

I would really appreciate for your help and time

Akgun


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Hi Akgun



Why don’t you define a parameter that contains all the results:



parameter results(,, sc);





loop(sc,



results(“Obj function”,” “, sc) = obj.l;

results(“TCG”,q,sc) = TCG.L(q);

…



);

** Unload the results to a gdx file, so we can send them to an excel sheet using gdxxrw

execute_unload “result.gdx”, results;

execute ‘GDXXRW.EXE results.gdx par=results rng=results!a1’;



Note that the results for the objective value have an “empty” index, so they fit in the results parameter with the other results.

No need to use the put utility: Use gdxxrw to export the data to excel.



Cheers



Renger


\


Modelworks

Gewerbestrasse 15

3600 Thun – Switzerland

+41 79 818 53 73

Info@modelworks.ch

blog.modelworks.ch











From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Akgun
Sent: Mittwoch, 8. Oktober 2014 18:05
To: gamsworld@googlegroups.com
Subject: Export results of different scenarios by using put



Hi All,



My model has 46 different scenarios, and I would like to write the results to an excel file. basically what I would like to have in my excel is like this one




Scenario 1


Scenario 2


Scenario 3


Scenario 4


……

Obj Function


Results


Results


Results


Results


TCG 1


Results


Results


Results


Results


TCG 2


Results


Results


Results


Results


TCG 3


Results


Results


Results


Results


…


Tgn 1


Results


Results


Results


Results


Tgn 2


Results


Results


Results


Results


Tgn 3


Results


Results


Results


Results


….


fgn 1


Results


Results


Results


Results


fgn 2


Results


Results


Results


Results


fgn 3


Results


Results


Results


Results




The code that I wrote is this but it only gives me one result for one iteration



file results / results1.xls/;

Model netgas /all/;

loop(sc,

sub_scen(sc)=yes;

Solve netgas using mip minimizing z;

display G.l,gn.l,CG.l,y.l,deltax.l,gdeltax.l,x.l,f.l;

put results;

put /‘Scenario’///

put sub_scen.ts:46;

put /@1#4 ‘Objective Function’/

zzz.l/;

put /‘Total cumulative generation’/;

loop(q, put TCG.l(q) /);

put /‘Total generation’/;

loop(q, put tgn.l(q)/);

put /‘Total cumulative generation’/;

loop(q, put fgn.l(q)/);

sub_scen(sc)=no;

);



I would really appreciate for your help and time



Akgun


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.