Using another name or an alias

Top  Previous  Next

There are occasions when one may wish to address a single set more than once in a statement.  In GAMS this is done by giving the set another name through the ALIAS command as follows

 

ALIAS(knownset,newset1,newset2,...);

 

where each of the new sets will refer to the same elements as in the existing known set.  As an alternative to this one can use the .Local notation but generally only in macros and only ith care..

Examples:

(sets.gms)

Suppose I have a two-dimensional data item that addresses the same set in both dimensions and I wish to compute the cost from each place to each other as a function of distance.  To do this I use an alias as follows

 

Set place        /p1,p2/;

Alias(place,otherplace);

Table distplace(place,place)  distaces

           P1   p2

P1         0    4

P2         4    0;

Parameter cost(place,place) cost data;

Cost(place,otherplace)=1+5*distplace(place,otherplace);