Indexing a Set with multiple values

Problems with modeling
Post Reply
pelorn
User
User
Posts: 14
Joined: 3 months ago

Indexing a Set with multiple values

Post by pelorn » 3 months ago

Hi there,

I'm trying some alteration to the DICE2013 model. I define a set of a hundred values and want to access one value for each period t. I.e. if t=5, I want GAMS to return the fifth value in the parameter cereq.

sets t Time periods (5 years per period) / 1*100 /
cereq list of multipliers /v1*v100/

I tried:

cereq(t)$ord((cereq)=t)

but that causes the program to crash.

How do I have to do this?

Many thanks

mkbonde
User
User
Posts: 2
Joined: 4 months ago

Re: Indexing a Set with multiple values

Post by mkbonde » 3 months ago

You can compare the positions of the two elements in their respective sets by writing

Code: Select all

$(ord(cereq)=ord(t))
or compare the position of cereq with the value of t:

Code: Select all

$(ord(cereq)=t.val)
Using .val is useful when comparing numerical sets that don't naturally start at 1, for example years.

pelorn
User
User
Posts: 14
Joined: 3 months ago

Re: Indexing a Set with multiple values

Post by pelorn » 3 months ago

Thank you!

Post Reply