i have a functioning model with time steps of 5 years. i want to rewrite the code to timesteps of 1 year. for that i need to recalibrate certain values. first step to do so is to get yearly values for a variable, that has only values every 5 years. so the originial code works with a set “t”:
set t Time periods (5 years per period) /1*10/ ;
my variable is depending on t:
Variable
E(t) Total CO2 emissions (GtCO2 per year)
;
after solving the model i want to work with the values, introduce a new set “year” and then find values for E on a yearly basis:
set year Years /1*50/;
PARAMETERS
Eyear(year) Linear intorpoled yearly Emissions
;
Loop (year, Eyear(year)=E(ceil(year/5))+((E(ceil(year/5)+1)-E(ceil(year/5)))/5)**(year-5*ceil(year/5)););
gams doesnt like, that i use “year” in a variable that is defined in “t”, but by ceil(year/5) i shouldnt ask for a value that doesnt exist.
after solving a model, are the values for E(t) fixed and i can use it as a parameter or is an addition step needed?
how can i refere to E(t) using “year”? is it even possible to use “year” in a variable defined in “t”?
Hello, according to your example I think that the final periods correspond to 45 years. A zero-time value is required to complete the 50 years.
I can be wrong anyway
Bye!
This is an example:
set t /110/
set year Years /145/;
PARAMETERS
E(t)
/1 100
2 200
3 300
4 400
5 500
6 600
7 700
8 800
9 900
10 1000/
Eyear(year) Linear intorpoled yearly Emissions
;
Loop((year,t)$(ord(t) eq ceil(ord(year)/5)),
if(ord(t) eq 1,
Eyear(year) = E(t) + ((E(t+1)-E(t))/4)(ord(year) - 1);
else
Eyear(year) = E(t) + ((E(t+1)-E(t))/5)(ord(year)- (ord(t)-1)*5);
););
thank you, that helped already enormously. i want to use, what i learned here for another part of the calibration…
in order to calibrate some values from 5 year time steps to 1 year time steps, i want to minimize the difference between values where i used E(t) and where i used Eyear(year), but only where there is an actual value for t(every 5 years), so i tried this: