Commit 313f0028 authored by Juha Kiviluoma's avatar Juha Kiviluoma
Browse files

Enables reading of any timeseries with forecasts between the solve loops.

Also changing the length of the forecast horizon so that it is now possible to either keep a static length for the forecasts or to have a decreasing forecast horizon that only extends forward at every tForecastJump.
parent e3d1b07c
......@@ -73,9 +73,9 @@ if (mType('building'),
// Define forecast properties and features
mSettings('building', 't_forecastStart') = 0;
mSettings('building', 't_forecastLength') = 0;
mSettings('building', 't_forecastLengthUnchanging') = 0; // Length of forecasts in time steps - this does not decrease when the solve moves forward (requires forecast data that is longer than the horizon at first)
mSettings('building', 't_forecastLengthDecreasesFrom') = 0; // Length of forecasts in time steps - this decreases when the solve moves forward until the new forecast data is read (then extends back to full length)
mSettings('building', 't_forecastJump') = 0;
mSettings('building', 'readForecastsInTheLoop') = 0;
// Define Realized and Central forecasts
* mf_realization('building', f) = no;
......
......@@ -79,9 +79,9 @@ if (mType('invest'),
// Define forecast properties and features
mSettings('invest', 't_forecastStart') = 0;
mSettings('invest', 't_forecastLength') = 0;
mSettings('invest', 't_forecastLengthUnchanging') = 0; // Length of forecasts in time steps - this does not decrease when the solve moves forward (requires forecast data that is longer than the horizon at first)
mSettings('building', 't_forecastLengthDecreasesFrom') = 0; // Length of forecasts in time steps - this decreases when the solve moves forward until the new forecast data is read (then extends back to full length)
mSettings('invest', 't_forecastJump') = 0;
mSettings('invest', 'readForecastsInTheLoop') = 0;
// Define Realized and Central forecasts
mf_realization('invest', f) = no;
......
......@@ -81,9 +81,19 @@ if (mType('schedule'),
// Define forecast properties and features
mSettings('schedule', 't_forecastStart') = 1;
mSettings('schedule', 't_forecastLength') = 36;
mSettings('schedule', 't_forecastLengthUnchanging') = 36; // Length of forecasts in time steps - this does not decrease when the solve moves forward (requires forecast data that is longer than the horizon at first)
mSettings('building', 't_forecastLengthDecreasesFrom') = 168; // Length of forecasts in time steps - this decreases when the solve moves forward until the new forecast data is read (then extends back to full length)
mSettings('schedule', 't_forecastJump') = 24;
mSettings('schedule', 'readForecastsInTheLoop') = 1;
mTimeseries_loop_read('schedule', 'ts_reserveDemand') = no;
mTimeseries_loop_read('schedule', 'ts_unit') = no;
mTimeseries_loop_read('schedule', 'ts_effUnit') = no;
mTimeseries_loop_read('schedule', 'ts_effGroupUnit') = no;
mTimeseries_loop_read('schedule', 'ts_influx') = no;
mTimeseries_loop_read('schedule', 'ts_cf') = no;
mTimeseries_loop_read('schedule', 'ts_reserveDemand') = no;
mTimeseries_loop_read('schedule', 'ts_nodeState') = no;
mTimeseries_loop_read('schedule', 'ts_fuelPriceChange') = no;
mTimeseries_loop_read('schedule', 'ts_unavailability') = no;
// Define Realized and Central forecasts
mf_realization('schedule', f) = no;
......
......@@ -43,10 +43,10 @@ Sets
// Samples and Forecasts
samples, // Number of active samples
forecasts, // Number of active forecasts
t_forecastLengthUnchanging, // Length of forecasts in time steps - this does not decrease when the solve moves forward (requires forecast data that is longer than the horizon at first)
t_forecastLengthDecreasesFrom, // Length of forecasts in time steps - this decreases when the solve moves forward until the new forecast data is read (then extends back to full length)
t_forecastStart, // Time step for first reading the forecasts (not necessarily t_start)
t_forecastLength, // Length of forecasts in time steps
t_forecastJump, // Number of time steps between each update of the forecasts
readForecastsInTheLoop, // Flag for updating forecasts in the solve loop
// Features
t_reserveLength, // Length of reserve provision horizon in time steps
......@@ -150,6 +150,21 @@ Sets
extraRes "Use extra tertiary reserves for error in elec. load during time step"
rampSched "Use power based scheduling"
/
* --- Set to declare time series that will be read between solves ------------------------------------------------------
timeseries "Names of time series that could be loop read from files between solves" /
ts_unit
ts_effUnit
ts_effGroupUnit
ts_influx
ts_cf
ts_reserveDemand
ts_nodeState
ts_fuelPriceChange
ts_fuelPrice
ts_unavailability
/
; // END Sets
* =============================================================================
......
......@@ -123,6 +123,9 @@ Sets
gnuGroup(grid, node, unit, group) "Grid, node, unit combinations in particular groups"
gn2nGroup(grid, node, node, group) "Transfer links in particular groups"
gnGroup(grid, node, group) "Grid, node combinations in particular gngroups"
* --- Set of timeseries that will be read from files between solves
mTimeseries_loop_read(mType, timeseries) "Those time series that will be read between solves"
;
* Set initial values to avoid errors when checking if parameter contents have been loaded from input data
Option clear = modelSolves;
......
......@@ -25,6 +25,7 @@ Scalars
ts_length "Length of time series (t)"
continueLoop "Helper to stop the looping early"
intervalLength "Legnth of the interval to be calculated, considering end of modelling period"
currentForecastLength "Length of the forecast in the curren solve, minimum of unchanging and decreasing forecast lengths"
count "General counter"
count_lambda, count_lambda2 "Counter for lambdas"
cum_slope "Cumulative for slope"
......@@ -130,10 +131,6 @@ Parameters
ts_reserveDemand_(restype, up_down, node, f, t)
ts_nodeState_(grid, node, param_gnBoundaryTypes, f, t)
ts_fuelPrice_(fuel, t)
// Temporary data time series for updating forecasts and reserve demand
ts_forecast(flow, node, t, f, t)
ts_tertiary(*,node,t,*,t)
;
* --- Other time dependent parameters -----------------------------------------
......
......@@ -21,15 +21,28 @@ $offtext
put log 'ord tSolve: ';
put log ord(tSolve) /;
putclose log;
if (mSettings(mSolve, 'readForecastsInTheLoop') and ord(tSolve) >= tForecastNext(mSolve),
put_utility 'gdxin' / 'input\forecasts\' tSolve.tl:0 '.gdx';
execute_load ts_forecast = forecast;
loop(mTimeseries_loop_read(mSolve, timeseries)${ord(tSolve) >= tForecastNext(mSolve)},
put_utility 'gdxin' / 'input\' timeseries.tl:0 '\' tSolve.tl:0 '.gdx';
if (mTimeseries_loop_read(mSolve, 'ts_unit'), execute_load ts_unit);
if (mTimeseries_loop_read(mSolve, 'ts_effUnit'), execute_load ts_effUnit);
if (mTimeseries_loop_read(mSolve, 'ts_effGroupUnit'), execute_load ts_effGroupUnit);
if (mTimeseries_loop_read(mSolve, 'ts_influx'), execute_load ts_influx);
if (mTimeseries_loop_read(mSolve, 'ts_cf'), execute_load ts_cf);
if (mTimeseries_loop_read(mSolve, 'ts_reserveDemand'), execute_load ts_reserveDemand);
if (mTimeseries_loop_read(mSolve, 'ts_nodeState'), execute_load ts_nodeState);
if (mTimeseries_loop_read(mSolve, 'ts_fuelPriceChange'), execute_load ts_fuelPriceChange);
if (mTimeseries_loop_read(mSolve, 'ts_unavailability'), execute_load ts_unavailability);
);
if (ord(tSolve) >= tForecastNext(mSolve),
// Update the next forecast
tForecastNext(mSolve)${ ord(tSolve) >= tForecastNext(mSolve) }
tForecastNext(mSolve)
= tForecastNext(mSolve) + mSettings(mSolve, 't_forecastJump');
);
$ontext
// Define t_latestForecast
Option clear = t_latestForecast;
t_latestForecast(tSolve) = yes;
......@@ -37,7 +50,7 @@ if (mSettings(mSolve, 'readForecastsInTheLoop') and ord(tSolve) >= tForecastNext
// Define updated time window
Option clear = tt_forecast;
tt_forecast(t_full(t))${ ord(t) >= ord(tSolve)
and ord(t) <= ord(tSolve) + mSettings(mSolve, 't_forecastLength') + mSettings(mSolve, 't_forecastJump')
and ord(t) <= ord(tSolve) + mSettings(mSolve, 't_forecastLengthUnchanging') + mSettings(mSolve, 't_forecastJump')
}
= yes;
......@@ -63,9 +76,8 @@ if (mSettings(mSolve, 'readForecastsInTheLoop') and ord(tSolve) >= tForecastNext
= ts_tertiary('wind', node, t+ddt(t), up_down, t)
* sum(flowUnit('wind', unit), p_gnu('elec', node, unit, 'maxGen'));
); // END IF readForecastsInTheLoop
$offtext
putclose log;
* --- Improve forecasts -------------------------------------------------------
*$ontext
......@@ -73,6 +85,13 @@ putclose log;
if(mSettings(mSolve, 'forecasts') > 0,
// Define updated time window
Option clear = tt_forecast;
tt_forecast(t_full(t))${ ord(t) >= ord(tSolve)
and ord(t) <= ord(tSolve) + mSettings(mSolve, 't_forecastLengthUnchanging') + mSettings(mSolve, 't_forecastJump')
}
= yes;
// Define updated time window
Option clear = tt;
tt(tt_forecast(t))${ ord(t) > ord(tSolve)
......
......@@ -124,7 +124,7 @@ $endif.debug
// Determine the timesteps of the current solve
tSolveFirst = ord(tSolve); // tSolveFirst: the start of the current solve, t0 used only for initial values
tSolveLast = ord(tSolve) + max(mSettings(mSolve, 't_forecastLength'), mSettings(mSolve, 't_horizon')); // tSolveLast: the end of the current solve
tSolveLast = ord(tSolve) + max(mSettings(mSolve, 't_forecastLengthUnchanging'), mSettings(mSolve, 't_horizon')); // tSolveLast: the end of the current solve
Option clear = t_current;
t_current(t_full(t))${ ord(t) >= tSolveFirst
and ord (t) <= tSolveLast
......@@ -149,6 +149,10 @@ tCounter = 1;
cc(counter)${ mInterval(mSolve, 'intervalLength', counter) }
= yes;
currentForecastLength = min( mSettings(mSolve, 't_forecastLengthUnchanging'), // Unchanging forecast length would remain the same
mSettings(mSolve, 't_forecastLengthDecreasesFrom') - [mSettings(mSolve, 't_forecastJump') - {tForecastNext(mSolve) - tSolveFirst}] // While decreasing forecast length has a fixed horizon point and thus gets shorter
); // Smallest forecast horizon is selected
// Loop over the defined intervals
loop(cc(counter),
// Loop over defined samples
......@@ -185,7 +189,7 @@ loop(cc(counter),
msft(msf(mSolve, s, f_solve), tt_interval(t))${ not mf_central(mSolve, f_solve)
and not mf_realization(mSolve, f_solve)
and ord(t) > tSolveFirst + mSettings(mSolve, 't_jump')
and ord(t) < tSolveFirst + mSettings(mSolve, 't_forecastLength')
and ord(t) < tSolveFirst + currentForecastLength
}
= yes;
......@@ -246,7 +250,7 @@ loop(cc(counter),
msft(msf(mSolve, s, f_solve), tt_interval(t))${ not mf_central(mSolve, f_solve)
and not mf_realization(mSolve, f_solve)
and ord(t) > tSolveFirst + mSettings(mSolve, 't_jump')
and ord(t) < tSolveFirst + mSettings(mSolve, 't_forecastLength')
and ord(t) < tSolveFirst + currentForecastLength
}
= yes;
......@@ -351,7 +355,7 @@ df(f_solve(f), t_active(t))${ ord(t) <= tSolveFirst + mSettings(mSolve, 't_jump'
// Forecast displacement between central and forecasted timesteps at the end of forecast horizon
Option clear = df_central; // This can be reset.
df_central(ft(f,t))${ ord(t) = tSolveFirst + mSettings(mSolve, 't_forecastLength') - p_stepLength(mSolve, f, t) / mSettings(mSolve, 'intervalInHours')
df_central(ft(f,t))${ ord(t) = tSolveFirst + mSettings(mSolve, 't_forecastLengthUnchanging') - p_stepLength(mSolve, f, t) / mSettings(mSolve, 'intervalInHours')
and not mf_realization(mSolve, f)
}
= sum(mf_central(mSolve, f_), ord(f_) - ord(f));
......
......@@ -49,7 +49,7 @@ loop((m, feature)$active(m, feature),
put /;
f_info.nd = 0; // Set number of decimals to zero
put "Start time: ", mSettings('schedule', 't_start')/;
put "Length of forecasts: ", mSettings('schedule', 't_forecastLength')/;
put "Length of forecasts: ", mSettings('schedule', 't_forecastLengthUnchanging')/;
put "Model horizon: ", mSettings('schedule', 't_horizon')/;
put "Model jumps after solve: ", mSettings('schedule', 't_jump')/;
put "Last time period to solve: ", mSettings('schedule', 't_end')/;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment