Decision variable subset usage Topic is solved

Problems with modeling
Post Reply
meloci01
User
User
Posts: 4
Joined: 3 years ago

Decision variable subset usage

Post by meloci01 »

Hi,

I have sets like this:

Sets
p set of plants /1*4/
t set of all production units in the network /t1, t2/
tp(t,p) set of production units at plant p /t1.1, t2.2/
s set of all subassembly units /s1, s2/
sp(s,p) all subassembly units at plant p /s1.3, s2.4/
c components and parts /c1, c2/

And I have to define a decision variable like this:

x(c,t,s) -> c ∈C, t ∈ Tp, s ∈ Sp

How can I define/control subset into decision variable?

And also how can I control in an equation? i.e
image.png
image.png (8.77 KiB) Viewed 2680 times
Thank you for your help
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: Decision variable subset usage

Post by abhosekar »

Do not repost/re-edit the same question too many times.
Variable domains cannot be defined over subsets but equations can be. Using projections to create couple more subsets and then using those to define your equations might be a good way for you. In the following code, you will see how to use projections to create subsets (tp_t and sp_s are subsets in this example. you can check this in the .lst file after running the following code fragment).

Code: Select all

Sets
t set of all production units in the network /t1, t2/
p /1*4/
tp(t,p) set of production units at plant p /t1.1, t2.2/
s set of all subassembly units /s1, s2/
sp(s,p) all subassembly units at plant p /s1.3, s2.4/
c components and parts /c1, c2/
tp_t(t)
sp_s(s)
;

option tp_t < tp;
option sp_s < sp;

display
tp_t
sp_s;

variable
x(c, t, s);
For the equation, I assume you are interested only in the left hand side. You can do this as follows:

Code: Select all

sum((t, s)$(tp_t(t) and sp_s(s)), x(c, t, s)) =e= ....
- Atharv
meloci01
User
User
Posts: 4
Joined: 3 years ago

Re: Decision variable subset usage

Post by meloci01 »

abhosekar wrote: 3 years ago Do not repost/re-edit the same question too many times.
Variable domains cannot be defined over subsets but equations can be. Using projections to create couple more subsets and then using those to define your equations might be a good way for you. In the following code, you will see how to use projections to create subsets (tp_t and sp_s are subsets in this example. you can check this in the .lst file after running the following code fragment).

Code: Select all

Sets
t set of all production units in the network /t1, t2/
p /1*4/
tp(t,p) set of production units at plant p /t1.1, t2.2/
s set of all subassembly units /s1, s2/
sp(s,p) all subassembly units at plant p /s1.3, s2.4/
c components and parts /c1, c2/
tp_t(t)
sp_s(s)
;

option tp_t < tp;
option sp_s < sp;

display
tp_t
sp_s;

variable
x(c, t, s);
For the equation, I assume you are interested only in the left hand side. You can do this as follows:

Code: Select all

sum((t, s)$(tp_t(t) and sp_s(s)), x(c, t, s)) =e= ....
- Atharv
I am sorry I forgot a set :( Thats why I send too many times.

I understand equation part but now I have problem with parameters.

For example,

cap(t) Capacity for component production of production unit t ∈ Tp

I wrote this parameter like cap(t,p) /t1.1 2000000, t2.2 3000000/ ;

I think now I did a mistake? /I tried to code an article with mock data, the aim is to learn and deal conding GAMS).

Thank you again for your help.
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: Decision variable subset usage

Post by abhosekar »

The following code works. I think the comma in your parameter was the problem. However, the parameter is defined on full domain and other values will be assumed to be 0.

Code: Select all

parameter
cap(t, p)
/t1.1 2000000
t2.2 3000000/ ;
You can simply use $(tp_t(t) and sp_s(s)) to make sure that correct t and s are used everytime you need to access cap(t, p)

- Atharv
Post Reply