Formatted all the code lines

pull/27/head
Jun He 3 years ago
parent c5b3b097ab
commit 6777e5fabf

@ -172,10 +172,16 @@ function _from_json(json; repair = true)
# Read production cost curve
K = length(dict["Production cost curve (MW)"])
curve_mw = hcat(
[timeseries(dict["Production cost curve (MW)"][k]) for k in 1:K]...,
[
timeseries(dict["Production cost curve (MW)"][k]) for
k in 1:K
]...,
)
curve_cost = hcat(
[timeseries(dict["Production cost curve (\$)"][k]) for k in 1:K]...,
[
timeseries(dict["Production cost curve (\$)"][k]) for
k in 1:K
]...,
)
min_power = curve_mw[:, 1]
max_power = curve_mw[:, K]
@ -210,14 +216,18 @@ function _from_json(json; repair = true)
end
# Read and validate initial conditions
initial_power = scalar(dict["Initial power (MW)"], default = nothing)
initial_status = scalar(dict["Initial status (h)"], default = nothing)
initial_power =
scalar(dict["Initial power (MW)"], default = nothing)
initial_status =
scalar(dict["Initial status (h)"], default = nothing)
if initial_power === nothing
initial_status === nothing ||
error("unit $unit_name has initial status but no initial power")
initial_status === nothing || error(
"unit $unit_name has initial status but no initial power",
)
else
initial_status !== nothing ||
error("unit $unit_name has initial power but no initial status")
initial_status !== nothing || error(
"unit $unit_name has initial power but no initial status",
)
initial_status != 0 ||
error("unit $unit_name has invalid initial status")
if initial_status < 0 && initial_power > 1e-3
@ -234,8 +244,10 @@ function _from_json(json; repair = true)
timeseries(dict["Must run?"], default = [false for t in 1:T]),
min_power_cost,
segments,
scalar(dict["Minimum uptime (h)"], default = 1) * time_multiplier,
scalar(dict["Minimum downtime (h)"], default = 1) * time_multiplier,
scalar(dict["Minimum uptime (h)"], default = 1) *
time_multiplier,
scalar(dict["Minimum downtime (h)"], default = 1) *
time_multiplier,
scalar(dict["Ramp up limit (MW)"], default = 1e6),
scalar(dict["Ramp down limit (MW)"], default = 1e6),
scalar(dict["Startup limit (MW)"], default = 1e6),
@ -257,7 +269,7 @@ function _from_json(json; repair = true)
unit_name,
bus,
timeseries(dict["Maximum power (MW)"]),
timeseries(dict["Cost (\$/MW)"])
timeseries(dict["Cost (\$/MW)"]),
)
push!(bus.profiled_units, pu)
push!(profiled_units, pu)

@ -124,7 +124,7 @@ function _aelmp_check_parameters(
)
end
end
all_units = instance.units;
all_units = instance.units
# CHECK: model cannot handle non-fast-starts (MISO Phase I: can ONLY solve fast-starts)
if any(u -> u.min_uptime > 1 || u.min_downtime > 1, all_units)
error(
@ -132,20 +132,14 @@ function _aelmp_check_parameters(
)
end
if any(u -> u.initial_power > 0, all_units)
error(
"The initial power of all generators must be 0.",
)
error("The initial power of all generators must be 0.")
end
if any(u -> u.initial_status >= 0, all_units)
error(
"The initial status of all generators must be negative.",
)
error("The initial status of all generators must be negative.")
end
# CHECK: model does not support startup costs (in time series)
if any(u -> length(u.startup_categories) > 1, all_units)
error(
"The method does NOT support time-varying start-up costs.",
)
error("The method does NOT support time-varying start-up costs.")
end
end

@ -2,11 +2,8 @@
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details.
function _add_profiled_unit!(
model::JuMP.Model,
pu::ProfiledUnit,
)::Nothing
punits = _init(model, :profiled_units)
function _add_profiled_unit!(model::JuMP.Model, pu::ProfiledUnit)::Nothing
punits = _init(model, :prod_profiled)
net_injection = _init(model, :expr_net_injection)
for t in 1:model[:instance].time
# Decision variable

Loading…
Cancel
Save