Remove old reserves

This commit is contained in:
2022-01-20 15:51:23 -06:00
parent 3220650e39
commit 5ca566f147
7 changed files with 29 additions and 109 deletions

View File

@@ -28,42 +28,18 @@ function _add_net_injection_eqs!(model::JuMP.Model)::Nothing
end
function _add_reserve_eqs!(model::JuMP.Model)::Nothing
eq_min_reserve = _init(model, :eq_min_reserve)
instance = model[:instance]
for t in 1:instance.time
# Equation (68) in Kneuven et al. (2020)
# As in Morales-España et al. (2013a)
# Akin to the alternative formulation with max_power_avail
# from Carrión and Arroyo (2006) and Ostrowski et al. (2012)
shortfall_penalty = instance.shortfall_penalty[t]
eq_min_reserve[t] = @constraint(
model,
sum(model[:reserve][g.name, t] for g in instance.units) +
(shortfall_penalty >= 0 ? model[:reserve_shortfall][t] : 0.0) >=
instance.reserves.spinning[t]
)
# Account for shortfall contribution to objective
if shortfall_penalty >= 0
add_to_expression!(
model[:obj],
shortfall_penalty,
model[:reserve_shortfall][t],
)
end
end
eq_min_reserve2 = _init(model, :eq_min_reserve2)
for r in instance.reserves2
eq_min_reserve = _init(model, :eq_min_reserve)
for r in instance.reserves
for t in 1:instance.time
# Equation (68) in Kneuven et al. (2020)
# As in Morales-España et al. (2013a)
# Akin to the alternative formulation with max_power_avail
# from Carrión and Arroyo (2006) and Ostrowski et al. (2012)
eq_min_reserve2[r.name, t] = @constraint(
eq_min_reserve[r.name, t] = @constraint(
model,
sum(model[:reserve2][r.name, g.name, t] for g in r.units) +
model[:reserve_shortfall2][r.name, t] >= r.amount[t]
sum(model[:reserve][r.name, g.name, t] for g in r.units) +
model[:reserve_shortfall][r.name, t] >= r.amount[t]
)
# Account for shortfall contribution to objective
@@ -71,7 +47,7 @@ function _add_reserve_eqs!(model::JuMP.Model)::Nothing
add_to_expression!(
model[:obj],
r.shortfall_penalty,
model[:reserve_shortfall2][r.name, t],
model[:reserve_shortfall][r.name, t],
)
end
end

View File

@@ -45,26 +45,13 @@ _is_initially_on(g::Unit)::Float64 = (g.initial_status > 0 ? 1.0 : 0.0)
function _add_reserve_vars!(model::JuMP.Model, g::Unit)::Nothing
reserve = _init(model, :reserve)
reserve_shortfall = _init(model, :reserve_shortfall)
for t in 1:model[:instance].time
if g.provides_spinning_reserves[t]
reserve[g.name, t] = @variable(model, lower_bound = 0)
else
reserve[g.name, t] = 0.0
end
reserve_shortfall[t] =
(model[:instance].shortfall_penalty[t] >= 0) ?
@variable(model, lower_bound = 0) : 0.0
end
reserve2 = _init(model, :reserve2)
reserve_shortfall2 = _init(model, :reserve_shortfall2)
for r in g.reserves
for t in 1:model[:instance].time
reserve2[r.name, g.name, t] = @variable(model, lower_bound = 0)
if (r.name, t) keys(reserve_shortfall2)
reserve_shortfall2[r.name, t] = @variable(model, lower_bound = 0)
reserve[r.name, g.name, t] = @variable(model, lower_bound = 0)
if (r.name, t) keys(reserve_shortfall)
reserve_shortfall[r.name, t] = @variable(model, lower_bound = 0)
if r.shortfall_penalty < 0
set_upper_bound(reserve_shortfall2[r.name, t], 0.0)
set_upper_bound(reserve_shortfall[r.name, t], 0.0)
end
end
end
@@ -225,10 +212,10 @@ end
function _total_reserves(model, g)::Vector
T = model[:instance].time
reserve = [model[:reserve][g.name, t] for t in 1:T]
reserve = 0.0
if !isempty(g.reserves)
reserve += [
sum(model[:reserve2][r.name, g.name, t] for r in g.reserves) for
sum(model[:reserve][r.name, g.name, t] for r in g.reserves) for
t in 1:model[:instance].time
]
end