Domain checking

Top  Previous  Next

The GAMS compiler conducts 'domain checking,' with respect to subset definition and set element usage.  Domain checking verifies that each element defined in a subset is in fact a member of the superset.  It also insures that each referenced element of a set in GAMS calculations or other equations is in fact a member of the set associated with the definition of that location in parameters, variables, sets etc.  When the items are not in the domain of the referenced set GAMS issues a compilation error and points to the missing element.

Examples:

(seterr.gms)

In the following case, the elements in bold and blue would pass the domain check, but the elements in bold and red would stimulate compiler errors because Baltimore is not an element of the set places and seatle is a misspelling.

 

Set places list of locations         /boston,Miami,seattle/;

Set place(places)                /boston,Miami,seatle,Baltimore/;

Parameter dataitem(places) / boston 5,Miami 8,seatle 4,Baltimore 3/;

Notes:

Domain checking is automatic and is only suppressed under two circumstances
When the set in the position is either the universal set or is aliased to the universal set as discussed below.
When the $onwarning option is used to suppress domain checking.
Domain checking finds misspellings and omitted elements and thus should be used as often as possible.
Sets with calculated elements cannot be used in definition of item domains.  This will generate a GAMS error. These sets are called dynamic sets.