Subsets and handling in equations

Dear members of Gamsworld,

I am sitting in front of a MIP code, which is bothering me quite a time and I have not found a solution so far.
Quickly explaines in words what I want to achieve:

I have a set J consisting of several cities (e.g. New York, Chicago, Miami → 1, 2, 3). I defined a subset which consists of a selection of those cities:

Sets
j set of cities /1*3/; This is the whole set

Set j_o(j) subset1 /1,3/; This is subset 1 of set J
Set j_c(j) subset2 /2/; This is subset 2 of set J

The division is used as an initialization because some cities are active in period t=1, others are not. During the course of time, the activity may change.
Following restrictions on the activity:

  1. a city of subset1 needs to be active in period t=1
  2. an active city (subset1) can become inactive during the planning horizon, but is not allowed to be reactivated
  3. an inactive city (subset2) can become active and will stay active for the rest of the planning horizon

In order to model the sets with equations I tried the following, but I guess I am doing something wrong here with the sets.

  1. open_begin(j_o,t)$(ord(t)=1)… x(t,j) =e= 1; This equation should be for all x(t,j) which belong to t=1 and the subset1 of set J
  2. no_reopen(j_o,t)… x(t,j) =g= x(t,j)$(ord(t)=ord(t)+1); This equation should be for all x(t,j) which belong to the subset1 of set J, the expression with “ord” should model x(t,j) =g= x(“t+1”,j) and I hope I did this part correct
  3. open_new(j_c,t)… x(t,j) =l= x(t,j)$(ord(t)=ord(t)+1); This equation should be for all x(t,j) which belong to the subset2 of set J

I think this may be an easy one for GAMS professionals, but I am just stuck and don’t know how to solve it. I googled a lot, but unfortunately no success on that last little step.

Thanks a lot to all!




\

To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/4slXH4XFFosJ.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Hi Martin



In the first equation be sure that you have the same sets on both sides: open:_being(j_o,t)$… x(t,j_o) and not x(t,j). This will cause problems because can’t find the index j_o in the equation



you can just use x(t+,j) instead of ord(t) = ord(t)+1.

Cheers



Rehger


Modelworks

Gewerbestrasse 15

3600 Thun – Switzerland

+41 79 818 53 73

Info@modelworks.ch

blog.modelworks.ch
From: gamsworld@googlegroups.com [gamsworld@googlegroups.com] on behalf of JapanGo [markusinjapan@googlemail.com]
Sent: Friday, October 26, 2012 13:25
To: gamsworld@googlegroups.com
Subject: Subsets and handling in equations

Dear members of Gamsworld,

I am sitting in front of a MIP code, which is bothering me quite a time and I have not found a solution so far.
Quickly explaines in words what I want to achieve:

I have a set J consisting of several cities (e.g. New York, Chicago, Miami → 1, 2, 3). I defined a subset which consists of a selection of those cities:

Sets
j set of cities /1*3/; This is the whole set

Set j_o(j) subset1 /1,3/; This is subset 1 of set J
Set j_c(j) subset2 /2/; This is subset 2 of set J

The division is used as an initialization because some cities are active in period t=1, others are not. During the course of time, the activity may change.
Following restrictions on the activity:

  1. a city of subset1 needs to be active in period t=1
  2. an active city (subset1) can become inactive during the planning horizon, but is not allowed to be reactivated
  3. an inactive city (subset2) can become active and will stay active for the rest of the planning horizon

In order to model the sets with equations I tried the following, but I guess I am doing something wrong here with the sets.

  1. open_begin(j_o,t)$(ord(t)=1)… x(t,j) =e= 1; This equation should be for all x(t,j) which belong to t=1 and the subset1 of set J
  2. no_reopen(j_o,t)… x(t,j) =g= x(t,j)$(ord(t)=ord(t)+1); This equation should be for all x(t,j) which belong to the subset1 of set J, the expression with “ord” should model x(t,j) =g= x(“t+1”,j) and I hope I did this part correct
  3. open_new(j_c,t)… x(t,j) =l= x(t,j)$(ord(t)=ord(t)+1); This equation should be for all x(t,j) which belong to the subset2 of set J

I think this may be an easy one for GAMS professionals, but I am just stuck and don’t know how to solve it. I googled a lot, but unfortunately no success on that last little step.

Thanks a lot to all!




\

To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/4slXH4XFFosJ.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Hi,

I also have a similar problem concerning the sub sets.

I’m confused about your reply. In the first equation, if you change x(t,j) to x(t,j_o), then how to capture the fact that j_o is a sub set of j?

