EridanusQ commited on
Commit
f12c3ea
·
1 Parent(s): 35f2452
UnitCommitment_Trajectory_Test/src/model/formulations/xxx2005/powertrajectories.jl ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function _add_power_trajectory_eqs!(
2
+ model::JuMP.Model,
3
+ g::ThermalUnit,
4
+ formulation_prod_vars::Gar1962.ProdVars,
5
+ formulation_power_trajectories::xxx2005.PowerTrajectories,
6
+ formulation_status_vars::Gar1962.StatusVars,
7
+ sc::UnitCommitmentScenario,
8
+ )::Nothing
9
+ if isempty(g.startup_curve) || isempty(g.shutdown_curve)
10
+ return
11
+ end
12
+
13
+ T_del = model[:instance].time
14
+ if haskey(model, :eq_ramp_up) && haskey(model, :eq_ramp_down)
15
+ for t in 1:T_del
16
+ key = (sc.name, g.name, t)
17
+ if haskey(model[:eq_ramp_up], key)
18
+ delete(model, model[:eq_ramp_up][key])
19
+ delete!(model[:eq_ramp_up], key)
20
+ end
21
+ if haskey(model[:eq_ramp_down], key)
22
+ delete(model, model[:eq_ramp_down][key])
23
+ delete!(model[:eq_ramp_down], key)
24
+ end
25
+ end
26
+ end
27
+
28
+ T = model[:instance].time
29
+ UD = length(g.startup_curve)
30
+ DD = length(g.shutdown_curve)
31
+ P_U = g.startup_curve
32
+ P_D = g.shutdown_curve
33
+ if haskey(model, :segprod)
34
+ for t in 1:T_del
35
+ su_min = isempty(P_U) ? 0.0 : minimum(P_U)
36
+ if su_min < g.min_power[t]
37
+ key1 = (sc.name, g.name, t, 1)
38
+ if haskey(model[:segprod], key1)
39
+ set_lower_bound(model[:segprod][key1], su_min - g.min_power[t])
40
+ end
41
+ end
42
+ end
43
+ end
44
+ RU = g.ramp_up_limit
45
+ RD = g.ramp_down_limit
46
+ gn = g.name
47
+
48
+ is_on = model[:is_on]
49
+ switch_on = model[:switch_on]
50
+ switch_off= model[:switch_off]
51
+
52
+ eq_startup_lb = _init(model, :eq_arr_startup_lb)
53
+ eq_startup_ub = _init(model, :eq_arr_startup_ub)
54
+ eq_shutdown_lb = _init(model, :eq_arr_shutdown_lb)
55
+ eq_shutdown_ub = _init(model, :eq_arr_shutdown_ub)
56
+ eq_ramp_up = _init(model, :eq_arr_ramp_up)
57
+ eq_ramp_down = _init(model, :eq_arr_ramp_down)
58
+ eq_overlap_logic = _init(model, :eq_overlap_logic)
59
+ eq_overlap_su_lb = _init(model, :eq_overlap_su_lb)
60
+ eq_overlap_sd_lb = _init(model, :eq_overlap_sd_lb)
61
+
62
+ for t in 1:T
63
+ Pmax = g.max_power[t]
64
+ Pmin = g.min_power[t]
65
+ p_t = _actual_power(model, g, sc, t)
66
+ su_prod = sum(
67
+ P_U[i] * switch_on[gn, t - i + 1]
68
+ for i in 1:UD if t - i + 1 >= 1;
69
+ init = 0.0
70
+ )
71
+ # Σ y(k-i+1)
72
+ su_sum = sum(
73
+ switch_on[gn, t - i + 1]
74
+ for i in 1:UD if t - i + 1 >= 1;
75
+ init = 0
76
+ )
77
+ # Σ P_D(i)·z(k+DD-i+1)
78
+ sd_prod = sum(
79
+ P_D[i] * switch_off[gn, t + DD - i + 1]
80
+ for i in 1:DD if t + DD - i + 1 <= T;
81
+ init = 0.0
82
+ )
83
+ # Σ z(k+i)
84
+ sd_sum = sum(
85
+ switch_off[gn, t + i]
86
+ for i in 1:DD if t + i <= T;
87
+ init = 0
88
+ )
89
+
90
+ # [1] 启动下限
91
+ eq_startup_lb[sc.name, gn, t] = @constraint(
92
+ model,
93
+ p_t >= Pmin * (is_on[gn, t] - su_sum - sd_sum) + su_prod
94
+ )
95
+
96
+ # [2] 停止下限
97
+ eq_shutdown_lb[sc.name, gn, t] = @constraint(
98
+ model,
99
+ p_t >= Pmin * (is_on[gn, t] - su_sum - sd_sum) + sd_prod
100
+ )
101
+
102
+ # [3] 启动上限
103
+ eq_startup_ub[sc.name, gn, t] = @constraint(
104
+ model,
105
+ p_t <= su_prod + Pmax * (is_on[gn, t] - su_sum)
106
+ )
107
+
108
+ # [4] 停止上限
109
+ eq_shutdown_ub[sc.name, gn, t] = @constraint(
110
+ model,
111
+ p_t <= sd_prod + Pmax * (is_on[gn, t] - sd_sum)
112
+ )
113
+
114
+ # [10]
115
+ eq_overlap_logic[sc.name, gn, t] = @constraint(
116
+ model,
117
+ switch_on[gn, t] + sum(
118
+ switch_off[gn, t + j]
119
+ for j in 0:(UD + DD - 2) if t + j <= T;
120
+ init = 0
121
+ ) <= 1
122
+ )
123
+
124
+ # [11] & [12]
125
+ eq_overlap_su_lb[sc.name, gn, t] = @constraint(
126
+ model,
127
+ p_t >= P_U[UD] * (su_sum + sd_sum - 1)
128
+ )
129
+
130
+ eq_overlap_sd_lb[sc.name, gn, t] = @constraint(
131
+ model,
132
+ p_t >= P_D[1] * (su_sum + sd_sum - 1)
133
+ )
134
+
135
+ # [5]
136
+ if t == 1
137
+ g.initial_status > 0 || continue
138
+ p_prev = g.initial_power
139
+ else
140
+ p_prev = _actual_power(model, g, sc, t - 1)
141
+ end
142
+ eq_ramp_up[sc.name, gn, t] = @constraint(
143
+ model,
144
+ p_t - p_prev <= Pmax * su_sum + RU * (is_on[gn, t] - su_sum)
145
+ )
146
+
147
+ # [6]
148
+ if t > 1
149
+ p_prev_rd = _actual_power(model, g, sc, t - 1)
150
+ sd_sum_prev = sum(
151
+ switch_off[gn, (t-1) + i]
152
+ for i in 1:DD if (t-1) + i <= T;
153
+ init = 0
154
+ )
155
+ eq_ramp_down[sc.name, gn, t] = @constraint(
156
+ model,
157
+ p_prev_rd - p_t <= Pmax * sd_sum_prev + RD * (is_on[gn, t-1] - sd_sum_prev)
158
+ )
159
+ end
160
+
161
+ reserve_t = _total_reserves(model, g, sc)[t]
162
+ @constraint(
163
+ model,
164
+ reserve_t <= Pmax * (is_on[gn, t] - su_sum - sd_sum)
165
+ )
166
+ end
167
+ return
168
+ end
UnitCommitment_Trajectory_Test/src/model/formulations/xxx2005/structs.jl ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ module xxx2005
2
+
3
+ import ..PowerTrajectoriesFormulation
4
+
5
+ struct PowerTrajectories <: PowerTrajectoriesFormulation end
6
+
7
+ end