Page 1 of 1

index of elements in an unordered subset

Posted: Mon Dec 28, 2020 2:19 am
by Bahar_Mdi
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

Re: index of elements in an unordered subset

Posted: Mon Dec 28, 2020 9:11 am
by bussieck
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

Re: index of elements in an unordered subset

Posted: Mon Dec 28, 2020 9:40 am
by Bahar_Mdi
Thanks a lot for your help.