If I have a variable x (t,j) and I want to sum x(t,j) at diffent t, but at different t, the elements of j will be differnt.

In Japango’s example,
when t=1, I want to sum x(1,j_o)
when t=2, I wnat to sum x(2,j_c)

how to define this?
Thank you very much.

Regards,
Nan



On Friday, October 26, 2012 8:38:31 PM UTC+8, Renger van Nieuwkoop wrote:

Hi Martin



In the first equation be sure that you have the same sets on both sides: open:_being(j_o,t)$… x(t,j_o) and not x(t,j). This will cause problems because can’t find the index j_o in the equation



you can just use x(t+,j) instead of ord(t) = ord(t)+1.

Cheers



Rehger


Modelworks

Gewerbestrasse 15

3600 Thun – Switzerland

+41 79 818 53 73

Info@modelworks.ch

blog.modelworks.ch
From: gams...@googlegroups.com [gams…@googlegroups.com] on behalf of JapanGo [markus…@googlemail.com]
Sent: Friday, October 26, 2012 13:25
To: gams...@googlegroups.com
Subject: Subsets and handling in equations

Dear members of Gamsworld,

I am sitting in front of a MIP code, which is bothering me quite a time and I have not found a solution so far.
Quickly explaines in words what I want to achieve:

I have a set J consisting of several cities (e.g. New York, Chicago, Miami → 1, 2, 3). I defined a subset which consists of a selection of those cities:

Sets
j set of cities /1*3/; This is the whole set

Set j_o(j) subset1 /1,3/; This is subset 1 of set J
Set j_c(j) subset2 /2/; This is subset 2 of set J

The division is used as an initialization because some cities are active in period t=1, others are not. During the course of time, the activity may change.
Following restrictions on the activity:

  1. a city of subset1 needs to be active in period t=1
  2. an active city (subset1) can become inactive during the planning horizon, but is not allowed to be reactivated
  3. an inactive city (subset2) can become active and will stay active for the rest of the planning horizon

In order to model the sets with equations I tried the following, but I guess I am doing something wrong here with the sets.

  1. open_begin(j_o,t)$(ord(t)=1)… x(t,j) =e= 1; This equation should be for all x(t,j) which belong to t=1 and the subset1 of set J
  2. no_reopen(j_o,t)… x(t,j) =g= x(t,j)$(ord(t)=ord(t)+1); This equation should be for all x(t,j) which belong to the subset1 of set J, the expression with “ord” should model x(t,j) =g= x(“t+1”,j) and I hope I did this part correct
  3. open_new(j_c,t)… x(t,j) =l= x(t,j)$(ord(t)=ord(t)+1); This equation should be for all x(t,j) which belong to the subset2 of set J

I think this may be an easy one for GAMS professionals, but I am just stuck and don’t know how to solve it. I googled a lot, but unfortunately no success on that last little step.

Thanks a lot to all!




\

To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/4slXH4XFFosJ.
To post to this group, send email to gams...@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/hHCfNEdPDsAJ.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Hi Nan



J_o is defined as a subset of j (j_o(j), so no need to have this somewhere in the equation).



Your second question:



A possible solution would be



total(t) =E= sum(j_o, x(1,j_o))(ord(t) Eq 1) + sum(j_o, x(1,j_c))(ord(t) Eq 2)



Cheers

Renger







From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Nan Yu
Sent: Saturday, October 27, 2012 9:32 AM
To: gamsworld@googlegroups.com
Subject: Re: Subsets and handling in equations



Hi,



I also have a similar problem concerning the sub sets.



I’m confused about your reply. In the first equation, if you change x(t,j) to x(t,j_o), then how to capture the fact that j_o is a sub set of j?



If I have a variable x (t,j) and I want to sum x(t,j) at diffent t, but at different t, the elements of j will be differnt.



In Japango’s example,

when t=1, I want to sum x(1,j_o)

when t=2, I wnat to sum x(2,j_c)



how to define this?

Thank you very much.



Regards,

Nan






On Friday, October 26, 2012 8:38:31 PM UTC+8, Renger van Nieuwkoop wrote:

Hi Martin



In the first equation be sure that you have the same sets on both sides: open:_being(j_o,t)$… x(t,j_o) and not x(t,j). This will cause problems because can’t find the index j_o in the equation



you can just use x(t+,j) instead of ord(t) = ord(t)+1.

Cheers



Rehger


Modelworks

Gewerbestrasse 15

3600 Thun – Switzerland

+41 79 818 53 73

Info@modelworks.ch

blog.modelworks.ch

