Commit 11c233b1 authored by Topi Rasku's avatar Topi Rasku
Browse files

Rewrote the forecast update and improvement code into "inputsLoop", and fixed...

Rewrote the forecast update and improvement code into "inputsLoop", and fixed an issue where all capacity factor time series were being updated even if there was no data to update them.
parent d09f6ac3
......@@ -75,17 +75,6 @@ fSolve(f)$mf(mSolve,f) = yes;
tSolveFirst = ord(tSolve); // tSolveFirst: the start of the current solve
tSolveLast = ord(tSolve) + max(mSettings(mSolve, 't_forecastLength'), mSettings(mSolve, 't_horizon')); // tSolveLast: the end of the current solve
// Determine the next and latest forecasts
tForecastNext(mSolve)${ ord(tSolve) >= tForecastNext(mSolve)
} = tForecastNext(mSolve) + mSettings(mSolve, 't_ForecastJump');
loop(tLatestForecast, // There should be only one latest forecast
ts_cf(flow,node,f,t)${ ord(f) > 1
and ord(f) <= mSettings(mSolve, 'forecasts') + 1
and ord(t) >= tSolveFirst + f_improve and
ord(t) <= tSolveFirst + mSettings(mSolve, 't_forecastLength')
} = ts_forecast(flow,node,tLatestForecast,f,t);
);
// Initializing sets and counters
Option clear = tCounter;
Option clear = p_stepLength;
......
......@@ -14,20 +14,62 @@ GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Backbone. If not, see <http://www.gnu.org/licenses/>.
$offtext
* --- Update the data with forecasts ------------------------------------------
put log 'ord tSolve: ';
put log ord(tSolve) /;
if (mSettings(mSolve, 'readForecastsInTheLoop') and ord(tSolve) >= tForecastNext(mSolve),
put_utility 'gdxin' / 'input\forecasts\' tSolve.tl:0 '.gdx';
execute_load ts_forecast = forecast;
tLatestForecast(t) = no;
tLatestForecast(t)$(ord(t) = ord(tSolve)) = yes;
put_utility 'gdxin' / 'input\tertiary\' tSolve.tl:0 '.gdx';
execute_load ts_tertiary;
ts_reserveDemand('tertiary', 'up', node, f, t)${ mf(mSolve, f)
and not fRealization(f)
} = min(500, ts_tertiary('wind', node, tSolve, 'up', t) * sum(flowUnit('wind', unit), p_gnu('elec', node, unit, 'maxGen')));
);
put_utility 'gdxin' / 'input\forecasts\' tSolve.tl:0 '.gdx';
execute_load ts_forecast = forecast;
// Update the next forecast
tForecastNext(mSolve)${ ord(tSolve) >= tForecastNext(mSolve)
} = tForecastNext(mSolve) + mSettings(mSolve, 't_ForecastJump');
// Define tLatestForecast
Option clear = tLatestForecast;
tLatestForecast(t)$(ord(t) = ord(tSolve)) = yes;
// Define updated time window
Option clear = tt;
tt(t)${ ord(t) >= ord(tSolve)
and ord(t) <= ord(tSolve) + mSettings(mSolve, 't_forecastLength') + mSettings(mSolve, 't_ForecastJump')
} = yes;
// Update capacity factor data
loop(tLatestForecast, // There should be only one latest forecast
ts_cf(flow, node, f, tt(t))${ ts_forecast(flow, node, tLatestForecast, f, t) // Only update data for capacity factors with forecast. NOTE! This results in problems if the forecast has values of zero!
and mf(mSolve, f)
} = ts_forecast(flow,node,tLatestForecast,f,t);
);
// Read the tertiary reserve requirements
put_utility 'gdxin' / 'input\tertiary\' tSolve.tl:0 '.gdx';
execute_load ts_tertiary;
ts_reserveDemand('tertiary', up_down, node, f, tt(t))${ mf(mSolve, f)
and not fRealization(f)
} = min(500, ts_tertiary('wind', node, tSolve, up_down, t) * sum(flowUnit('wind', unit), p_gnu('elec', node, unit, 'maxGen')));
); // END IF readForecastsInTheLoop
putclose log;
* --- Improve forecasts -------------------------------------------------------
// Define updated time window
Option clear = tt;
tt(t)${ ord(t) >= ord(tSolve)
and ord(t) <= ord(tSolve) + f_improve
} = yes;
// Improve capacity factors, linear improvement towards fRealization
loop(fRealization(f_),
ts_cf(flow, node, f, tt(t))${ not fRealization(f)
and fRealization(f_)
and mf(mSolve, f)
} = (
(ord(t) - ord(tSolve)) * ts_cf(flow, node, f, t)
+ (f_improve + ord(tSolve) - ord(t)) * ts_cf(flow, node, f_, t)
) / f_improve;
);
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