Reply-to: gamsworld@googlegroups.com

Dear Gamsworld,

I have yet another littel problem with defining Sets in GAMS. I would

like to define a set “dynamically”, not in the sense of defining a set

as a subset of a larger one, but rather to define a set using a

variable, parameter or scalar.

set

j jobid /1*2/ ;

table data(j, type) data

submittime starttime runtime requiredinstances instancetype

userID unitprice fullprice

1 321626 321691 138 1

2 61 0.243336639209984 34.0

2 321626 321691 138 1

3 61 0.458563024119794 64.0

;

parameters endtime(j), begintime(j),capacity(j,resources);

endtime(j)= data(j,‘starttime’)+data(j,‘runtime’);

begintime(j)= data(j,‘starttime’);

mintime=smin(j, begintime(j));

maxtime=smax(j, endtime(j));

set t /mintime*maxtime/;

Given the code, the last line is giving an error, as the set needs to

be defined using a scalar. Is there any way that problem could be

solved without manually defining t, but rather defining t with

parameters? A neat workaround perhaps?

Kind Regards

Chris

\

Hello Chris

You can use this workaround:

set tt /1*100/;

set t(tt);

scalars mintime,maxtime;

mintime=10;

maxtime=20;

t(tt) = YES$(ord(tt) ge mintime and ord(tt) le maxtime);

display t;

The main idea is to declare an auxiliary set (tt) that is large

enough, so it would work with all possible values of mintime and

maxtime.

Regards

Bruno

On 9 ago, 10:46, Bodenstein

wrote:

Dear Gamsworld,

I have yet another littel problem with defining Sets in GAMS. I would

like to define a set “dynamically”, not in the sense of defining a set

as a subset of a larger one, but rather to define a set using a

variable, parameter or scalar.

set

j jobid /1*2/ ;

table data(j, type) data

submittime starttime runtime requiredinstances instancetype

userID unitprice fullprice

1 321626 321691 138 1

2 61 0.243336639209984 34.0

2 321626 321691 138 1

3 61 0.458563024119794 64.0

;

parameters endtime(j), begintime(j),capacity(j,resources);

endtime(j)= data(j,‘starttime’)+data(j,‘runtime’);

begintime(j)= data(j,‘starttime’);

mintime=smin(j, begintime(j));

maxtime=smax(j, endtime(j));

set t /mintime*maxtime/;

Given the code, the last line is giving an error, as the set needs to

be defined using a scalar. Is there any way that problem could be

solved without manually defining t, but rather defining t with

parameters? A neat workaround perhaps?

Kind Regards

Chris

\

Dear Bruno

Thanks, you’re a sport!

I’ve tried all kinds of things, but never thought of using subsets.

Regards

Chris

On 10 Aug., 18:17, Bruno wrote:

Hello Chris

You can use this workaround:

set tt /1*100/;

set t(tt);

scalars mintime,maxtime;

mintime=10;

maxtime=20;

t(tt) = YES$(ord(tt) ge mintime and ord(tt) le maxtime);

display t;

The main idea is to declare an auxiliary set (tt) that is large

enough, so it would work with all possible values of mintime and

maxtime.

Regards

Bruno

On 9 ago, 10:46, Bodenstein

wrote:

Dear Gamsworld,

I have yet another littel problem with defining Sets in GAMS. I would

like to define a set “dynamically”, not in the sense of defining a set

as a subset of a larger one, but rather to define a set using a

variable, parameter or scalar.

set

j jobid /1*2/ ;

table data(j, type) data

submittime starttime runtime requiredinstances instancetype

userID unitprice fullprice

1 321626 321691 138 1

2 61 0.243336639209984 34.0

2 321626 321691 138 1

3 61 0.458563024119794 64.0

;

parameters endtime(j), begintime(j),capacity(j,resources);

endtime(j)= data(j,‘starttime’)+data(j,‘runtime’);

begintime(j)= data(j,‘starttime’);

mintime=smin(j, begintime(j));

maxtime=smax(j, endtime(j));

set t /mintime*maxtime/;

Given the code, the last line is giving an error, as the set needs to

be defined using a scalar. Is there any way that problem could be

solved without manually defining t, but rather defining t with

parameters? A neat workaround perhaps?

Kind Regards

Chris

\