3b_inputsLoop.gms 3.66 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
    put_utility 'gdxin' / 'input\forecasts\' tSolve.tl:0 '.gdx';
    execute_load ts_forecast = forecast;

    // Update the next forecast
28
29
    tForecastNext(mSolve)${ ord(tSolve) >= tForecastNext(mSolve) }
        = tForecastNext(mSolve) + mSettings(mSolve, 't_forecastJump');
30
31
32

    // Define tLatestForecast
    Option clear = tLatestForecast;
33
    tLatestForecast(tSolve) = yes;
34
35

    // Define updated time window
36
    Option clear = tt_;
37
38
39
    tt_(tFull(t))${ ord(t) >= ord(tSolve)
                    and ord(t) <= ord(tSolve) + mSettings(mSolve, 't_forecastLength') + mSettings(mSolve, 't_ForecastJump')
                    }
40
        = yes;
41
42
43

    // Update capacity factor data
    loop(tLatestForecast,  // There should be only one latest forecast
44
45
46
47
        ts_cf(flow, node, fSolve(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);
48
49
50
51
52
    );

    // Read the tertiary reserve requirements
    put_utility 'gdxin' / 'input\tertiary\' tSolve.tl:0 '.gdx';
    execute_load ts_tertiary;
53
54
    ts_reserveDemand('tertiary', up_down, node, f, tt_(t))${    mf(mSolve, f)
                                                                and gn('elec', node)
55
                                                                and not mfRealization(mSolve, f)
56
57
58
                                                                }
*        = 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')));
59

60
); // END IF readForecastsInTheLoop
61
62

putclose log;
63
64

* --- Improve forecasts -------------------------------------------------------
65
$ontext
66
67
68
69
// !!! TEMPORARY MEASURES !!!
if(mSettings(mSolve, 'forecasts') > 0,

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

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