3b_inputsLoop.gms 3.59 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$ontext
This file is part of Backbone.

Backbone is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Backbone is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
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
17
18
19

* --- Update the data with forecasts ------------------------------------------

20
21
22
23
put log 'ord tSolve: ';
put log ord(tSolve) /;

if (mSettings(mSolve, 'readForecastsInTheLoop') and ord(tSolve) >= tForecastNext(mSolve),
24
25
26
27
28
29
30
31
32
33
34
35
    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
36
37
38
39
40
    Option clear = tt_;
    tt_(t)${    ord(t) >= ord(tSolve)
                and ord(t) <= ord(tSolve) + mSettings(mSolve, 't_forecastLength') + mSettings(mSolve, 't_ForecastJump')
                }
        = yes;
41
42
43

    // Update capacity factor data
    loop(tLatestForecast,  // There should be only one latest forecast
44
        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!
45
46
47
48
49
50
51
                                        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;
52
53
    ts_reserveDemand('tertiary', up_down, node, f, tt_(t))${    mf(mSolve, f)
                                                                and gn('elec', node)
54
                                                                and not mfRealization(mSolve, f)
55
56
57
                                                                }
*        = min(500, ts_tertiary('wind', node, tSolve, up_down, t) * sum(flowUnit('wind', unit), p_gnu('elec', node, unit, 'maxGen')));
        = max(p_nReserves(node, 'primary', up_down), ts_tertiary('wind', node, tSolve, up_down, t) * sum(flowUnit('wind', unit), p_gnu('elec', node, unit, 'maxGen')));
58

59
); // END IF readForecastsInTheLoop
60
61

putclose log;
62
63
64

* --- Improve forecasts -------------------------------------------------------

65
66
67
68
// !!! TEMPORARY MEASURES !!!
if(mSettings(mSolve, 'forecasts') > 0,

    // Define updated time window
69
70
71
72
73
    Option clear = tt_;
    tt_(t)${    ord(t) >= ord(tSolve)
                and ord(t) <= ord(tSolve) + f_improve
                }
        = yes;
74
75

    // Improve capacity factors, linear improvement towards fRealization
76
77
78
    loop(mfRealization(mSolve, f_),
        ts_cf(flow, node, f, tt_(t))${  not mfRealization(mSolve, f)
                                        and mfRealization(mSolve, f_)
79
80
81
82
83
84
85
                                        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;
    );
); // END IF forecasts