Universal Set: * as a set identifier

Top  Previous  Next

Set references may be indefinite allowing any entries at all by referring to the universal set.  This is done by either

Using an * instead of a set name in an item definition, or
Aliasing a set to the universal set (denoted by an *) and then using that set in item definitions.

In either case domain checking is suppressed and any entry whatsoever may be used without error.

Examples:

(sets.gms)

Here I use the universal set in a number of places

 

Set knownset /p1*p4/;

Alias (newuniverse,*);

Set a1(newuniverse);

Parameter  dataitem(*)  data without fixed set assignments /

                              Newitem1 1, newitem2 3/;

Parameter dd(newuniverse);

Dd(knownset)=4;

Dd("newone")=5;

Dataitem("newitem4")=dataitem("newitem1")*dataitem("newitem2");

A1("boston")=yes;

 

where the blue and bolded items are all associated with universal sets and no domain checking is going on and new elements can be freely introduced.

Notes:

Use of universal sets for data input items is not recommended as spelling errors will not generally be detected.
GAMS will check in replacement statements to make sure specifically referenced elements have been defined and will give an error if not (setuniverr.gms).  But this is not done in model equations.
Sometimes this is useful in finding the sets over which data items are defined or in quickly formulating reports.
The universal set is specified as ordered and ordered operators like lag, leads and ORD can be applied to any sets aliased with it.