Domain checking in sameas (and similar commands)

Problems with syntax of GAMS
Post Reply
Posts: 7
Joined: 4 months ago

Domain checking in sameas (and similar commands)

Post by chrispahm » 1 week ago

As so often when writing code, typos happen. When such a typo occurs in a dollar conditional (in my case today using a sameas operator), and the typo happens to be part of the universal set already (because the typo is a set element from a different set), the GAMS compiler doesn't throw an error.
Consider the following example model:

Code: Select all

Set crops "crops"            / wheat /;
Set bots "botanical group"   / wheats/;

Parameter test(crops);

test("wheat") = 1;

* This should throw an error in my opinion, but it doesn't
test(crops) $ (sameas (crops, "wheats")) = 1 ;
You get the idea. I might be the only one, and I know I could use singletons etc. to work around this issue, but again I feel like the sameas operator should not compare strings against the universal set but rather the set which is referenced in the operator.
Just a feature I wish was included in GAMS.

Post Reply