Multiobjective Output exports

Problems with syntax of GAMS
Post Reply
Posts: 4
Joined: 2 years ago

Multiobjective Output exports

Post by player » 1 month ago


How can I iterate the txt file name (trial-1, trial-2, ... etc.) to get variable values for each weight set (w1, w2) in multi objective opt. model? OR, is it possible to get these in an excel file with different sheets? For example; the results of weight set (5,2) will be exported to the sheet name (5,2) then results of weightset (5,3) will be exported to the sheet named (5,3) but in same excel file?


Code Block:

Code: Select all

file results/C:\Users\Desktop\trial\res\trial-1.txt/;
put results;
put system.ifile/;
put system.time/;
put w1/;
put w2/;
put 'i       j       var 1		var 2'/;
put,,   put var1.l(i), put var2.l(i)/
putclose results;

User avatar
Posts: 933
Joined: 6 years ago

Re: Multiobjective Output exports

Post by bussieck » 1 month ago

You can use w1 and w2 to compose your file name:

Code: Select all

scalar w1,w2;
w1=5; w2=3;
file fx /'trial_w1_w2.txt'/; put_utility fx 'ren' / 'trial_' w1:0:0 '_' w2:0:0 '.txt';
put 'w1=' w1 / 'w2=' w2;
If you run under Windows with Excel installed you can use the gdxxrw tool:

Code: Select all

set i /i1*i10/, j /j1*j5/;
parameter rep(i,j); rep(i,j) = uniformInt(1,10);
scalar w1 /5/, w2 /2/;
file fgdxxrw / '' /;
putclose fgdxxrw 'i=rep.gdx o=trials.xlsx par=rep rng=' w1:0:0 '_' w2:0:0 '!A1';
execute_unload 'rep.gdx', rep;
execute 'gdxxrw';

Post Reply