## Enter cyclic parameters

Problems with syntax of GAMS
User Posts: 6
Joined: 2 years ago

### Enter cyclic parameters

Hi,

I am modelling electricity consumption of a household during three month long period. Daily consumption is assumed to be the same every day. I import data from excel file, where the data are like c(1) - 0.2 (kWh), c(2) - 0.2 (kWh),..., c(24) - 0.1 (kWh). So I've currently imported a vector of 24 parameters, but i need to 'copy' them consecutively. Like this way: cc(1) = c(1), ..., cc(24) = c(24), cc(25) = c(1), cc(26) = c(2) and so on, to get vector of 24*90(hours*days) hours long. I've tried combination of loop and mod function, but it didnt worked. Can anybody please help? Thanks. Renger
Posts: 545
Joined: 3 years ago

### Re: Enter cyclic parameters

Hi
Take a look at these loops. I believe they are doing what you try to achieve (I initialized the first 24 values with the numbers 1 to 24 to easily check the results):

Code: Select all

``````set i /1*2160/, l /1*90/, k(i) /1*24/;
parameter c(i);

* Values for the first 24 hours
c(i)\$(i.val < 25) = ord(i);
display c;

loop(i,
loop(l,
loop(k\$(k.val = i.val - l.val*24),
c(i) = c(k);
);
);
);

display c;``````
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist

User Posts: 6
Joined: 2 years ago

### Re: Enter cyclic parameters

Hi Renger,

first of all, thanks for your quick reply. It looks pretty accurate and works well. I'm glad you understood although my description was pretty weird. The question is following, is there any possibility to manage situation, when I have data, let's say for (n+1/2) of days? Because if I understand well, your code would work for complete days only. I've tried using "mod" function, but I had a lot of problems as rewriting parameter requires to have index of a set in the argument. Assume the following example:

Sets t /1*3649/
tt(t) /1*3649/
ttt(t) /1*24/;

Parameters D(tt)
DD(ttt); - i write data from excel spreadsheet to parameter DD(ttt)

and then I wanted to use something like

loop(tt,
D(tt) = D(mod(ord(tt-1),24)+1)
);

It would work perfectly, because it shifts argument and doesn't leave any empty parameter D(tt) for arbitrary tt value, except it doesn't work as I expected... Well... It doesn't work at all. My point is - what to do If I don't have nice data that can be divided exactly into whole days like you did?

Renger
Posts: 545
Joined: 3 years ago

### Re: Enter cyclic parameters

Hi
Could you make a small example with numbers and (to keep it simple) a repeating week and daily values (e.g. you have the values for one week and want to have them for all weeks)? It is not clear to me what you want to do with the half days.
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist

User Posts: 6
Joined: 2 years ago

### Re: Enter cyclic parameters

Hi,

of course. Let's say, I have hourly data of consumption for 54 hours (like 2.25 days), hence set i / 1*55/ (including consumption from 0.00 to 1.00); and hourly data of production for 24 hours only, hence probably ii(i) /1*25/. What I need is to extend production data to have the same length as a consumption data. Both starting at the same time at time 0.00.

Renger
Posts: 545
Joined: 3 years ago

### Re: Enter cyclic parameters

Hi
Is this what you are looking for:

Code: Select all

``````Sets t /1*55/
k(t) /1*24/
;
Parameter
c(t),s(t);
s(k) = k.val;
c(t) = t.val;

loop(t,
s(t) = sum(k\$(mod(t.val,24) = k.val), s(k));
);

display s;``````
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist