dynamic code to output a set of files, where files and names depend on a set

Hi

I know someone answered a similar Q on this recently but I cannot seem
to find it.

What I want to do is write a separate gdx output file for each year in
the solve. Year is a set, but often changes between runs.


So something like:

Loop (year) do

PlantCap(unit) = PlantCapacity(unit,year);
EXECUTE_UNLOAD ‘RESULTS\GDX\PlantCapacity_XXyearXX’, PlantCap;

endloop;

where the XXyearXX should be replaced by the current year in the loop,
eg we will end up with a file for each year like:
PlantCapacity_2010
PlantCapacity_2011
PlantCapacity_2012
etc

Aside: I am not using a version of GAMS which has macros.

All help appreciated.

Cheers
Andy C

\

Hi,

The GAMS Support wiki has something for this situation:

http://support.gams-software.com/doku.php?id=interfaces:set_identifier_in_gdx_file_name

Regards,
Michael Bussieck - GAMSWorld Coordinator

On Jan 16, 4:38 pm, AC wrote:

Hi

I know someone answered a similar Q on this recently but I cannot seem
to find it.

What I want to do is write a separate gdx output file for each year in
the solve. Year is a set, but often changes between runs.

So something like:

Loop (year) do

PlantCap(unit) = PlantCapacity(unit,year);
EXECUTE_UNLOAD ‘RESULTS\GDX\PlantCapacity_XXyearXX’, PlantCap;

endloop;

where the XXyearXX should be replaced by the current year in the loop,
eg we will end up with a file for each year like:
PlantCapacity_2010
PlantCapacity_2011
PlantCapacity_2012
etc

Aside: I am not using a version of GAMS which has macros.

All help appreciated.

Cheers
Andy C

\