Syntax for Sorting the Sets

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

Syntax for Sorting the Sets

Post by arvindmarandi » 3 months ago

Hello GAMS World,

Suppose we have a have set, as defined below:

Code: Select all

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.

User avatar
dirkse
Moderator
Moderator
Posts: 188
Joined: 6 years ago
Location: Fairfax, VA

Re: Syntax for Sorting the Sets

Post by dirkse » 3 months ago

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_Ordered ... rderedSets

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

viewtopic.php?f=13&t=9537&p=21733&hilit ... ion#p21733

HTH,

-Steve

Post Reply