From: gams...@googlegroups.com [gams…@googlegroups.com] on behalf of JapanGo [markus…@googlemail.com]
Sent: Friday, October 26, 2012 13:25
To: gams...@googlegroups.com
Subject: Subsets and handling in equations

Dear members of Gamsworld,

I am sitting in front of a MIP code, which is bothering me quite a time and I have not found a solution so far.
Quickly explaines in words what I want to achieve:

I have a set J consisting of several cities (e.g. New York, Chicago, Miami → 1, 2, 3). I defined a subset which consists of a selection of those cities:

Sets
j set of cities /1*3/; This is the whole set

Set j_o(j) subset1 /1,3/; This is subset 1 of set J
Set j_c(j) subset2 /2/; This is subset 2 of set J

The division is used as an initialization because some cities are active in period t=1, others are not. During the course of time, the activity may change.
Following restrictions on the activity:

  1. a city of subset1 needs to be active in period t=1
  2. an active city (subset1) can become inactive during the planning horizon, but is not allowed to be reactivated
  3. an inactive city (subset2) can become active and will stay active for the rest of the planning horizon

In order to model the sets with equations I tried the following, but I guess I am doing something wrong here with the sets.

  1. open_begin(j_o,t)$(ord(t)=1)… x(t,j) =e= 1; This equation should be for all x(t,j) which belong to t=1 and the subset1 of set J
  2. no_reopen(j_o,t)… x(t,j) =g= x(t,j)$(ord(t)=ord(t)+1); This equation should be for all x(t,j) which belong to the subset1 of set J, the expression with “ord” should model x(t,j) =g= x(“t+1”,j) and I hope I did this part correct
  3. open_new(j_c,t)… x(t,j) =l= x(t,j)$(ord(t)=ord(t)+1); This equation should be for all x(t,j) which belong to the subset2 of set J

I think this may be an easy one for GAMS professionals, but I am just stuck and don’t know how to solve it. I googled a lot, but unfortunately no success on that last little step.

Thanks a lot to all!



\

To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/4slXH4XFFosJ.
To post to this group, send email to gams...@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/hHCfNEdPDsAJ.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Hej Rehger,

Thanks a lot for your reply. I knew it was easy :wink:
Thanks also for the hint that I can simply use “t+1”. I did use the “ord” because I thought I read somewhere “t+1” ist not possible, but it seems to be working.

When I run the model now it strangely keeps all cities active which I initially chose (even if it is not the optimal solution in the non-dynamic case).
The three constraints below should “force” the model to change activity in the course of time (=t) in oder to come to the optimal solution.

Any clues?

Am Freitag, 26. Oktober 2012 14:38:31 UTC+2 schrieb Renger van Nieuwkoop:

Hi Martin



In the first equation be sure that you have the same sets on both sides: open:_being(j_o,t)$… x(t,j_o) and not x(t,j). This will cause problems because can’t find the index j_o in the equation



you can just use x(t+,j) instead of ord(t) = ord(t)+1.

Cheers



Rehger


Modelworks

Gewerbestrasse 15

3600 Thun – Switzerland

+41 79 818 53 73

Info@modelworks.ch

blog.modelworks.ch
From: gams...@googlegroups.com [gams…@googlegroups.com] on behalf of JapanGo [markus…@googlemail.com]
Sent: Friday, October 26, 2012 13:25
To: gams...@googlegroups.com
Subject: Subsets and handling in equations

Dear members of Gamsworld,

I am sitting in front of a MIP code, which is bothering me quite a time and I have not found a solution so far.
Quickly explaines in words what I want to achieve:

I have a set J consisting of several cities (e.g. New York, Chicago, Miami → 1, 2, 3). I defined a subset which consists of a selection of those cities:

Sets
j set of cities /1*3/; This is the whole set

Set j_o(j) subset1 /1,3/; This is subset 1 of set J
Set j_c(j) subset2 /2/; This is subset 2 of set J

The division is used as an initialization because some cities are active in period t=1, others are not. During the course of time, the activity may change.
Following restrictions on the activity:

  1. a city of subset1 needs to be active in period t=1
  2. an active city (subset1) can become inactive during the planning horizon, but is not allowed to be reactivated
  3. an inactive city (subset2) can become active and will stay active for the rest of the planning horizon

In order to model the sets with equations I tried the following, but I guess I am doing something wrong here with the sets.

  1. open_begin(j_o,t)$(ord(t)=1)… x(t,j) =e= 1; This equation should be for all x(t,j) which belong to t=1 and the subset1 of set J
  2. no_reopen(j_o,t)… x(t,j) =g= x(t,j)$(ord(t)=ord(t)+1); This equation should be for all x(t,j) which belong to the subset1 of set J, the expression with “ord” should model x(t,j) =g= x(“t+1”,j) and I hope I did this part correct
  3. open_new(j_c,t)… x(t,j) =l= x(t,j)$(ord(t)=ord(t)+1); This equation should be for all x(t,j) which belong to the subset2 of set J

