Hello,
I am currently learning GAMS and I came up on this issue:
I am using these sets:
Sets
y “Set of years in the planning horizon” /y2023y2045/
d “Set of all days in a year” /d1d366/
t “Set of all hours in a day” /h1*h24/;
Then I am importing data for some parameters from excel. e.g. E(y,d,t)
Therefore I would prefer not to change the way my sets are defined, because I will need to change everything in my excel as well.
And further down the code, in certain equations I need to use variables like this one: “E_b_res(y,d,t-1)”
So is should work like this:
if ( ord(t)=1 AND ord(d)=1 AND E(y-1,‘d366’,‘h24’) <> 0 )
x=E_b_res(y-1,‘d366’,‘h24’)
else if ( ord(t=1) AND ord(d)=1 )
x=E_b_res(y-1,‘d365’,‘h24’)
else if( ord(t=1) )
x=E_b_res(y,d-1,‘h24’)
else
x=E_b_res(y,d,t-1)
Where x is the value I need E_b_res(y,d,t-1) to have.
*note: in the E(y-1,‘d366’,‘h24’) <> 0 part, I am checking whether or not its a leap year. My excel doesn’t input values for d366 of non leap years so this is an easy way of checking
This felt very complex to do using the $ operator. I am also considering using Multi-Dimensional Sets, but I couldn’t really figure out how they work just using the documentation. For example: why can’t I define a variable over a multi-dimensional set?
I am pretty sure there are some easy solutions for this that I am missing.