Define a set enlarging another set

Problems with syntax of GAMS
Post Reply
Graldur
User
User
Posts: 1
Joined: 8 months ago

Define a set enlarging another set

Post by Graldur » 8 months ago

Hello,

for a model I need to define a set that includes all members of a previously defined set + counts further.

So for example I have a set i defined as the numbers from 1 to 10.
Set j is supposed to contain the numbers 1 to n+n-1.
So in this case the numbers from 1 to 19. However I. I would like to find a way to automize this step so that I can just feed in new numbers for set i while set j is calculated automatically.

Can someone help me here?

Thanks,
Graldur

User avatar
Renger
Posts: 127
Joined: 1 year ago

Re: Define a set enlarging another set

Post by Renger » 7 months ago

Hi
I am not sure if the following answers your question.

Define a superset and then a dynamically assigned set as follows:

Code: Select all

set super /1 * 1000/; 

set i(super) /1*10/
     j(super);

* Your code that defines the size of the next set

parameter
    size  Size of next set;
    
 size = 10;
 

j(super)$(ord(super) > 10) and ord(super) < sizej + 10) = YES;

display i,j;

Cheers

Renger

Post Reply