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:

And here I have tried to link them together:

I get the error “unknown symbol”. I hope you can help me

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:

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

-Michael

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?

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.

How can I define this in my set and link it to my function. I hope you can help me again.

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:

```
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

If I try to link the equation with phi, I get an error. This is what I’ve been doing:

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.

I guess your *Zeitstr(s)* should hold for all **first** micro-periods in all macro-periods. Since your macro-period is part of this information you need to do something about this. There are lots of different ways to do this (see below). You really need to learn more of the basic stuff. GAMS is unlike other (address oriented) programming languages. As soon as you have your sets and the relation among them under control things just fall into place. You need to invest to learn this and then a whole new world of efficient model building opens up for you. A forum like this helps to get you over the hump in very special situations, it is not a replacement for learning a sophisticated tool like GAMS properly. Besides documentation, there are lots of other materials and even courses. I hope you have a mentor that recommended GAMS to you. Go there for advice! I can’t really help with the dummy period. Try your best, post a small concrete issue someone can look at, and hope for the best.

Here are some examples how to deal with your *Zeitstr(s)* issue:

- Change domain of
*Zeitstr(s)*

```
Zeitstr(phi(s,t)).. w(s) =e= wquer(s);
```

```
Zeitstr(s)$sum(phi(s,t),1).. w(s) =e= wquer(s);
```

- Make a subset with first micro -periods

```
set fs(s); fs(s) = sum(phi(s,t),1); Zeitstr(fs).. w(fs) =e= wquer(fs);
```

Good luck!

-Michael