Compare commits

...

2 Commits
web ... m2m

3 changed files with 44 additions and 30 deletions

View File

@@ -26,59 +26,67 @@ function _enforce_transmission(;
isf::Matrix{Float64}, isf::Matrix{Float64},
lodf::Matrix{Float64}, lodf::Matrix{Float64},
)::Nothing )::Nothing
instance = model[:instance]
limit::Float64 = 0.0 limit::Float64 = 0.0
overflow = model[:overflow] overflow = model[:overflow]
net_injection = model[:net_injection] net_injection = model[:net_injection]
lm = violation.monitored_line
lc = violation.outage_line
t = violation.time
eq_flow_ub = _init(model, :eq_flow_ub)
eq_flow_lb = _init(model, :eq_flow_lb)
eq_flow_def = _init(model, :eq_flow_def)
eq_idx = (
sc.name,
lm.name,
lc === nothing ? "Base" : lc.name,
t,
)
if violation.outage_line === nothing if lc === nothing
limit = violation.monitored_line.normal_flow_limit[violation.time] limit = lm.normal_flow_limit[t]
@info @sprintf( @info @sprintf(
" %8.3f MW overflow in %-5s time %3d (pre-contingency, scenario %s)", " %8.3f MW overflow in %-5s time %3d (pre-contingency, scenario %s)",
violation.amount, violation.amount,
violation.monitored_line.name, lm.name,
violation.time, t,
sc.name, sc.name,
) )
else else
limit = violation.monitored_line.emergency_flow_limit[violation.time] limit = lm.emergency_flow_limit[t]
@info @sprintf( @info @sprintf(
" %8.3f MW overflow in %-5s time %3d (outage: line %s, scenario %s)", " %8.3f MW overflow in %-5s time %3d (outage: line %s, scenario %s)",
violation.amount, violation.amount,
violation.monitored_line.name, lm.name,
violation.time, t,
violation.outage_line.name, lc.name,
sc.name, sc.name,
) )
end end
fm = violation.monitored_line.name v = overflow[sc.name, lm.name, t]
t = violation.time flow = @variable(model, base_name = "flow[$eq_idx]")
flow = @variable(model, base_name = "flow[$fm,$t]") eq_flow_ub[eq_idx] = @constraint(model, flow <= limit + v)
eq_flow_lb[eq_idx] = @constraint(model, -flow <= limit + v)
v = overflow[sc.name, violation.monitored_line.name, violation.time] if lc === nothing
@constraint(model, flow <= limit + v) eq_flow_def[eq_idx] = @constraint(
@constraint(model, -flow <= limit + v)
if violation.outage_line === nothing
@constraint(
model, model,
flow == sum( flow == sum(
net_injection[sc.name, b.name, violation.time] * net_injection[sc.name, b.name, t] *
isf[violation.monitored_line.offset, b.offset] for isf[lm.offset, b.offset] for
b in sc.buses if b.offset > 0 b in sc.buses if b.offset > 0
) )
) )
else else
@constraint( eq_flow_def[eq_idx] = @constraint(
model, model,
flow == sum( flow == sum(
net_injection[sc.name, b.name, violation.time] * ( net_injection[sc.name, b.name, t] * (
isf[violation.monitored_line.offset, b.offset] + ( isf[lm.offset, b.offset] + (
lodf[ lodf[
violation.monitored_line.offset, lm.offset,
violation.outage_line.offset, lc.offset,
] * isf[violation.outage_line.offset, b.offset] ] * isf[lc.offset, b.offset]
) )
) for b in sc.buses if b.offset > 0 ) for b in sc.buses if b.offset > 0
) )

View File

@@ -2,7 +2,9 @@
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved. # Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details. # Released under the modified BSD license. See COPYING.md for more details.
function optimize!(model::JuMP.Model, method::XavQiuWanThi2019.Method)::Nothing using DataStructures
function optimize!(model::JuMP.Model, method::XavQiuWanThi2019.Method)::Dict
if !occursin("Gurobi", JuMP.solver_name(model)) if !occursin("Gurobi", JuMP.solver_name(model))
method.two_phase_gap = false method.two_phase_gap = false
end end
@@ -22,6 +24,9 @@ function optimize!(model::JuMP.Model, method::XavQiuWanThi2019.Method)::Nothing
large_gap = true large_gap = true
end end
end end
stats = Dict(
"violations" => []
)
while true while true
time_elapsed = time() - initial_time time_elapsed = time() - initial_time
time_remaining = method.time_limit - time_elapsed time_remaining = method.time_limit - time_elapsed
@@ -68,6 +73,7 @@ function optimize!(model::JuMP.Model, method::XavQiuWanThi2019.Method)::Nothing
if violations_found if violations_found
for (i, v) in enumerate(violations) for (i, v) in enumerate(violations)
append!(stats["violations"], v)
_enforce_transmission(model, v, model[:instance].scenarios[i]) _enforce_transmission(model, v, model[:instance].scenarios[i])
end end
else else
@@ -80,5 +86,5 @@ function optimize!(model::JuMP.Model, method::XavQiuWanThi2019.Method)::Nothing
end end
end end
end end
return return stats
end end

View File

@@ -3,12 +3,12 @@
# Released under the modified BSD license. See COPYING.md for more details. # Released under the modified BSD license. See COPYING.md for more details.
""" """
optimize!(model::JuMP.Model)::Nothing optimize!(model::JuMP.Model)::Dict
Solve the given unit commitment model. Unlike `JuMP.optimize!`, this uses more Solve the given unit commitment model. Unlike `JuMP.optimize!`, this uses more
advanced methods to accelerate the solution process and to enforce transmission advanced methods to accelerate the solution process and to enforce transmission
and N-1 security constraints. and N-1 security constraints.
""" """
function optimize!(model::JuMP.Model)::Nothing function optimize!(model::JuMP.Model)::Dict
return UnitCommitment.optimize!(model, XavQiuWanThi2019.Method()) return UnitCommitment.optimize!(model, XavQiuWanThi2019.Method())
end end