4a_outputVariant.gms 9.88 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$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

18
* =============================================================================
19
* --- Recording realized parameter values -------------------------------------
20
21
22
23
* =============================================================================
// !!! NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Have to go through my RealValue branch changes to the result arrays for
// More thought-out result arrays
24

25
26
27
28
29
30
31
32
33
34
35
36
* --- Result arrays required by model dynamics --------------------------------

// Realized state history
r_state(gn_state(grid, node), ft_realized(f, t))
    = v_state.l(grid, node, f, t)
;
// Realized unit online history
r_online(uft_online(unit, ft_realized(f, t)))
    = v_online_LP.l(unit, f, t)${ uft_onlineLP(unit, f, t)    }
        + v_online_MIP.l(unit, f, t)${  uft_onlineMIP(unit, f, t)   }
;
// Reserve provisions of units
37
38
r_reserve(nuRescapable(restype, up_down, node, unit), f_solve(f), t_active(t))${    mft_nReserves(node, restype, mSolve, f, t)
                                                                                    or sum(f_, df_nReserves(node, restype, f_, t))
39
40
41
42
                                                                                    or [     ord(t) > tSolveFirst + mSettings(mSolve, 't_jump')
                                                                                         and ord(t) <= tSolveFirst + mSettings(mSolve, 't_jump') + p_nReserves(node, restype, 'gate_closure') - mod(tSolveFirst - 1 + mSettings(mSolve, 't_jump'), p_nReserves(node, restype, 'update_frequency'))
                                                                                         and tSolveFirst <= mSettings(mSolve, 't_end') - mSettings(mSolve, 't_jump')
                                                                                       ]
43
                                                                                    }
44
45
46
    = v_reserve.l(restype, up_down, node, unit, f, t)
;
// Reserve transfer capacity
47
48
49
r_resTransferRightward(restypeDirectionNode(restype, up_down, from_node), to_node, f_solve(f), t_active(t))${   restypeDirectionNode(restype, up_down, to_node)
                                                                                                                and [   mft_nReserves(from_node, restype, mSolve, f, t)
                                                                                                                    or sum(f_, df_nReserves(from_node, restype, f_, t))
50
51
52
53
                                                                                                                    or [     ord(t) > tSolveFirst + mSettings(mSolve, 't_jump')
                                                                                                                         and ord(t) <= tSolveFirst + mSettings(mSolve, 't_jump') + p_nReserves(from_node, restype, 'gate_closure') - mod(tSolveFirst - 1 + mSettings(mSolve, 't_jump'), p_nReserves(from_node, restype, 'update_frequency'))
                                                                                                                         and tSolveFirst <= mSettings(mSolve, 't_end') - mSettings(mSolve, 't_jump')
                                                                                                                       ]
54
55
                                                                                                                    ]
                                                                                                                }
56
57
    = v_resTransferRightward.l(restype, up_down, from_node, to_node, f, t)
;
58
59
60
r_resTransferLeftward(restypeDirectionNode(restype, up_down, from_node), to_node, f_solve(f), t_active(t))${    restypeDirectionNode(restype, up_down, to_node)
                                                                                                                and [   mft_nReserves(from_node, restype, mSolve, f, t)
                                                                                                                    or sum(f_, df_nReserves(from_node, restype, f_, t))
61
62
63
64
                                                                                                                    or [     ord(t) > tSolveFirst + mSettings(mSolve, 't_jump')
                                                                                                                         and ord(t) <= tSolveFirst + mSettings(mSolve, 't_jump') + p_nReserves(from_node, restype, 'gate_closure') - mod(tSolveFirst - 1 + mSettings(mSolve, 't_jump'), p_nReserves(from_node, restype, 'update_frequency'))
                                                                                                                         and tSolveFirst <= mSettings(mSolve, 't_end') - mSettings(mSolve, 't_jump')
                                                                                                                       ]
65
66
                                                                                                                    ]
                                                                                                                }
67
68
69
70
71
72
    = v_resTransferLeftward.l(restype, up_down, from_node, to_node, f, t)
;
// Unit startup and shutdown history
r_startup(unit, starttype, ft_realized(f, t))${ uft_online(unit, f, t)  }
    = v_startup.l(unit, starttype, f, t)
;
73
74
75
r_shutdown(uft_online(unit, ft_realized(f, t)))
    = v_shutdown.l(unit, f, t)
;
76
77
78
79
80
81
82

* --- Interesting results -----------------------------------------------------

// Unit generation and consumption
r_gen(gnuft(grid, node, unit, ft_realized(f, t)))
    = v_gen.l(grid, node, unit, f, t)
;
83
84
85
86
// Fuel use of units
r_fuelUse(fuel, uft(unit_fuel, ft_realized(f, t)))
    = v_fuelUse.l(fuel, unit_fuel, f, t)
