Daria
Daria

Reputation: 1

How can I get one element from a set in GAMS?

I have a set
I workers /W1,W2,W3/ and variable T(I) time Wi does his work I need to write a function T1<=T2, so I need to get first and second elements of set I. How can I do this? this EQUATIONS eq1; eq1 .. T(I('1')) =le= T(I('2')) doesn't work

Upvotes: 0

Views: 1992

Answers (1)

Martin Bonde
Martin Bonde

Reputation: 556

You can either write

T("W1")

or

T(i)$(ord(i)=1)

In the first case, we reference the particular set element directly.

In the second case, ord() gives us the "the position of this particular setelement within the overall set". From that we check if i is element number 1. We can use a $-condition to limit a variable or set this way.

Upvotes: 1

Related Questions