Parameter data: Par

Top  Previous  Next

When an item containing data along with identifying set elements is to be read or written one uses

 

Par=parametername Rng=DataRange Dimensions SymbolOptions

Examples:

Basic parameter writing is done using commands like (Gdxxrwwrite.gms)

 

execute_unload 'Gdxxrwwrite.gdx' twodim,threedim,i,j,k,ii;

execute "Gdxxrw Gdxxrwwrite.gdx o=gdxxrwss.xls par=twodim Rng=output!a1"

 

which first creates the GDX file called GdxxrwWrite.gdx then uses the Gdxxrw program to save the parameter called TWODIM into the sheet called output starting at the upper left-hand corner A1 while drawing data from GdxxrwWrite.gdx and writing into the spreadsheet called GdxxrwSS.xls.  The resultant spreadsheet segment in the output sheet is as follows

 

_img92

 

Parameters can be read the using essentially the same command with the name of the source spreadsheet appearing after Gdxxrw as follows (Gdxxrwread.gms)

 

$call "Gdxxrw gdxxrwss.xls par=distance Rng=sheet1!a20:d23 rdim=1 cdim=1"

$GDXin gdxxrwss.gdx

$load distance

execute "Gdxxrw gdxxrwss.xls par=distance2 Rng=sheet1!a20:d23"

execute_load 'gdxxrwss.gdx' distance2

Notes:

When writing to a GDX file and moving the data on to a spreadsheet, one should use the GAMS Execute_Unload and Execute commands to ensure that the current parameter data present at the time the Execute_Unload is saved in the GDX file.
One needs to watch out for file names and paths with spaces in them as discussed above.
Use of $Call would write out the data values at compile time not after calculations.
One must use Execute for the Gdxxrw command whenever an Execute_Unload is used.  Otherwise the program will use the last version of the GDX file written by a compile time $Call or a pre-existing GDX file in existence before the program ran.  The GDX file created any Execute_Unload commands immediately before a $Call would not be used as all $ conditions are resolved at compile time then at the later execution time all Execute_Unload and Execute statements are resolved.
GAMS chooses the row and column ordering as well as the way that table is arrayed in the spreadsheet.  Users may contain additional control of the orders using the merge option as discussed below and additional control over the table layout using the CDIM and RDIM options as illustrated next.