I think this may be an easy one for GAMS professionals, but I am just stuck and don’t know how to solve it. I googled a lot, but unfortunately no success on that last little step.

Thanks a lot to all!




\

To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/4slXH4XFFosJ.
To post to this group, send email to gams...@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/axldoQ1C5S4J.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Dear Renger,

Thank you very much for the quick help. It works like that.
There is still one thing I want to ask regarding the subsets:
The three constraints I wrote in the original post should take care of the dynamic aspect of the model.
When I run the model, I get the following result: the cities which were active initially (subset1) stay active throughout the whole planning horizon. (even though they are not optimal).
How is GAMS handleing the subsets? I could assume that the corresponding x(t,j) in the objective function are not automazically related to the subset? Do I need to specify that somewhere else? As the model is optimizing in the objective funcvtion for x(t,j) I am not sure if they are autoamtically linked to the newly created subsets and thus to x(tj_o) and x(t,j_c).
Hope to get some help on that issue. Thanks a lot!


Am Freitag, 26. Oktober 2012 14:38:31 UTC+2 schrieb Renger van Nieuwkoop:

Hi Martin



In the first equation be sure that you have the same sets on both sides: open:_being(j_o,t)$… x(t,j_o) and not x(t,j). This will cause problems because can’t find the index j_o in the equation



you can just use x(t+,j) instead of ord(t) = ord(t)+1.

Cheers



Rehger


Modelworks

Gewerbestrasse 15

3600 Thun – Switzerland

+41 79 818 53 73

Info@modelworks.ch

blog.modelworks.ch
From: gams...@googlegroups.com [gams…@googlegroups.com] on behalf of JapanGo [markus…@googlemail.com]
Sent: Friday, October 26, 2012 13:25
To: gams...@googlegroups.com
Subject: Subsets and handling in equations

Dear members of Gamsworld,

I am sitting in front of a MIP code, which is bothering me quite a time and I have not found a solution so far.
Quickly explaines in words what I want to achieve:

I have a set J consisting of several cities (e.g. New York, Chicago, Miami → 1, 2, 3). I defined a subset which consists of a selection of those cities:

Sets
j set of cities /1*3/; This is the whole set

Set j_o(j) subset1 /1,3/; This is subset 1 of set J
Set j_c(j) subset2 /2/; This is subset 2 of set J

The division is used as an initialization because some cities are active in period t=1, others are not. During the course of time, the activity may change.
Following restrictions on the activity:

  1. a city of subset1 needs to be active in period t=1
  2. an active city (subset1) can become inactive during the planning horizon, but is not allowed to be reactivated
  3. an inactive city (subset2) can become active and will stay active for the rest of the planning horizon

In order to model the sets with equations I tried the following, but I guess I am doing something wrong here with the sets.

  1. open_begin(j_o,t)$(ord(t)=1)… x(t,j) =e= 1; This equation should be for all x(t,j) which belong to t=1 and the subset1 of set J
  2. no_reopen(j_o,t)… x(t,j) =g= x(t,j)$(ord(t)=ord(t)+1); This equation should be for all x(t,j) which belong to the subset1 of set J, the expression with “ord” should model x(t,j) =g= x(“t+1”,j) and I hope I did this part correct
  3. open_new(j_c,t)… x(t,j) =l= x(t,j)$(ord(t)=ord(t)+1); This equation should be for all x(t,j) which belong to the subset2 of set J

I think this may be an easy one for GAMS professionals, but I am just stuck and don’t know how to solve it. I googled a lot, but unfortunately no success on that last little step.

Thanks a lot to all!




\

To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/4slXH4XFFosJ.
To post to this group, send email to gams...@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/IG9Q-EOhGL8J.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Dear Renger,

Thank you very much.

Regards,
Nan

On Sun, Oct 28, 2012 at 4:13 AM, Renger van Nieuwkoop wrote:

Hi Nan



J_o is defined as a subset of j (j_o(j), so no need to have this somewhere in the equation).



Your second question:



A possible solution would be



total(t) =E= sum(j_o, x(1,j_o))(ord(t) Eq 1) + sum(j_o, x(1,j_c))(ord(t) Eq 2)



Cheers

Renger







From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Nan Yu
Sent: Saturday, October 27, 2012 9:32 AM
To: gamsworld@googlegroups.com
Subject: Re: Subsets and handling in equations



