Variable sequence as a set

Problems with modeling
Post Reply
waeltaha
User
User
Posts: 6
Joined: 3 years ago

Variable sequence as a set

Post by waeltaha »

Hi
I need to implement the following
Once I load a scalar value (say value for x) from an excel file, I need to use this value to create a sequence set as follows

Set i sequence given by the user /1*x/

This gives me an error, so how can I create a variable set, where the user will provide the length of this set.

Thank you
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Variable sequence as a set

Post by Renger »

Hi

You could define an overall set with the maximum of x as the number of elements:

Code: Select all

set k /1*10000/;
Then you define a dynamic subset and use the value from excel to define it:

Code: Select all

set  i(k);
i(k)$(val.k < x+1) = YES;
 
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
waeltaha
User
User
Posts: 6
Joined: 3 years ago

Re: Variable sequence as a set

Post by waeltaha »

Dear Renger

Thank you for help. This solution doesn't work with gams 24.5.3. It gives me error 140: unknown symbol and points to val.k; however, when I have tried
k.val instead of val.k, it worked. Thank you.

Regards
Wael
Post Reply