User Tools

Site Tools


gams:output_zero_values_with_a_display_statement

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
gams:output_zero_values_with_a_display_statement [2021/09/03 15:58]
Atharv Bhosekar removed
— (current)
Line 1: Line 1:
-====== How do I output zero values with a display statement? ====== 
  
-GAMS uses all sparse structures and, in general, having a value of zero and not existing are the same. However GAMS has a special value that means the element in question is numerically zero but that it does exist. That value is EPS. So, if you run the following example: 
-<​code>​ 
-Set i /i1 * i2/; 
-Set j /j1 * j2/; 
-Parameter x(i, j) / 
- i1.j1 11 
- i1.j2 12 
- /; 
-Display x; 
-x(i, j)$(Not x(i, j)) = EPS; 
-Display x; 
-</​code>​ 
-You'll see that the second row of data is written by the second display statement. ​ 
- 
-You could still use x with the EPS entries for computations but you would lose efficiency because x would be treated as dense instead of sparse (no importance for such a tiny example, of course). 
- 
-If you don't like EPS, you can use an acronym instead: 
-<​code>​ 
-Acronym zero; 
-x(i, j)$(Not x(i, j)) = zero; 
-Display x; 
-</​code>​ 
-but then you can't do computations with the result. 
- 
-If you don't like the looks of ''​zero'',​ you can make the acronym equal to lower case letter ''​o''​ instead. If you don't like that, you'll have to switch to writing reports with the Put statement. ​