Hi,



I also have a similar problem concerning the sub sets.



I’m confused about your reply. In the first equation, if you change x(t,j) to x(t,j_o), then how to capture the fact that j_o is a sub set of j?



If I have a variable x (t,j) and I want to sum x(t,j) at diffent t, but at different t, the elements of j will be differnt.



In Japango’s example,

when t=1, I want to sum x(1,j_o)

when t=2, I wnat to sum x(2,j_c)



how to define this?

Thank you very much.



Regards,

Nan






On Friday, October 26, 2012 8:38:31 PM UTC+8, Renger van Nieuwkoop wrote:

Hi Martin



In the first equation be sure that you have the same sets on both sides: open:_being(j_o,t)$… x(t,j_o) and not x(t,j). This will cause problems because can’t find the index j_o in the equation



you can just use x(t+,j) instead of ord(t) = ord(t)+1.

Cheers



Rehger


Modelworks

Gewerbestrasse 15

3600 Thun – Switzerland

+41 79 818 53 73

Info@modelworks.ch

blog.modelworks.ch

From: gams...@googlegroups.com [gams…@googlegroups.com] on behalf of JapanGo [markus…@googlemail.com]
Sent: Friday, October 26, 2012 13:25
To: gams...@googlegroups.com
Subject: Subsets and handling in equations

Dear members of Gamsworld,

I am sitting in front of a MIP code, which is bothering me quite a time and I have not found a solution so far.
Quickly explaines in words what I want to achieve:

I have a set J consisting of several cities (e.g. New York, Chicago, Miami → 1, 2, 3). I defined a subset which consists of a selection of those cities:

Sets
j set of cities /1*3/; This is the whole set

Set j_o(j) subset1 /1,3/; This is subset 1 of set J
Set j_c(j) subset2 /2/; This is subset 2 of set J

The division is used as an initialization because some cities are active in period t=1, others are not. During the course of time, the activity may change.
Following restrictions on the activity:

  1. a city of subset1 needs to be active in period t=1
  2. an active city (subset1) can become inactive during the planning horizon, but is not allowed to be reactivated
  3. an inactive city (subset2) can become active and will stay active for the rest of the planning horizon

In order to model the sets with equations I tried the following, but I guess I am doing something wrong here with the sets.

  1. open_begin(j_o,t)$(ord(t)=1)… x(t,j) =e= 1; This equation should be for all x(t,j) which belong to t=1 and the subset1 of set J
  2. no_reopen(j_o,t)… x(t,j) =g= x(t,j)$(ord(t)=ord(t)+1); This equation should be for all x(t,j) which belong to the subset1 of set J, the expression with “ord” should model x(t,j) =g= x(“t+1”,j) and I hope I did this part correct
  3. open_new(j_c,t)… x(t,j) =l= x(t,j)$(ord(t)=ord(t)+1); This equation should be for all x(t,j) which belong to the subset2 of set J

I think this may be an easy one for GAMS professionals, but I am just stuck and don’t know how to solve it. I googled a lot, but unfortunately no success on that last little step.

Thanks a lot to all!



\

To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/4slXH4XFFosJ.
To post to this group, send email to gams...@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/hHCfNEdPDsAJ.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Must be somewhere in your figures. No idea.

Renger



Von: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] Im Auftrag von JapanGo
Gesendet: Monday, October 29, 2012 4:27 PM
An: gamsworld@googlegroups.com
Betreff: Re: Subsets and handling in equations



Hej Rehger,

Thanks a lot for your reply. I knew it was easy :wink:
Thanks also for the hint that I can simply use “t+1”. I did use the “ord” because I thought I read somewhere “t+1” ist not possible, but it seems to be working.

When I run the model now it strangely keeps all cities active which I initially chose (even if it is not the optimal solution in the non-dynamic case).
The three constraints below should “force” the model to change activity in the course of time (=t) in oder to come to the optimal solution.

Any clues?

Am Freitag, 26. Oktober 2012 14:38:31 UTC+2 schrieb Renger van Nieuwkoop:

Hi Martin



In the first equation be sure that you have the same sets on both sides: open:_being(j_o,t)$… x(t,j_o) and not x(t,j). This will cause problems because can’t find the index j_o in the equation



you can just use x(t+,j) instead of ord(t) = ord(t)+1.

Cheers



Rehger


Modelworks

Gewerbestrasse 15

3600 Thun – Switzerland

+41 79 818 53 73

Info@modelworks.ch

blog.modelworks.ch

