interfaces:export_of_all_elements_of_the_solution_including_zero-elements_to_gdx_and_excel

If a variable (e.g. x) has all defaults record (e.g. x is a positive variable and x.lo=0, x.up=inf, x.m=0, x.l=0, x.scale=1) then the variable record does not exist. Thus an execute_unload (or other ways to export) to a GDX file will not create this record, and there is no way of exporting a non-existing record to Excel. *Please keep in mind, that the efficiency and performance of GAMS highly relies on a sparse data structure.*

If you want to make sure that all variable records exist before you export, you can set the scale field of a variable to 0.1. Here is an example:

set i / 1*2/; positive variable x(i); x.l('1')=0; x.l('2')=1; * This will only export x('2'); execute_unload 'x1' x.l; * Force the creation of x('1') x.scale(i) = 0.1; execute_unload 'x2' x.l; Execute 'gdxxrw x1.gdx o=x.xls Squeeze=N var=x.l rng=x1!a1 dim=1'; Execute 'gdxxrw x2.gdx o=x.xls Squeeze=N var=x.l rng=x2!a1 dim=1';

As long as you do not use the scale field (or `modelname.scaind=1`

) this will work fine for you.

Another option is to reassign the `x.l=0`

to `x.l=eps`

: `x.l(i,j)$(x.l=0) = eps;`

. The numerical value is still 0, but the record will exist. On the gdxxrw call you can 'rename' eps to zero:

set i / 1*2/; positive variable x(i); x.l('1')=eps; x.l('2')=1; execute_unload 'x3' x.l; Execute 'gdxxrw x3.gdx o=x.xls epsout=0 var=x.l rng=x3!a1 dim=1 ';

IMPRESSUM / LEGAL NOTICE
PRIVACY POLICY
interfaces/export_of_all_elements_of_the_solution_including_zero-elements_to_gdx_and_excel.txt · Last modified: 2013/06/05 08:28 by support