## index of elements in an unordered subset Topic is solved

Problems with syntax of GAMS
Bahar_Mdi
User
Posts: 12
Joined: 1 year ago

### index of elements in an unordered subset

Dear all,

I want to determine the index of elements in an unordered subset in GAMS and I need some help.

for example, I have a set i /1*6/ and I get subset(i) from MATLAB software based on an algorithm that I designed for my problem. a subset(i) contains some elements of i that are sorted in a special way. Consider that I get subset(i) /4,3,1,6,2/ from MATLAB. In my model, I need to have the index of elements in subset(i). for example, I need to have a constraint for elements that are between 3 and 2 in subset(i). I can not use 'ord' because subset(i) is an unordered subset based on i. How should I define the mentioned constraint in my model?

I appreciate it if someone can help me.
Thanks and regards,
Bahar

bussieck
Moderator
Posts: 525
Joined: 4 years ago

### Re: index of elements in an unordered subset

Bahar,

This is not possible with a one dimensional set. In GAMS there is only one order, the input label order, so if you have a set i /1*10/, then all sets with these elements will have this natural order. You can work around this by making your subset two-dimensional: set subset(i,i) / 1.4,2.3,3.1,4.6,5.2/. Now, the first dimension is your index and the second dimension your set element.

Hope this helps,
-Michael

Bahar_Mdi
User
Posts: 12
Joined: 1 year ago

### Re: index of elements in an unordered subset

Thanks a lot for your help.