Import Data from Excel into GAMS that contain Zeros

24 Views Asked by At

This might seems simple question. but I don't why I cannot know how to fix this problem.

I have a matrix in a Excell sheet that contain zero values.

enter image description here

But this what is shown is gdx enter image description here

How to transport the same matrix from Excel (with the zeros) in GAMS?

     Sets
     h hours /1*24/
     d days /day1*day2/

     Parameter SR(h,d);

     $Call gdxxrw.exe MyMatrix.xlsx par=SR rng=sheet1!B2:C25 output=MyMatrix.gdx 
     $GDXIN MyMatrix.gdx
     $LOAD SR = SR
     $GDXIN

     display SR;
1

There are 1 best solutions below

0
Lutz On

One of the central ideas in data storage in GAMS and GDX is that data is sparse, i.e. mostly zero. For this, efficient schemes are used to store only the nonzero values. In GAMS it is actually the same if a parameter record in GDX is 0 or if it does not exist. So, probably you do actually not need the 0 entries in GDX at all?

But if you do need it, you can just set the gdxxrw option squeeze (see here) to n.