Parse new reserves

This commit is contained in:
2022-01-19 10:03:22 -06:00
parent 2bd68b49a5
commit ca0d250dfa
5 changed files with 42 additions and 0 deletions

View File

@@ -66,6 +66,7 @@ function _from_json(json; repair = true)
contingencies = Contingency[]
lines = TransmissionLine[]
loads = PriceSensitiveLoad[]
reserves2 = Reserve[]
function scalar(x; default = nothing)
x !== nothing || return default
@@ -86,6 +87,7 @@ function _from_json(json; repair = true)
name_to_bus = Dict{String,Bus}()
name_to_line = Dict{String,TransmissionLine}()
name_to_unit = Dict{String,Unit}()
name_to_reserve = Dict{String,Reserve}()
function timeseries(x; default = nothing)
x !== nothing || return default
@@ -116,6 +118,19 @@ function _from_json(json; repair = true)
push!(buses, bus)
end
# Read reserves
if "Reserves2" in keys(json)
for (reserve_name, dict) in json["Reserves2"]
reserve = Reserve(
name = reserve_name,
type = lowercase(dict["Type"]),
amount = timeseries(dict["Amount (MW)"]),
)
name_to_reserve[reserve_name] = reserve
push!(reserves2, reserve)
end
end
# Read units
for (unit_name, dict) in json["Generators"]
bus = name_to_bus[dict["Bus"]]
@@ -153,6 +168,12 @@ function _from_json(json; repair = true)
)
end
# Read reserves
unit_reserves = Reserve[]
if "Reserve eligibility" in keys(dict)
unit_reserves = [name_to_reserve[n] for n in dict["Reserve eligibility"]]
end
# Read and validate initial conditions
initial_power = scalar(dict["Initial power (MW)"], default = nothing)
initial_status = scalar(dict["Initial status (h)"], default = nothing)
@@ -191,6 +212,7 @@ function _from_json(json; repair = true)
default = [true for t in 1:T],
),
startup_categories,
unit_reserves,
)
push!(bus.units, unit)
name_to_unit[unit_name] = unit
@@ -276,6 +298,8 @@ function _from_json(json; repair = true)
price_sensitive_loads_by_name = Dict(ps.name => ps for ps in loads),
price_sensitive_loads = loads,
reserves = reserves,
reserves2 = reserves2,
reserves_by_name = name_to_reserve,
shortfall_penalty = shortfall_penalty,
time = T,
units_by_name = Dict(g.name => g for g in units),

View File

@@ -20,6 +20,12 @@ mutable struct StartupCategory
cost::Float64
end
Base.@kwdef mutable struct Reserve
name::String
type::String
amount::Vector{Float64}
end
mutable struct Unit
name::String
bus::Bus
@@ -38,6 +44,7 @@ mutable struct Unit
initial_power::Union{Float64,Nothing}
provides_spinning_reserves::Vector{Bool}
startup_categories::Vector{StartupCategory}
reserves::Vector{Reserve}
end
mutable struct TransmissionLine
@@ -80,6 +87,8 @@ Base.@kwdef mutable struct UnitCommitmentInstance
price_sensitive_loads_by_name::Dict{AbstractString,PriceSensitiveLoad}
price_sensitive_loads::Vector{PriceSensitiveLoad}
reserves::Reserves
reserves2::Vector{Reserve}
reserves_by_name::Dict{AbstractString,Reserve}
shortfall_penalty::Vector{Float64}
time::Int
units_by_name::Dict{AbstractString,Unit}