Monday, May 19, 2008

EPS and $ in gams

>When I run REAP I get a execution error division by EPS message and I
>can't figure out why. There must be something I'm missing. There are $
>control statements to prevent this from happening and its never been a
>problem before. I've tried placing the $ control conditions on either
>side of the assignment symbol and still get the error.


Yes, EPS is numerically the same as zero. As soon as you start calculating
with it, it is considered the same as zero. However when used as a $
condition it is considered to be nonzero. So


1 scalar a /EPS/;
2 scalar b;
3 b$a=1/a;
4 display a,b;

gives:

**** Exec Error at line 3: division by eps

Indeed this fix is correct:

scalar a /EPS/;
a$(a=EPS) = 0;
scalar b;
b$a=1/a;
display a,b;

this will make a equal to zero if it was EPS and the expression b$a works
again as expected.

No comments:

Post a Comment