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