## Dynamic set problem

Problems with syntax of GAMS
sph_93
User
Posts: 5
Joined: 1 week ago

### Dynamic set problem

Hello,

i have problems with the creation of a dynamic set. I have two macroperiods, each of which should contain three microperiods. But I can't get them linked.Here are my sets:
grafik.png (8.57 KiB) Viewed 211 times
And here I have tried to link them together:
grafik.png (19.85 KiB) Viewed 211 times
I get the error "unknown symbol". I hope you can help me

bussieck
Moderator
Posts: 461
Joined: 3 years ago

### Re: Dynamic set problem

That's a very basic data organization question. I suggest you read more about using sets effectively in GAMS. There are a couple of chapters in the User's Guide that deal with that:

Code: Select all

``````set t /t1,t2/, s /s1*s6/, ts(t,s) /t1.(s1*s3), t2.(s4*s6)/;
``````

-Michael

sph_93
User
Posts: 5
Joined: 1 week ago

### Re: Dynamic set problem

Hello, Michael, thank you very much for your help. Your tip helped. I still have two last problems.
I have 3 microperiods s in 2 macroperiods t.The first microperiod in each macroperiod should get a fixed start time in the set phi. How can I program this problem?
grafik.png (2.19 KiB) Viewed 148 times
I've tried:
Set
phi(s,t) Set of all microperiods with fixed starting times ;
phi(s,t)\$((ord(s)=1 and ord(t)=1)) = yes;
phi(s,t)\$((ord(s)=4 and ord(t)=2)) = yes;

I also need a dummy period s=S+1.
grafik.png (5.83 KiB) Viewed 148 times
grafik.png (3.73 KiB) Viewed 148 times
How can I define this in my set and link it to my function. I hope you can help me again.

bussieck
Moderator
Posts: 461
Joined: 3 years ago

### Re: Dynamic set problem

Your idea about phi isn't wrong. You can generalize this easily if your division of macro- and microperiods is regular (3 micro for each macro). Otherwise, the logic needs a little more:

Code: Select all

``````set t /t1,t2/, s /s1*s6/, ts(t,s) /t1.(s1*s3), t2.(s4*s6)/
set phi(s,t); phi(s,t) = (ord(t)-1)*3+1 = ord(s); display phi;
option clear=phi;
alias (s,ss); phi(s,t) = ts(t,s) and smin(ts(t,ss), ord(ss)) = ord(s); display phi;``````
If you have a special entity like a dummy period, it might make sense to have a dummy variable/constraint whereever you need rather than sticking this into your well defined set structure. One would need to see where this dummy period is used. The algebra "forall j,l,s" makes little sense, since there is just a single "s", the dummy period. So this looks more like "forall j,l". If y and x are variables that are also indexed with regular microperiods than my suggestion was to use a special xDummy(l,j) and yDummy(l,j) for the dummy period rather than making s part of your set structure and dealing with "exceptions" anywhere else in the code. There are also other solutions. Again, they will be clearer if you know better how to work with dynamic sets.

-Michael

sph_93
User
Posts: 5
Joined: 1 week ago

### Re: Dynamic set problem

If I try to link the equation with phi, I get an error. This is what I've been doing:
grafik.png (7.45 KiB) Viewed 99 times
I'm sorry, I don't understand what you mean by dummy period.
I don't know how to define dummy period and then put it into the equation. I would be so grateful if you could help me with that.

bussieck
Moderator
Posts: 461
Joined: 3 years ago

### Re: Dynamic set problem

Here are some examples how to deal with your Zeitstr(s) issue:
• Change domain of Zeitstr(s)

Code: Select all

`` Zeitstr(phi(s,t)).. w(s) =e= wquer(s);``
• Make sure the s has a t

Code: Select all

`` Zeitstr(s)\$sum(phi(s,t),1).. w(s) =e= wquer(s);``
• Make a subset with first micro -periods

Code: Select all

`` set fs(s); fs(s) = sum(phi(s,t),1); Zeitstr(fs).. w(fs) =e= wquer(fs);``
Good luck!
-Michael