@@ -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