lundi 20 novembre 2017

GAMS: Saving outputs generated in a loop to a single .gdx file without overwriting previous entries

I want to have a scenarios of 3 runs in GAMS, where I also want to save each of the 3 randomly selected elements of the set "codes" into a .gdx file, without each entry being overwritten by the next randomly generated output in the loop. How can I prevent this overwritting such that I am able to save each randomly generated output in the loop, in one single output.gdx file? The following is my code so far:

SET
      codes /aaa, aab, aac, aad, aae, aaf, aag, aah, aaj, aak, aal/
      selected(codes);

$gdxout outputs
loop((1,3),
randnumber = uniformint(1,11);
selected(codes)=ord(codes)=randnumber;
execute_unload 'output.gdx',selected;
display selected;
);
$gdxout

The result of my code above gives me a .gdx file with only 1 entry - the last (3rd) randomly selected element of the set "codes". Some help on this will be deeply appreciated.




Aucun commentaire:

Enregistrer un commentaire