;
87
88
89
90
91
92
93
94
95
// Transfer of energy between nodes
r_transfer(gn2n(grid, from_node, to_node), ft_realized(f, t))
    = v_transfer.l(grid, from_node, to_node, f, t)
;
// Energy spilled from nodes
r_spill(gn(grid, node), ft_realized(f, t))
    = v_spill.l(grid, node, f, t)
;
// Total Objective function
96
97
98
99
100
r_totalObj
    = r_totalObj + v_obj.l
;
// q_balance marginal values
r_balanceMarginal(gn(grid, node), ft_realized(f, t))
101
    = q_balance.m(grid, node, mSolve, f, t)
102
103
104
105
106
;
// q_resDemand marginal values
r_resDemandMarginal(restypeDirectionNode(restype, up_down, node), ft_realized(f, t))
    = q_resDemand.m(restype, up_down, node, f, t)
;
107
108
109
// v_stateSlack values for calculation of realized costs later on
r_stateSlack(gn_stateSlack(grid, node), slack, ft_realized(f, t))
    = v_stateSlack.l(grid, node, slack, f, t)
110
;
111
// Unit investments
112
r_invest(unit)${unit_investLP(unit) or unit_investMIP(unit)}
113
    = v_invest_LP.l(unit) + v_invest_MIP.l(unit)
114
;
115
116
117
118
119
120
121
122
// Link investments
r_investTransfer(grid, node, node_, t_invest(t))${ p_gnn(grid, node, node_, 'transferCapInvLimit')
                                                   and t_current(t)
                                                   and ord(t) <= tSolveFirst + mSettings(mSolve, 't_jump')
                                                   }
    = v_investTransfer_LP.l(grid, node, node_, t)
        + v_investTransfer_MIP.l(grid, node, node_, t) * p_gnn(grid, node, node_, 'unitSize')
;
123
124
125
126
127
128
129
130
131
132
133
134
135
136

* --- Feasibility results -----------------------------------------------------

// Dummy generation & consumption
r_qGen(inc_dec, gn(grid, node), ft_realized(f, t))
    = vq_gen.l(inc_dec, grid, node, f, t)
;
// Dummy reserve demand changes
r_qResDemand(restypeDirectionNode(restype, up_down, node), ft_realized(f, t))
    = vq_resDemand.l(restype, up_down, node, f, t)
;

* --- Diagnostics Results -----------------------------------------------------

137
// Capacity factors for examining forecast errors
Topi Rasku's avatar
Topi Rasku committed
138
d_capacityFactor(flowNode(flow, node), f_solve(f), t_active(t))${ sum(flowUnit(flow, unit), nu(node, unit)) }
139
140
    = ts_cf_(flow, node, f, t)
        + ts_cf(flow, node, f, t)${ not ts_cf_(flow, node, f, t) }
Topi Rasku's avatar
Topi Rasku committed
141
142
143
144
145
146
147
148
149
150
151
152
        - 1e-3${    not ts_cf_(flow, node, f, t)
                    and not ts_cf(flow, node, f, t)
                    }
;
// Temperature forecast for examining the error
d_nodeState(gn_state(grid, node), param_gnBoundaryTypes, f_solve(f), t_active(t))${ p_gnBoundaryPropertiesForStates(grid, node, param_gnBoundaryTypes, 'useTimeseries') }
    = ts_nodeState_(grid, node, param_gnBoundaryTypes, f, t)
        + ts_nodeState(grid, node, param_gnBoundaryTypes, f, t)${ not ts_nodeState_(grid, node, param_gnBoundaryTypes, f, t) }
        - 1e-3${    not ts_nodeState_(grid, node, param_gnBoundaryTypes, f, t)
                    and not ts_nodeState_(grid, node, param_gnBoundaryTypes, f, t)
                    }
;
153
154

* --- Model Solve & Status ----------------------------------------------------
155

156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
// Model/solve status
if (mSolve('schedule'),
    r_solveStatus(tSolve,'modelStat')=schedule.modelStat;
    r_solveStatus(tSolve,'solveStat')=schedule.solveStat;
    r_solveStatus(tSolve,'totalTime')=schedule.etSolve;
    r_solveStatus(tSolve,'iterations')=schedule.iterUsd;
    r_solveStatus(tSolve,'nodes')=schedule.nodUsd;
    r_solveStatus(tSolve,'numEqu')=schedule.numEqu;
    r_solveStatus(tSolve,'numDVar')=schedule.numDVar;
    r_solveStatus(tSolve,'numVar')=schedule.numVar;
    r_solveStatus(tSolve,'numNZ')=schedule.numNZ;
    r_solveStatus(tSolve,'sumInfes')=schedule.sumInfes;
    r_solveStatus(tSolve,'objEst')=schedule.objEst;
    r_solveStatus(tSolve,'objVal')=schedule.objVal;
);

172
173