Skip to content

Commit 4802a91

Browse files
authored
Minor update to variable names (#7)
* Minor update to variable names * Added fixed `link_opex_fixed`
1 parent faf8ac6 commit 4802a91

3 files changed

Lines changed: 24 additions & 19 deletions

File tree

docs/src/links/capacitycostlink.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ with paranthesis.
9191

9292
Two additional variables track capacity utilization and associated costs over sub-periods:
9393

94-
- ``\texttt{ccl\_max\_cap\_use}[l, t_{sub}]``: Maximum capacity usage in sub-period ``t_{sub}`` for link ``l``.
95-
- ``\texttt{ccl\_cap\_cost}[l, t_{sub}]``: Operational cost in sub-period ``t_{sub}`` for link ``l``.
94+
- ``\texttt{ccl\_cap\_use\_max}[l, t_{sub}]``: Maximum capacity usage in sub-period ``t_{sub}`` for link ``l``.
95+
- ``\texttt{ccl\_cap\_use\_cost}[l, t_{sub}]``: Operational cost in sub-period ``t_{sub}`` for link ``l``.
9696

9797
### [Constraints](@id links-CapacityCostLink-math-con)
9898

@@ -117,21 +117,21 @@ All additional constraints are created within a new method for the function [`cr
117117
The capacity utilization constraint tracks the maximum usage within each sub-period:
118118

119119
```math
120-
\texttt{link\_in}[l, t, cap\_resource(l)] \leq \texttt{ccl\_max\_cap\_use}[l, t_{sub}]
120+
\texttt{link\_in}[l, t, cap\_resource(l)] \leq \texttt{ccl\_cap\_use\_max}[l, t_{sub}]
121121
```
122122

123123
The capacity cost is calculated as:
124124

125125
```math
126-
\texttt{ccl\_cap\_cost}[l, t_{sub}] = \texttt{ccl\_max\_cap\_use}[l, t_{sub}] \times \overline{cap\_price}(l, t_{sub})
126+
\texttt{ccl\_cap\_use\_cost}[l, t_{sub}] = \texttt{ccl\_cap\_use\_max}[l, t_{sub}] \times \overline{cap\_price}(l, t_{sub})
127127
```
128128

129129
where ``\overline{cap\_price}`` is the average capacity price over the sub-period.
130130

131131
Finally, costs are aggregated to each strategic period:
132132

133133
```math
134-
\texttt{link\_opex\_var}[l, t_{inv}] = \sum_{t_{sub} \in t_{inv}} \texttt{ccl\_cap\_cost}[l, t_{sub}]
134+
\texttt{link\_opex\_var}[l, t_{inv}] = \sum_{t_{sub} \in t_{inv}} \texttt{ccl\_cap\_use\_cost}[l, t_{sub}]
135135
```
136136

137137
In addition, the energy flow of the constrained resource should not exceed the maximum pipe capacity, which is included through the following constraint:

src/link/model.jl

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
EMB.variables_element(m, ℒˢᵘᵇ::Vector{<:CapacityCostLink}, 𝒯, modeltype::EnergyModel)
33
44
Creates the following additional variable for **ALL** capacity cost links:
5-
- `ccl_max_cap_use[l, t]` is a continuous variable describing the maximum capacity
5+
- `ccl_cap_use_max[l, t]` is a continuous variable describing the maximum capacity
66
usage over sub periods for a [`CapacityCostLink`](@ref) `l` in operational period `t`.
7-
- `ccl_cap_cost[l, t]` is a continuous variable describing the cost over sub periods
7+
- `ccl_cap_use_cost[l, t]` is a continuous variable describing the cost over sub periods
88
for a [`CapacityCostLink`](@ref) `l` in operational period `t`.
99
"""
1010
function EMB.variables_element(m, ℒˢᵘᵇ::Vector{<:CapacityCostLink}, 𝒯, ::EnergyModel)
11-
@variable(m, ccl_max_cap_use[ℒˢᵘᵇ, 𝒯] >= 0)
12-
@variable(m, ccl_cap_cost[ℒˢᵘᵇ, 𝒯] >= 0)
11+
@variable(m, ccl_cap_use_max[ℒˢᵘᵇ, 𝒯] >= 0)
12+
@variable(m, ccl_cap_use_cost[ℒˢᵘᵇ, 𝒯] >= 0)
1313
end
1414

1515
"""
@@ -46,20 +46,25 @@ function EMB.create_link(
4646

4747
# Max capacity use constraints
4848
@constraint(m, [t_sub 𝒯ˢᵘᵇ, t t_sub],
49-
m[:link_in][l, t, p_cap] .≤ m[:ccl_max_cap_use][l, t_sub]
49+
m[:link_in][l, t, p_cap] .≤ m[:ccl_cap_use_max][l, t_sub]
5050
)
5151

5252
# Capacity cost constraint
5353
@constraint(m, [t_sub 𝒯ˢᵘᵇ],
54-
m[:ccl_cap_cost][l, t_sub[end]] ==
55-
m[:ccl_max_cap_use][l, t_sub[end]] * avg_cap_price(l, t_sub)
54+
m[:ccl_cap_use_cost][l, t_sub[end]] ==
55+
m[:ccl_cap_use_max][l, t_sub[end]] * avg_cap_price(l, t_sub)
5656
)
5757

5858
# Sum up costs for each sub_period into the strategic period cost
5959
@constraint(m, [t_inv 𝒯ᴵⁿᵛ],
6060
m[:link_opex_var][l, t_inv] ==
61-
sum(m[:ccl_cap_cost][l, t] for t t_inv)
61+
sum(m[:ccl_cap_use_cost][l, t] for t t_inv)
6262
)
63+
64+
# Fix the fixed OPEX to avoid unconstrainted variables
65+
for t_inv 𝒯ᴵⁿᵛ
66+
fix(m[:link_opex_fixed][l, t_inv], 0; force = true)
67+
end
6368
end
6469

6570
"""

test/link/test_CapacityCostLink.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,27 +207,27 @@ end
207207
)
208208

209209
# Max capacity use per sub-period:
210-
# link_in[t] ≤ ccl_max_cap_use[t_sub_end]
210+
# link_in[t] ≤ ccl_cap_use_max[t_sub_end]
211211
@test all(
212212
all(
213213
value(m[:link_in][cc_link, t, power])
214-
value(m[:ccl_max_cap_use][cc_link, t_sub[end]])
214+
value(m[:ccl_cap_use_max][cc_link, t_sub[end]])
215215
for t t_sub
216216
)
217217
for t_sub 𝒯ˢᵘᵇ
218218
)
219219

220220
# Capacity cost at end of sub-period: cap_cost == max_cap_use * avg_cap_price
221221
@test all(
222-
value(m[:ccl_cap_cost][cc_link, t_sub[end]])
223-
value(m[:ccl_max_cap_use][cc_link, t_sub[end]]) * EMF.avg_cap_price(cc_link, t_sub)
222+
value(m[:ccl_cap_use_cost][cc_link, t_sub[end]])
223+
value(m[:ccl_cap_use_max][cc_link, t_sub[end]]) * EMF.avg_cap_price(cc_link, t_sub)
224224
for t_sub 𝒯ˢᵘᵇ
225225
)
226226

227-
# Strategic-period sum: link_opex_var == sum(ccl_cap_cost over t_inv)
227+
# Strategic-period sum: link_opex_var == sum(ccl_cap_use_cost over t_inv)
228228
@test all(
229229
value(m[:link_opex_var][cc_link, t_inv])
230-
sum(value(m[:ccl_cap_cost][cc_link, t]) for t t_inv)
230+
sum(value(m[:ccl_cap_use_cost][cc_link, t]) for t t_inv)
231231
for t_inv 𝒯ᴵⁿᵛ
232232
)
233233

0 commit comments

Comments
 (0)