Skip to content

Commit

Permalink
feat: enable differential pmin/pmax for DC lines
Browse files Browse the repository at this point in the history
  • Loading branch information
danielolsen committed Dec 11, 2020
1 parent fd0192d commit 5858281
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
24 changes: 14 additions & 10 deletions src/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ function _make_sets(case::Case, storage::Union{Storage,Nothing})::Sets
# Positional indices from mpc.gencost
MODEL = 1
NCOST = 4
# Buses
# Sets - Buses
num_bus = length(case.busid)
bus_idx = 1:num_bus
bus_id2idx = Dict(case.busid .=> bus_idx)
load_bus_idx = findall(case.bus_demand .> 0)
num_load_bus = length(load_bus_idx)
# Sets - branches
branch_rating = vcat(case.branch_rating, case.dcline_rating)
branch_rating[branch_rating .== 0] .= Inf
ac_branch_rating = replace(case.branch_rating, 0=>Inf)
branch_rating = vcat(ac_branch_rating, case.dcline_pmax)
num_branch_ac = length(case.branchid)
num_branch = num_branch_ac + length(case.dclineid)
branch_idx = 1:num_branch
Expand Down Expand Up @@ -196,7 +196,8 @@ function _build_model(m::JuMP.Model; case::Case, storage::Storage,
segment_slope = _build_segment_slope(case, sets.segment_idx, segment_width)
# Branch connectivity matrix
branch_map = _make_branch_map(case)
branch_rating = vcat(case.branch_rating, case.dcline_rating)
branch_pmin = vcat(-1 * case.branch_rating, case.dcline_pmin)
branch_pmax = vcat(case.branch_rating, case.dcline_pmax)
# Demand by bus
bus_demand = _make_bus_demand(case, start_index, end_index)
bus_demand *= demand_scaling
Expand Down Expand Up @@ -321,21 +322,24 @@ function _build_model(m::JuMP.Model; case::Case, storage::Storage,
pg[i, h] == case.gen_pmin[i] + sum(pg_seg[i, :, h]))

if trans_viol_enabled
JuMP.@expression(m,
branch_limit, branch_rating + trans_viol)
JuMP.@expression(m, branch_limit_pmin, branch_pmin - trans_viol)
JuMP.@expression(m, branch_limit_pmax, branch_pmax + trans_viol)
else
JuMP.@expression(m,
branch_limit[br in sets.branch_idx, h in hour_idx],
branch_rating[br])
branch_limit_pmin[br in sets.branch_idx, h in hour_idx],
branch_pmin[br])
JuMP.@expression(m,
branch_limit_pmax[br in sets.branch_idx, h in hour_idx],
branch_pmax[br])
end
println("branch_min, branch_max: ", Dates.now())
JuMP.@constraint(m,
branch_min[br in sets.noninf_branch_idx, h in hour_idx],
-1 * branch_limit[br, h] <= pf[br, h])
branch_limit_pmin[br, h] <= pf[br, h])
println("branch_max: ", Dates.now())
JuMP.@constraint(m,
branch_max[br in sets.noninf_branch_idx, h in hour_idx],
pf[br, h] <= branch_limit[br, h])
pf[br, h] <= branch_limit_pmax[br, h])

println("branch_angle: ", Dates.now())
# Explicit numbering here so that we constrain AC branches but not DC
Expand Down
6 changes: 4 additions & 2 deletions src/read.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ function read_case(filepath)
end
case["dcline_from"] = convert(Array{Int,1}, mpc["dcline"][:,1])
case["dcline_to"] = convert(Array{Int,1}, mpc["dcline"][:,2])
case["dcline_rating"] = mpc["dcline"][:,11]
case["dcline_pmin"] = mpc["dcline"][:,10]
case["dcline_pmax"] = mpc["dcline"][:,11]
else
case["dclineid"] = Int64[]
case["dcline_from"] = Int64[]
case["dcline_to"] = Int64[]
case["dcline_rating"] = Float64[]
case["dcline_pmin"] = Float64[]
case["dcline_pmax"] = Float64[]
end

# Buses
Expand Down
3 changes: 2 additions & 1 deletion src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Base.@kwdef struct Case
dclineid::Array{Int64,1}
dcline_from::Array{Int64,1}
dcline_to::Array{Int64,1}
dcline_rating::Array{Float64,1}
dcline_pmin::Array{Float64,1}
dcline_pmax::Array{Float64,1}

busid::Array{Int64,1}
bus_demand::Array{Float64,1}
Expand Down

0 comments on commit 5858281

Please sign in to comment.