## Subset of a different set of the indexed one

Archiver
User
Posts: 7876
Joined: 1 year ago

### Subset of a different set of the indexed one

Hi every one

I have a q with GAMS

I need to introduce the set tw(i) as in this sample:

set i/1*3/,
parameters tl(i)
/1 3
2 1
3 5/,
tu(i)
/1 15
2 12
3 16/;
set tw(i) /tl(i)*tu(i)/; *Error and problem

I want tw sets for each i so the result should be:
tw(1) from 3 to 15
tw(2) from 1 to 12
tw(3) from 5 to 16

I used to enter it manually but now I need to program it to sum over 'tw' the subset of 't'

con2(i);
con2(i).. sum(tw(i),del(i,t)) =e= 1;

I appreciate any help

Thanks and Regards

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.

Archiver
User
Posts: 7876
Joined: 1 year ago

### Re: Subset of a different set of the indexed one

Hey, as far as I know, there is no way to create a "family" of sets. It should be easy to copy-paste-search-replace-text-editor-automate this kind of structure:

set t /1*100/

tw1(t)
tw2(t)
...
twn(t)

tw1(t)=YES\$(ord(t)>tl(1) and ord(t)tl(2) and ord(t)tl(n) and ord(t) wrote:

Hi every one

I have a q with GAMS

I need to introduce the set tw(i) as in this sample:

set i/1*3/,
parameters tl(i)
/1 3
2 1
3 5/,
tu(i)
/1 15
2 12
3 16/;
set tw(i) /tl(i)*tu(i)/; *Error and problem

I want tw sets for each i so the result should be:
tw(1) from 3 to 15
tw(2) from 1 to 12
tw(3) from 5 to 16

I used to enter it manually but now I need to program it to sum over 'tw' the subset of 't'

con2(i);
con2(i).. sum(tw(i),del(i,t)) =e= 1;

I appreciate any help

Thanks and Regards

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.

Archiver
User
Posts: 7876
Joined: 1 year ago

### Re: Subset of a different set of the indexed one

I realized that now I'm trying to create the sets in Matlab and creating GDX and read it in GAMS.
However, GAMS gave me error 832 Can only load parameters and scalars
Can't I transfer sets from Matlab to GAMS?
The reason for that is I'm creating tl(i) and tu(i) randomly in Matlab with other processes.

On Friday, April 1, 2016 at 10:07:00 AM UTC+3, Claudio Delpino wrote:

Hey, as far as I know, there is no way to create a "family" of sets. It should be easy to copy-paste-search-replace-text-editor-automate this kind of structure:

set t /1*100/

tw1(t)
tw2(t)
...
twn(t)

tw1(t)=YES\$(ord(t)>tl(1) and ord(t)tl(2) and ord(t)tl(n) and ord(t) wrote:

Hi every one

I have a q with GAMS

I need to introduce the set tw(i) as in this sample:

set i/1*3/,
parameters tl(i)
/1 3
2 1
3 5/,
tu(i)
/1 15
2 12
3 16/;
set tw(i) /tl(i)*tu(i)/; *Error and problem

I want tw sets for each i so the result should be:
tw(1) from 3 to 15
tw(2) from 1 to 12
tw(3) from 5 to 16

I used to enter it manually but now I need to program it to sum over 'tw' the subset of 't'

con2(i);
con2(i).. sum(tw(i),del(i,t)) =e= 1;

I appreciate any help

Thanks and Regards

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.

Archiver
User
Posts: 7876
Joined: 1 year ago

### Re: Subset of a different set of the indexed one

Claudio,

You can make this data-driven in GAMS. For example, try something like this:

sets
i / i1*i5 /
t / 1*100 /
it(i,t) 'subset of t for each i'
;
parameter
lim(i) /
i1 14
i2 44
i3 54
i4 64
i5 [card(t)]
/
;
abort\$[smin{i, lim(i) - lim(i-1)} lim(i-1)] and [ord(t) wrote:

Hey, as far as I know, there is no way to create a "family" of sets. It should be easy to copy-paste-search-replace-text-editor-automate this kind of structure:

set t /1*100/

tw1(t)
tw2(t)
...
twn(t)

tw1(t)=YES\$(ord(t)>tl(1) and ord(t)tl(2) and ord(t)tl(n) and ord(t) wrote:

Hi every one

I have a q with GAMS

I need to introduce the set tw(i) as in this sample:

set i/1*3/,
parameters tl(i)
/1 3
2 1
3 5/,
tu(i)
/1 15
2 12
3 16/;
set tw(i) /tl(i)*tu(i)/; *Error and problem

I want tw sets for each i so the result should be:
tw(1) from 3 to 15
tw(2) from 1 to 12
tw(3) from 5 to 16

I used to enter it manually but now I need to program it to sum over 'tw' the subset of 't'

con2(i);
con2(i).. sum(tw(i),del(i,t)) =e= 1;

I appreciate any help

Thanks and Regards

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.

--
Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com

Archiver
User
Posts: 7876
Joined: 1 year ago

### Re: Subset of a different set of the indexed one

Hello,thefooox1,
I suggest a function named alias,which is used like this,
alias(ii,i);
and then,

tw(ii) =tl(i)*tu(i); is written by equation to be caculated.

åœ¨ 2016å¹´3æœˆ30æ—¥æ˜ŸæœŸä¸‰ UTC+8ä¸Šåˆ8:30:15ï¼Œthefooox1å†™é“ï¼š

Hi every one

I have a q with GAMS

I need to introduce the set tw(i) as in this sample:

set i/1*3/,
parameters tl(i)
/1 3
2 1
3 5/,
tu(i)
/1 15
2 12
3 16/;
set tw(i) /tl(i)*tu(i)/; *Error and problem

I want tw sets for each i so the result should be:
tw(1) from 3 to 15
tw(2) from 1 to 12
tw(3) from 5 to 16

I used to enter it manually but now I need to program it to sum over 'tw' the subset of 't'

con2(i);
con2(i).. sum(tw(i),del(i,t)) =e= 1;

I appreciate any help

Thanks and Regards

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.

Archiver
User
Posts: 7876
Joined: 1 year ago

### Re: Subset of a different set of the indexed one

Thank you Dr. Dirkse

On Saturday, April 2, 2016 at 7:23:31 AM UTC+3, Steven Dirkse wrote:

Claudio,

You can make this data-driven in GAMS. For example, try something like this:

sets
i / i1*i5 /
t / 1*100 /
it(i,t) 'subset of t for each i'
;
parameter
lim(i) /
i1 14
i2 44
i3 54
i4 64
i5 [card(t)]
/
;
abort\$[smin{i, lim(i) - lim(i-1)} lim(i-1)] and [ord(t) wrote:

Hey, as far as I know, there is no way to create a "family" of sets. It should be easy to copy-paste-search-replace-text-editor-automate this kind of structure:

set t /1*100/

tw1(t)
tw2(t)
...
twn(t)

tw1(t)=YES\$(ord(t)>tl(1) and ord(t)tl(2) and ord(t)tl(n) and ord(t) wrote:

Hi every one

I have a q with GAMS

I need to introduce the set tw(i) as in this sample:

set i/1*3/,
parameters tl(i)
/1 3
2 1
3 5/,
tu(i)
/1 15
2 12
3 16/;
set tw(i) /tl(i)*tu(i)/; *Error and problem

I want tw sets for each i so the result should be:
tw(1) from 3 to 15
tw(2) from 1 to 12
tw(3) from 5 to 16

I used to enter it manually but now I need to program it to sum over 'tw' the subset of 't'

con2(i);
con2(i).. sum(tw(i),del(i,t)) =e= 1;

I appreciate any help

Thanks and Regards

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.

--
Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdi...@gams.com
http://www.gams.com

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.