Tuesday, May 20, 2008

surprising GAMS models

I just provided this example:


if(1,
$set name "hello"
else
$set name "world"
);

display "%name%";


which may be surprising to non-expert GAMS users.
Here is one that may even stump hardcore GAMS modelers:


scalar s /NA/;
s$(s>1) = 3.14;
display s;


Question: can you predict the result of the display statement?

2 comments:

  1. Is this a feature or a bug?

    Is there a purpose in returning True to (NA>1)?

    ReplyDelete
  2. Not sure if this is a design bug or feature, but in GAMS any operation on NA returns NA. Hence (NA>1) is evaluated as NA, and $NA is interpreted as true (or rather as "does exist").

    ReplyDelete