Syntax for Sorting the Sets

Hello GAMS World,

Suppose we have a have set, as defined below:

set p /p1, p4, p3, p2, p5/;

I wanted to create an another set, say po, which stores the
elements of the set p in a ordered way.

that is, elements of set po should be p1,p2,p3,p4,p5

Kindy, provide me the ways to perform this task.

Arvind,

You cannot store the same set in two different orders in GAMS. Read more about that here:

https://www.gams.com/39/docs/UG_OrderedSets.html#UG_OrderedSets_OrderedAndUnorderedSets

But you can access the set elements out of order. Here’s an old thread on this topic:

https://newforum.gams.com/t/loop-order-of-set-elements/1608/2

HTH,

-Steve