Subset of a different set of the indexed one

Archive of Gamsworld Google Group
Post Reply
Archiver
User
User
Posts: 7876
Joined: 7 years ago

Subset of a different set of the indexed one

Post by Archiver »


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.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: Subset of a different set of the indexed one

Post by Archiver »


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.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


--
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.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: Subset of a different set of the indexed one

Post by Archiver »


Hi and Thanks for your reply

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.

Thanks again for your help

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.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


--
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.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: Subset of a different set of the indexed one

Post by Archiver »

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.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


--
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.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.




--
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
User
Posts: 7876
Joined: 7 years ago

Re: Subset of a different set of the indexed one

Post by Archiver »


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.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: Subset of a different set of the indexed one

Post by Archiver »


Thank you Dr. Dirkse

That was helpful.

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.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


--
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.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.




--
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.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
Post Reply