From: gams...@googlegroups.com [gams…@googlegroups.com] on behalf of JapanGo [markus…@googlemail.com]
Sent: Friday, October 26, 2012 13:25
To: gams...@googlegroups.com
Subject: Subsets and handling in equations

Dear members of Gamsworld,

I am sitting in front of a MIP code, which is bothering me quite a time and I have not found a solution so far.
Quickly explaines in words what I want to achieve:

I have a set J consisting of several cities (e.g. New York, Chicago, Miami → 1, 2, 3). I defined a subset which consists of a selection of those cities:

Sets
j set of cities /1*3/; This is the whole set

Set j_o(j) subset1 /1,3/; This is subset 1 of set J
Set j_c(j) subset2 /2/; This is subset 2 of set J

The division is used as an initialization because some cities are active in period t=1, others are not. During the course of time, the activity may change.
Following restrictions on the activity:

  1. a city of subset1 needs to be active in period t=1
  2. an active city (subset1) can become inactive during the planning horizon, but is not allowed to be reactivated
  3. an inactive city (subset2) can become active and will stay active for the rest of the planning horizon

In order to model the sets with equations I tried the following, but I guess I am doing something wrong here with the sets.

  1. open_begin(j_o,t)$(ord(t)=1)… x(t,j) =e= 1; This equation should be for all x(t,j) which belong to t=1 and the subset1 of set J
  2. no_reopen(j_o,t)… x(t,j) =g= x(t,j)$(ord(t)=ord(t)+1); This equation should be for all x(t,j) which belong to the subset1 of set J, the expression with “ord” should model x(t,j) =g= x(“t+1”,j) and I hope I did this part correct
  3. open_new(j_c,t)… x(t,j) =l= x(t,j)$(ord(t)=ord(t)+1); This equation should be for all x(t,j) which belong to the subset2 of set J

I think this may be an easy one for GAMS professionals, but I am just stuck and don’t know how to solve it. I googled a lot, but unfortunately no success on that last little step.

Thanks a lot to all!



\

To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/4slXH4XFFosJ.
To post to this group, send email to gams...@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/axldoQ1C5S4J.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

OK, thank you.

One question for understanding: if a x(t,j) is changed from 0 to1 (which means the city is activated), are the subsets then adjusted accordingly? That means is the vale for the corresponding x(t,j_c) changed accordingly? The same vice versa: If a x(t,j_c) is changed, is the corresponding x(t,j) changed accordingly?
Is that done automatically or do I have to set the sets/subsets in some other kind of relation?

Thanks!

Am Dienstag, 30. Oktober 2012 10:18:44 UTC+1 schrieb Renger van Nieuwkoop:

Must be somewhere in your figures. No idea.

Renger



Von: gams...@googlegroups.com [mailto:gams...@googlegroups.com] Im Auftrag von JapanGo
Gesendet: Monday, October 29, 2012 4:27 PM
An: gams...@googlegroups.com
Betreff: Re: Subsets and handling in equations



Hej Rehger,

Thanks a lot for your reply. I knew it was easy :wink:
Thanks also for the hint that I can simply use “t+1”. I did use the “ord” because I thought I read somewhere “t+1” ist not possible, but it seems to be working.

When I run the model now it strangely keeps all cities active which I initially chose (even if it is not the optimal solution in the non-dynamic case).
The three constraints below should “force” the model to change activity in the course of time (=t) in oder to come to the optimal solution.

Any clues?

Am Freitag, 26. Oktober 2012 14:38:31 UTC+2 schrieb Renger van Nieuwkoop:

Hi Martin



In the first equation be sure that you have the same sets on both sides: open:_being(j_o,t)$… x(t,j_o) and not x(t,j). This will cause problems because can’t find the index j_o in the equation



you can just use x(t+,j) instead of ord(t) = ord(t)+1.

Cheers



Rehger


Modelworks

Gewerbestrasse 15

3600 Thun – Switzerland

+41 79 818 53 73

Info@modelworks.ch

blog.modelworks.ch

From: gams...@googlegroups.com [gams…@googlegroups.com] on behalf of JapanGo [markus…@googlemail.com]
Sent: Friday, October 26, 2012 13:25
To: gams...@googlegroups.com
Subject: Subsets and handling in equations

Dear members of Gamsworld,

I am sitting in front of a MIP code, which is bothering me quite a time and I have not found a solution so far.
Quickly explaines in words what I want to achieve:

I have a set J consisting of several cities (e.g. New York, Chicago, Miami → 1, 2, 3). I defined a subset which consists of a selection of those cities:

Sets
j set of cities /1*3/; This is the whole set

