mirror of
https://github.com/ANL-CEEESA/UnitCommitment.jl.git
synced 2025-12-06 16:28:51 -06:00
Make papers into modules, instead of structs; add StartupCostsFormulation
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
function _add_ramp_eqs!(
|
||||
model::JuMP.Model,
|
||||
g::Unit,
|
||||
formulation::ArrCon2000,
|
||||
formulation::ArrCon2000.Ramping,
|
||||
)::Nothing
|
||||
# TODO: Move upper case constants to model[:instance]
|
||||
RESERVES_WHEN_START_UP = true
|
||||
|
||||
@@ -9,4 +9,10 @@ Formulation described in:
|
||||
to an electricity spot market. IEEE Transactions on power systems, 15(3),
|
||||
1098-1104.
|
||||
"""
|
||||
struct ArrCon2000 <: RampingFormulation end
|
||||
module ArrCon2000
|
||||
|
||||
import ..RampingFormulation
|
||||
|
||||
struct Ramping <: RampingFormulation end
|
||||
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
function _add_production_piecewise_linear_eqs!(
|
||||
model::JuMP.Model,
|
||||
g::Unit,
|
||||
formulation::CarArr2006,
|
||||
formulation::CarArr2006.PwlCosts,
|
||||
)::Nothing
|
||||
eq_prod_above_def = _init(model, :eq_prod_above_def)
|
||||
eq_segprod_limit = _init(model, :eq_segprod_limit)
|
||||
|
||||
@@ -9,4 +9,10 @@ Formulation described in:
|
||||
mixed-integer linear formulation for the thermal unit commitment problem.
|
||||
IEEE Transactions on power systems, 21(3), 1371-1378.
|
||||
"""
|
||||
struct CarArr2006 <: PiecewiseLinearCostsFormulation end
|
||||
module CarArr2006
|
||||
|
||||
import ..PiecewiseLinearCostsFormulation
|
||||
|
||||
struct PwlCosts <: PiecewiseLinearCostsFormulation end
|
||||
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
function _add_ramp_eqs!(
|
||||
model::JuMP.Model,
|
||||
g::Unit,
|
||||
formulation::DamKucRajAta2016,
|
||||
formulation::DamKucRajAta2016.Ramping,
|
||||
)::Nothing
|
||||
# TODO: Move upper case constants to model[:instance]
|
||||
RESERVES_WHEN_START_UP = true
|
||||
|
||||
@@ -8,4 +8,10 @@ Formulation described in:
|
||||
Damcı-Kurt, P., Küçükyavuz, S., Rajan, D., & Atamtürk, A. (2016). A polyhedral
|
||||
study of production ramping. Mathematical Programming, 158(1), 175-205.
|
||||
"""
|
||||
struct DamKucRajAta2016 <: RampingFormulation end
|
||||
module DamKucRajAta2016
|
||||
|
||||
import ..RampingFormulation
|
||||
|
||||
struct Ramping <: RampingFormulation end
|
||||
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
function _add_production_piecewise_linear_eqs!(
|
||||
model::JuMP.Model,
|
||||
g::Unit,
|
||||
formulation::Gar1962,
|
||||
formulation::Gar1962.PwlCosts,
|
||||
)::Nothing
|
||||
eq_prod_above_def = _init(model, :eq_prod_above_def)
|
||||
eq_segprod_limit = _init(model, :eq_segprod_limit)
|
||||
|
||||
@@ -10,4 +10,10 @@ Formulation described in:
|
||||
of Electrical Engineers. Part III: Power Apparatus and Systems, 81(3), 730-734.
|
||||
|
||||
"""
|
||||
struct Gar1962 <: PiecewiseLinearCostsFormulation end
|
||||
module Gar1962
|
||||
|
||||
import ..PiecewiseLinearCostsFormulation
|
||||
|
||||
struct PwlCosts <: PiecewiseLinearCostsFormulation end
|
||||
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
function _add_production_piecewise_linear_eqs!(
|
||||
model::JuMP.Model,
|
||||
g::Unit,
|
||||
formulation::KnuOstWat2018,
|
||||
formulation::KnuOstWat2018.PwlCosts,
|
||||
)::Nothing
|
||||
eq_prod_above_def = _init(model, :eq_prod_above_def)
|
||||
eq_segprod_limit_a = _init(model, :eq_segprod_limit_a)
|
||||
|
||||
@@ -9,4 +9,10 @@ Formulation described in:
|
||||
generators in unit commitment. IEEE Transactions on Power Systems, 33(4),
|
||||
4496-4507.
|
||||
"""
|
||||
struct KnuOstWat2018 <: PiecewiseLinearCostsFormulation end
|
||||
module KnuOstWat2018
|
||||
|
||||
import ..PiecewiseLinearCostsFormulation
|
||||
|
||||
struct PwlCosts <: PiecewiseLinearCostsFormulation end
|
||||
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
function _add_ramp_eqs!(
|
||||
model::JuMP.Model,
|
||||
g::Unit,
|
||||
formulation::MorLatRam2013,
|
||||
formulation::MorLatRam2013.Ramping,
|
||||
)::Nothing
|
||||
# TODO: Move upper case constants to model[:instance]
|
||||
RESERVES_WHEN_START_UP = true
|
||||
|
||||
50
src/model/formulations/MorLatRam2013/scosts.jl
Normal file
50
src/model/formulations/MorLatRam2013/scosts.jl
Normal file
@@ -0,0 +1,50 @@
|
||||
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||
# Released under the modified BSD license. See COPYING.md for more details.
|
||||
|
||||
function _add_startup_cost_eqs!(
|
||||
model::JuMP.Model,
|
||||
g::Unit,
|
||||
formulation::MorLatRam2013.StartupCosts,
|
||||
)::Nothing
|
||||
eq_startup_choose = _init(model, :eq_startup_choose)
|
||||
eq_startup_restrict = _init(model, :eq_startup_restrict)
|
||||
S = length(g.startup_categories)
|
||||
startup = model[:startup]
|
||||
for t in 1:model[:instance].time
|
||||
for s in 1:S
|
||||
# If unit is switching on, we must choose a startup category
|
||||
eq_startup_choose[g.name, t, s] = @constraint(
|
||||
model,
|
||||
model[:switch_on][g.name, t] ==
|
||||
sum(startup[g.name, t, s] for s in 1:S)
|
||||
)
|
||||
|
||||
# If unit has not switched off in the last `delay` time periods, startup category is forbidden.
|
||||
# The last startup category is always allowed.
|
||||
if s < S
|
||||
range_start = t - g.startup_categories[s+1].delay + 1
|
||||
range_end = t - g.startup_categories[s].delay
|
||||
range = (range_start:range_end)
|
||||
initial_sum = (
|
||||
g.initial_status < 0 && (g.initial_status + 1 in range) ? 1.0 : 0.0
|
||||
)
|
||||
eq_startup_restrict[g.name, t, s] = @constraint(
|
||||
model,
|
||||
startup[g.name, t, s] <=
|
||||
initial_sum + sum(
|
||||
model[:switch_off][g.name, i] for i in range if i >= 1
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
# Objective function terms for start-up costs
|
||||
add_to_expression!(
|
||||
model[:obj],
|
||||
startup[g.name, t, s],
|
||||
g.startup_categories[s].cost,
|
||||
)
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
@@ -9,4 +9,12 @@ Formulation described in:
|
||||
MILP formulation for the thermal unit commitment problem. IEEE Transactions
|
||||
on Power Systems, 28(4), 4897-4908.
|
||||
"""
|
||||
struct MorLatRam2013 <: RampingFormulation end
|
||||
module MorLatRam2013
|
||||
|
||||
import ..RampingFormulation
|
||||
import ..StartupCostsFormulation
|
||||
|
||||
struct Ramping <: RampingFormulation end
|
||||
struct StartupCosts <: StartupCostsFormulation end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
function _add_ramp_eqs!(
|
||||
model::JuMP.Model,
|
||||
g::Unit,
|
||||
formulation::PanGua2016,
|
||||
formulation::PanGua2016.Ramping,
|
||||
)::Nothing
|
||||
# TODO: Move upper case constants to model[:instance]
|
||||
RESERVES_WHEN_SHUT_DOWN = true
|
||||
|
||||
@@ -8,4 +8,10 @@ Formulation described in:
|
||||
Pan, K., & Guan, Y. (2016). Strong formulations for multistage stochastic
|
||||
self-scheduling unit commitment. Operations Research, 64(6), 1482-1498.
|
||||
"""
|
||||
struct PanGua2016 <: RampingFormulation end
|
||||
module PanGua2016
|
||||
|
||||
import ..RampingFormulation
|
||||
|
||||
struct Ramping <: RampingFormulation end
|
||||
|
||||
end
|
||||
|
||||
@@ -5,18 +5,21 @@
|
||||
abstract type TransmissionFormulation end
|
||||
abstract type RampingFormulation end
|
||||
abstract type PiecewiseLinearCostsFormulation end
|
||||
abstract type StartupCostsFormulation end
|
||||
|
||||
struct Formulation
|
||||
pwl_costs::PiecewiseLinearCostsFormulation
|
||||
ramping::RampingFormulation
|
||||
startup_costs::StartupCostsFormulation
|
||||
transmission::TransmissionFormulation
|
||||
|
||||
function Formulation(;
|
||||
pwl_costs::PiecewiseLinearCostsFormulation = Gar1962(),
|
||||
ramping::RampingFormulation = MorLatRam2013(),
|
||||
pwl_costs::PiecewiseLinearCostsFormulation = Gar1962.PwlCosts(),
|
||||
ramping::RampingFormulation = MorLatRam2013.Ramping(),
|
||||
startup_costs::StartupCostsFormulation = MorLatRam2013.StartupCosts(),
|
||||
transmission::TransmissionFormulation = ShiftFactorsFormulation(),
|
||||
)
|
||||
return new(pwl_costs, ramping, transmission)
|
||||
return new(pwl_costs, ramping, startup_costs, transmission)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ function _add_unit!(model::JuMP.Model, g::Unit, f::Formulation)
|
||||
_add_production_limit_eqs!(model, g)
|
||||
_add_production_piecewise_linear_eqs!(model, g, f.pwl_costs)
|
||||
_add_ramp_eqs!(model, g, f.ramping)
|
||||
_add_startup_shutdown_costs_eqs!(model, g)
|
||||
_add_startup_cost_eqs!(model, g, f.startup_costs)
|
||||
_add_startup_shutdown_limit_eqs!(model, g)
|
||||
_add_status_eqs!(model, g)
|
||||
return
|
||||
@@ -134,49 +134,6 @@ function _add_startup_shutdown_limit_eqs!(model::JuMP.Model, g::Unit)::Nothing
|
||||
return
|
||||
end
|
||||
|
||||
function _add_startup_shutdown_costs_eqs!(model::JuMP.Model, g::Unit)::Nothing
|
||||
eq_startup_choose = _init(model, :eq_startup_choose)
|
||||
eq_startup_restrict = _init(model, :eq_startup_restrict)
|
||||
S = length(g.startup_categories)
|
||||
startup = model[:startup]
|
||||
for t in 1:model[:instance].time
|
||||
for s in 1:S
|
||||
# If unit is switching on, we must choose a startup category
|
||||
eq_startup_choose[g.name, t, s] = @constraint(
|
||||
model,
|
||||
model[:switch_on][g.name, t] ==
|
||||
sum(startup[g.name, t, s] for s in 1:S)
|
||||
)
|
||||
|
||||
# If unit has not switched off in the last `delay` time periods, startup category is forbidden.
|
||||
# The last startup category is always allowed.
|
||||
if s < S
|
||||
range_start = t - g.startup_categories[s+1].delay + 1
|
||||
range_end = t - g.startup_categories[s].delay
|
||||
range = (range_start:range_end)
|
||||
initial_sum = (
|
||||
g.initial_status < 0 && (g.initial_status + 1 in range) ? 1.0 : 0.0
|
||||
)
|
||||
eq_startup_restrict[g.name, t, s] = @constraint(
|
||||
model,
|
||||
startup[g.name, t, s] <=
|
||||
initial_sum + sum(
|
||||
model[:switch_off][g.name, i] for i in range if i >= 1
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
# Objective function terms for start-up costs
|
||||
add_to_expression!(
|
||||
model[:obj],
|
||||
startup[g.name, t, s],
|
||||
g.startup_categories[s].cost,
|
||||
)
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
function _add_status_vars!(model::JuMP.Model, g::Unit)::Nothing
|
||||
is_on = _init(model, :is_on)
|
||||
switch_on = _init(model, :switch_on)
|
||||
|
||||
Reference in New Issue
Block a user