The GAMS lingo for this is lag and lead operators: *x(d,h-1)* e.g. shows the previous hour.

The - is not a numerical minus but a lag. Trouble is that the predecessor for *x(d,‘h1’)* is *x(d-1,‘h24’)*. You also have to decide what the predecessor of *‘d1’,‘h1’* is.

If you do a steady state model you could have *‘d365’,‘h24’* or you can decide that there is no predecessor (meaning *delta(‘d1’,‘h1’) = x(‘d1’,'h1)*). I am assuming your sets look like this:

```
Set d / d1*d365 /
h / h1*h24 /;
```

Now here is what you can do:

```
delta(d,h) =e= x(d,h) - x(d-(1$sameas('h1')),h--1));
```

Not so elegant, but it will work. I prefer working with an additional set of all hours in the year and a map between *d,h* and all hours in the year:

```
Set h /h1*h24/, d /d1*d365/, dh(d,h) /#d.#h/
Set t /t1*t8760/, tdh(t,d,h) /#t:#dh/, dht /#dh:#t/;
```

. and : are called matching operators. Now I would have the variable *x* and *delta* over *t* and then the constraint looks simple:

```
delta(t) =e= x(t) - x(t-1); (or x(t--1) for steady state)
```

In case you have data by *d,h* you can use the map *tdh*, for example:

```
delta(t) =l= sum(tdh(t,d,h), maxdeviation(d,h));
```