Ran JuliaFormatter

add_formulations
Aleksandr Kazachkov 4 years ago
parent 1058270db3
commit 8fbf00845a

@ -35,7 +35,7 @@ function _add_ramp_eqs!(
RESERVES_WHEN_RAMP_DOWN = true
RESERVES_WHEN_SHUT_DOWN = true
is_initially_on = _is_initially_on(g)
# The following are the same for generator g across all time periods
SU = g.startup_limit # startup rate
SD = g.shutdown_limit # shutdown rate

@ -72,7 +72,11 @@ function _add_status_vars!(
# In the first time period, force unit to switch on if was off before
# Otherwise, unit is on, and will never turn off, so will never need to turn on
fix(is_on[g.name, t], 1.0; force = true)
fix(switch_on[g.name, t], (t == 1 ? 1.0 - _is_initially_on(g) : 0.0); force = true)
fix(
switch_on[g.name, t],
(t == 1 ? 1.0 - _is_initially_on(g) : 0.0);
force = true,
)
fix(switch_off[g.name, t], 0.0; force = true)
elseif t == 1
if is_initially_on
@ -89,7 +93,8 @@ function _add_status_vars!(
# Add explicit constraint if !FIX_VARS
if g.must_run[t]
is_on[g.name, t] = 1.0
switch_on[g.name, t] = (t == 1 ? 1.0 - _is_initially_on(g) : 0.0)
switch_on[g.name, t] =
(t == 1 ? 1.0 - _is_initially_on(g) : 0.0)
switch_off[g.name, t] = 0.0
elseif t == 1
if is_initially_on

@ -45,7 +45,12 @@ function _add_unit!(model::JuMP.Model, g::Unit, formulation::Formulation)
)
_add_startup_cost_eqs!(model, g, formulation.startup_costs)
_add_shutdown_cost_eqs!(model, g)
_add_startup_shutdown_limit_eqs!(model, g, formulation.status_vars, formulation.prod_vars)
_add_startup_shutdown_limit_eqs!(
model,
g,
formulation.status_vars,
formulation.prod_vars,
)
_add_status_eqs!(model, g, formulation.status_vars)
return
end
@ -119,7 +124,7 @@ function _add_startup_shutdown_limit_eqs!(
model::JuMP.Model,
g::Unit,
formulation_status_vars::Gar1962.StatusVars,
formulation_prod_vars::Gar1962.ProdVars
formulation_prod_vars::Gar1962.ProdVars,
)::Nothing
eq_shutdown_limit = _init(model, :eq_shutdown_limit)
eq_startup_limit = _init(model, :eq_startup_limit)
@ -145,7 +150,8 @@ function _add_startup_shutdown_limit_eqs!(
# Generator producing too much to be turned off in the first time period
# (can a binary variable have bounds x = 0?)
if formulation_status_vars.fix_vars_via_constraint
eq_shutdown_limit[g.name, 0] = @constraint(model, model[:switch_off][g.name, 1] <= 0.0)
eq_shutdown_limit[g.name, 0] =
@constraint(model, model[:switch_off][g.name, 1] <= 0.0)
else
fix(model[:switch_off][g.name, 1], 0.0; force = true)
end
@ -265,16 +271,16 @@ function _add_min_uptime_downtime_eqs!(model::JuMP.Model, g::Unit)::Nothing
# Equation (4) in Knueven et al. (2020)
eq_min_uptime[g.name, t] = @constraint(
model,
sum(switch_on[g.name, i] for i in (t-g.min_uptime+1):t if i >= 1)
<= is_on[g.name, t]
sum(switch_on[g.name, i] for i in (t-g.min_uptime+1):t if i >= 1) <= is_on[g.name, t]
)
# Minimum down-time
# Equation (5) in Knueven et al. (2020)
eq_min_downtime[g.name, t] = @constraint(
model,
sum(switch_off[g.name, i] for i in (t-g.min_downtime+1):t if i >= 1)
<= 1 - is_on[g.name, t]
sum(
switch_off[g.name, i] for i in (t-g.min_downtime+1):t if i >= 1
) <= 1 - is_on[g.name, t]
)
# Minimum up/down-time for initial periods

Loading…
Cancel
Save