Set j_o(j) subset1 /1,3/; This is subset 1 of set J
Set j_c(j) subset2 /2/; This is subset 2 of set J

The division is used as an initialization because some cities are active in period t=1, others are not. During the course of time, the activity may change.
Following restrictions on the activity:

  1. a city of subset1 needs to be active in period t=1
  2. an active city (subset1) can become inactive during the planning horizon, but is not allowed to be reactivated
  3. an inactive city (subset2) can become active and will stay active for the rest of the planning horizon

In order to model the sets with equations I tried the following, but I guess I am doing something wrong here with the sets.

  1. open_begin(j_o,t)$(ord(t)=1)… x(t,j) =e= 1; This equation should be for all x(t,j) which belong to t=1 and the subset1 of set J
  2. no_reopen(j_o,t)… x(t,j) =g= x(t,j)$(ord(t)=ord(t)+1); This equation should be for all x(t,j) which belong to the subset1 of set J, the expression with “ord” should model x(t,j) =g= x(“t+1”,j) and I hope I did this part correct
  3. open_new(j_c,t)… x(t,j) =l= x(t,j)$(ord(t)=ord(t)+1); This equation should be for all x(t,j) which belong to the subset2 of set J

I think this may be an easy one for GAMS professionals, but I am just stuck and don’t know how to solve it. I googled a lot, but unfortunately no success on that last little step.

Thanks a lot to all!



\

To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/4slXH4XFFosJ.
To post to this group, send email to gams...@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/axldoQ1C5S4J.
To post to this group, send email to gams...@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/WS02wlHcuY4J.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Hi

Gams treats the subsets as members of the main set, so if you define X(t,j) = 1, all the values for X for the subsets are also 1. There is no need for assigning them additionally.



Renger



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of JapanGo
Sent: Tuesday, October 30, 2012 9:08 AM
To: gamsworld@googlegroups.com
Subject: Re: Subsets and handling in equations



Dear Renger,

Thank you very much for the quick help. It works like that.
There is still one thing I want to ask regarding the subsets:
The three constraints I wrote in the original post should take care of the dynamic aspect of the model.
When I run the model, I get the following result: the cities which were active initially (subset1) stay active throughout the whole planning horizon. (even though they are not optimal).
How is GAMS handleing the subsets? I could assume that the corresponding x(t,j) in the objective function are not automazically related to the subset? Do I need to specify that somewhere else? As the model is optimizing in the objective funcvtion for x(t,j) I am not sure if they are autoamtically linked to the newly created subsets and thus to x(tj_o) and x(t,j_c).
Hope to get some help on that issue. Thanks a lot!


Am Freitag, 26. Oktober 2012 14:38:31 UTC+2 schrieb Renger van Nieuwkoop:

Hi Martin



In the first equation be sure that you have the same sets on both sides: open:_being(j_o,t)$… x(t,j_o) and not x(t,j). This will cause problems because can’t find the index j_o in the equation



you can just use x(t+,j) instead of ord(t) = ord(t)+1.

Cheers



Rehger


Modelworks

Gewerbestrasse 15

3600 Thun – Switzerland

+41 79 818 53 73

Info@modelworks.ch

blog.modelworks.ch

From: gams...@googlegroups.com [gams…@googlegroups.com] on behalf of JapanGo [markus…@googlemail.com]
Sent: Friday, October 26, 2012 13:25
To: gams...@googlegroups.com
Subject: Subsets and handling in equations

Dear members of Gamsworld,

I am sitting in front of a MIP code, which is bothering me quite a time and I have not found a solution so far.
Quickly explaines in words what I want to achieve:

I have a set J consisting of several cities (e.g. New York, Chicago, Miami → 1, 2, 3). I defined a subset which consists of a selection of those cities:

Sets
j set of cities /1*3/; This is the whole set

Set j_o(j) subset1 /1,3/; This is subset 1 of set J
Set j_c(j) subset2 /2/; This is subset 2 of set J

The division is used as an initialization because some cities are active in period t=1, others are not. During the course of time, the activity may change.
Following restrictions on the activity:

  1. a city of subset1 needs to be active in period t=1
  2. an active city (subset1) can become inactive during the planning horizon, but is not allowed to be reactivated
  3. an inactive city (subset2) can become active and will stay active for the rest of the planning horizon

