sorting values in a variable
Posted: Wed Oct 31, 2018 9:13 am
Hello,
I have a problem for my PhD thesis in GAMS. The problem is I have a variable (not parameter) c(j) and I calculated it with my function. And after 5 indices the 6th indice value must be made by comparing the rest of 5 c(j) values, it is a condition. However, it has to be done by sorting as I guess. For example first five c(j) are 35, 48, 12, 45, 64 and 6th will be constrained by using the smallest of the rest of all. In that example, obviously it is 12, however I know it but the model doesnt know it, so I have to sort the c(j) in ascending, so in this way I hope I can compare by (k-5) which compares c(6) and c(1) then c(7) and c(2) etc. Is there any idea how I can do it.
Thanks in advance.
I have a problem for my PhD thesis in GAMS. The problem is I have a variable (not parameter) c(j) and I calculated it with my function. And after 5 indices the 6th indice value must be made by comparing the rest of 5 c(j) values, it is a condition. However, it has to be done by sorting as I guess. For example first five c(j) are 35, 48, 12, 45, 64 and 6th will be constrained by using the smallest of the rest of all. In that example, obviously it is 12, however I know it but the model doesnt know it, so I have to sort the c(j) in ascending, so in this way I hope I can compare by (k-5) which compares c(6) and c(1) then c(7) and c(2) etc. Is there any idea how I can do it.
Thanks in advance.