Skip to content

Commit 606b67b

Browse files
Small improvements & comments
1 parent bf350e8 commit 606b67b

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

src/opf/sdpwrm.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ function build_opf(::Type{SDPOPF}, data::OPFData, optimizer;
6464
set_upper_bound.([WR[i, i] for i in 1:N], vmax.^2)
6565

6666
# Voltage product bounds
67-
# Only apply bounds on (i, j) entries and not (j, i)
67+
# Only apply bounds on (i, j) entries and not (j, i).
6868
# If a bus pair has parallel branches, `set_lower_bound` and `set_upper_bound` are called
6969
# with the same bounds for multiple times (calls subsequent to the first are no-op).
70+
# Currently, these variables are not fixed to 0 when all branches between the bus pair are off.
7071
set_lower_bound.([WR[i,j] for (i, j) in zip(bus_fr, bus_to)], wr_min)
7172
set_upper_bound.([WR[i,j] for (i, j) in zip(bus_fr, bus_to)], wr_max)
7273
set_lower_bound.([WI[i,j] for (i, j) in zip(bus_fr, bus_to)], wi_min)

src/opf/sparse_sdpwrm.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,14 @@ function build_opf(::Type{SparseSDPOPF}, data::OPFData, optimizer;
8585
offdiag_indices = [(i, j) for i in 1:n, j in 1:n if i != j]
8686
for (i, j) in offdiag_indices
8787
i_bus, j_bus = group[i], group[j]
88+
# `e` is only for indexing the computed bounds values
89+
e = findfirst(e -> bus_fr[e] == i_bus && bus_to[e] == j_bus, 1:E)
8890
# if (i_bus, j_bus) is a valid directed bus pair in the system
89-
if (i_bus, j_bus) in zip(bus_fr, bus_to)
90-
# `e`` is only for indexing the computed bounds values
91-
e = findfirst(i -> bus_fr[i] == i_bus && bus_to[i] == j_bus, 1:E)
92-
# Only apply bounds on (i, j) entries and not (j, i)
91+
if !isnothing(e)
92+
# Only apply bounds on (i, j) entries and not (j, i).
93+
# Currently, these variables are not fixed to 0 when all branches between the bus pair are off.
9394
# The outer loop over the cliques will apply bounds to all variables linked to the directed
94-
# bus pair (i_bus, j_bus)
95+
# bus pair (i_bus, j_bus).
9596
set_upper_bound(WR_g[i, j], wr_max[e])
9697
set_lower_bound(WR_g[i, j], wr_min[e])
9798
set_upper_bound(WI_g[i, j], wi_max[e])
@@ -349,8 +350,8 @@ function extract_dual(opf::OPFModel{SparseSDPOPF})
349350
i_bus, j_bus = group[i], group[j]
350351
# If there are multiple branches from bus i to j, the same (i, j) entries of S, μ_WR and μ_WI are
351352
# extracted for each of the branches.
352-
e_idx = findall(i -> bus_fr[i] == i_bus && bus_to[i] == j_bus, 1:E)
353-
for e in e_idx
353+
es = findall(e -> bus_fr[e] == i_bus && bus_to[e] == j_bus, 1:E)
354+
for e in es
354355
# Mean of S_g[1,1] and S_g[2,2] blocks
355356
dual_solution["sr"][e] += (S_g[i, j] + S_g[i + n, j + n]) / 2
356357
# Mean of upper triangle and lower triangle of S_g[1,2] block

0 commit comments

Comments
 (0)