In order to model the sets with equations I tried the following, but I guess I am doing something wrong here with the sets.

  1. open_begin(j_o,t)$(ord(t)=1)… x(t,j) =e= 1; This equation should be for all x(t,j) which belong to t=1 and the subset1 of set J
  2. no_reopen(j_o,t)… x(t,j) =g= x(t,j)$(ord(t)=ord(t)+1); This equation should be for all x(t,j) which belong to the subset1 of set J, the expression with “ord” should model x(t,j) =g= x(“t+1”,j) and I hope I did this part correct
  3. open_new(j_c,t)… x(t,j) =l= x(t,j)$(ord(t)=ord(t)+1); This equation should be for all x(t,j) which belong to the subset2 of set J

I think this may be an easy one for GAMS professionals, but I am just stuck and don’t know how to solve it. I googled a lot, but unfortunately no success on that last little step.

Thanks a lot to all!



\

To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/4slXH4XFFosJ.
To post to this group, send email to gams...@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/IG9Q-EOhGL8J.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Hi Renger,

Thank you for clarifying this!

Am Donnerstag, 1. November 2012 05:52:10 UTC+1 schrieb Renger van Nieuwkoop:

Hi

Gams treats the subsets as members of the main set, so if you define X(t,j) = 1, all the values for X for the subsets are also 1. There is no need for assigning them additionally.



Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of JapanGo
Sent: Tuesday, October 30, 2012 9:08 AM
To: gams...@googlegroups.com
Subject: Re: Subsets and handling in equations



Dear Renger,

Thank you very much for the quick help. It works like that.
There is still one thing I want to ask regarding the subsets:
The three constraints I wrote in the original post should take care of the dynamic aspect of the model.
When I run the model, I get the following result: the cities which were active initially (subset1) stay active throughout the whole planning horizon. (even though they are not optimal).
How is GAMS handleing the subsets? I could assume that the corresponding x(t,j) in the objective function are not automazically related to the subset? Do I need to specify that somewhere else? As the model is optimizing in the objective funcvtion for x(t,j) I am not sure if they are autoamtically linked to the newly created subsets and thus to x(tj_o) and x(t,j_c).
Hope to get some help on that issue. Thanks a lot!


Am Freitag, 26. Oktober 2012 14:38:31 UTC+2 schrieb Renger van Nieuwkoop:

Hi Martin



In the first equation be sure that you have the same sets on both sides: open:_being(j_o,t)$… x(t,j_o) and not x(t,j). This will cause problems because can’t find the index j_o in the equation



you can just use x(t+,j) instead of ord(t) = ord(t)+1.

Cheers



Rehger


Modelworks

Gewerbestrasse 15

3600 Thun – Switzerland

+41 79 818 53 73

Info@modelworks.ch

blog.modelworks.ch

From: gams...@googlegroups.com [gams…@googlegroups.com] on behalf of JapanGo [markus…@googlemail.com]
Sent: Friday, October 26, 2012 13:25
To: gams...@googlegroups.com
Subject: Subsets and handling in equations

Dear members of Gamsworld,

I am sitting in front of a MIP code, which is bothering me quite a time and I have not found a solution so far.
Quickly explaines in words what I want to achieve:

I have a set J consisting of several cities (e.g. New York, Chicago, Miami → 1, 2, 3). I defined a subset which consists of a selection of those cities:

Sets
j set of cities /1*3/; This is the whole set

Set j_o(j) subset1 /1,3/; This is subset 1 of set J
Set j_c(j) subset2 /2/; This is subset 2 of set J

The division is used as an initialization because some cities are active in period t=1, others are not. During the course of time, the activity may change.
Following restrictions on the activity:

  1. a city of subset1 needs to be active in period t=1
  2. an active city (subset1) can become inactive during the planning horizon, but is not allowed to be reactivated
  3. an inactive city (subset2) can become active and will stay active for the rest of the planning horizon

In order to model the sets with equations I tried the following, but I guess I am doing something wrong here with the sets.

  1. open_begin(j_o,t)$(ord(t)=1)… x(t,j) =e= 1; This equation should be for all x(t,j) which belong to t=1 and the subset1 of set J
  2. no_reopen(j_o,t)… x(t,j) =g= x(t,j)$(ord(t)=ord(t)+1); This equation should be for all x(t,j) which belong to the subset1 of set J, the expression with “ord” should model x(t,j) =g= x(“t+1”,j) and I hope I did this part correct
  3. open_new(j_c,t)… x(t,j) =l= x(t,j)$(ord(t)=ord(t)+1); This equation should be for all x(t,j) which belong to the subset2 of set J

I think this may be an easy one for GAMS professionals, but I am just stuck and don’t know how to solve it. I googled a lot, but unfortunately no success on that last little step.

Thanks a lot to all!



\

To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/4slXH4XFFosJ.
To post to this group, send email to gams...@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/IG9Q-EOhGL8J.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/s9GI6GPK60cJ.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.