mirror of
https://github.com/ANL-CEEESA/UnitCommitment.jl.git
synced 2025-12-06 00:08:52 -06:00
Ran JuliaFormatter
This commit is contained in:
@@ -35,7 +35,7 @@ function _add_ramp_eqs!(
|
|||||||
RESERVES_WHEN_RAMP_DOWN = true
|
RESERVES_WHEN_RAMP_DOWN = true
|
||||||
RESERVES_WHEN_SHUT_DOWN = true
|
RESERVES_WHEN_SHUT_DOWN = true
|
||||||
is_initially_on = _is_initially_on(g)
|
is_initially_on = _is_initially_on(g)
|
||||||
|
|
||||||
# The following are the same for generator g across all time periods
|
# The following are the same for generator g across all time periods
|
||||||
SU = g.startup_limit # startup rate
|
SU = g.startup_limit # startup rate
|
||||||
SD = g.shutdown_limit # shutdown 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
|
# 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
|
# 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(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)
|
fix(switch_off[g.name, t], 0.0; force = true)
|
||||||
elseif t == 1
|
elseif t == 1
|
||||||
if is_initially_on
|
if is_initially_on
|
||||||
@@ -89,7 +93,8 @@ function _add_status_vars!(
|
|||||||
# Add explicit constraint if !FIX_VARS
|
# Add explicit constraint if !FIX_VARS
|
||||||
if g.must_run[t]
|
if g.must_run[t]
|
||||||
is_on[g.name, t] = 1.0
|
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
|
switch_off[g.name, t] = 0.0
|
||||||
elseif t == 1
|
elseif t == 1
|
||||||
if is_initially_on
|
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_startup_cost_eqs!(model, g, formulation.startup_costs)
|
||||||
_add_shutdown_cost_eqs!(model, g)
|
_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)
|
_add_status_eqs!(model, g, formulation.status_vars)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -119,7 +124,7 @@ function _add_startup_shutdown_limit_eqs!(
|
|||||||
model::JuMP.Model,
|
model::JuMP.Model,
|
||||||
g::Unit,
|
g::Unit,
|
||||||
formulation_status_vars::Gar1962.StatusVars,
|
formulation_status_vars::Gar1962.StatusVars,
|
||||||
formulation_prod_vars::Gar1962.ProdVars
|
formulation_prod_vars::Gar1962.ProdVars,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
eq_shutdown_limit = _init(model, :eq_shutdown_limit)
|
eq_shutdown_limit = _init(model, :eq_shutdown_limit)
|
||||||
eq_startup_limit = _init(model, :eq_startup_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
|
# Generator producing too much to be turned off in the first time period
|
||||||
# (can a binary variable have bounds x = 0?)
|
# (can a binary variable have bounds x = 0?)
|
||||||
if formulation_status_vars.fix_vars_via_constraint
|
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
|
else
|
||||||
fix(model[:switch_off][g.name, 1], 0.0; force = true)
|
fix(model[:switch_off][g.name, 1], 0.0; force = true)
|
||||||
end
|
end
|
||||||
@@ -265,16 +271,16 @@ function _add_min_uptime_downtime_eqs!(model::JuMP.Model, g::Unit)::Nothing
|
|||||||
# Equation (4) in Knueven et al. (2020)
|
# Equation (4) in Knueven et al. (2020)
|
||||||
eq_min_uptime[g.name, t] = @constraint(
|
eq_min_uptime[g.name, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
sum(switch_on[g.name, i] for i in (t-g.min_uptime+1):t if i >= 1)
|
sum(switch_on[g.name, i] for i in (t-g.min_uptime+1):t if i >= 1) <= is_on[g.name, t]
|
||||||
<= is_on[g.name, t]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Minimum down-time
|
# Minimum down-time
|
||||||
# Equation (5) in Knueven et al. (2020)
|
# Equation (5) in Knueven et al. (2020)
|
||||||
eq_min_downtime[g.name, t] = @constraint(
|
eq_min_downtime[g.name, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
sum(switch_off[g.name, i] for i in (t-g.min_downtime+1):t if i >= 1)
|
sum(
|
||||||
<= 1 - is_on[g.name, t]
|
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
|
# Minimum up/down-time for initial periods
|
||||||
|
|||||||
Reference in New Issue
Block a user