Power Balance reference in PowerModels.jl

I’m running an OPF problem with SDPWRMForm and SOCWRConicForm formulations (AbstractWForms) and I’m trying to retrieve the duals from the power balance constraints (lam_kcl_r in the output). However, it seams that the reference to those constraints (kcl_p) is not stored as it is in the DCPlosslessForm (in the “con” dictionary).

Could the solution be to change the power balance constraint in “shared form” to:

function constraint_power_balance_shunt(pm::GenericPowerModel{T}, n::Int, c::Int, i, bus_arcs, bus_arcs_dc, bus_gens, bus_pd, bus_qd, bus_gs, bus_bs) where T <: AbstractWForms
    w    = var(pm, n, c, :w, i)
    pg   = var(pm, n, c, :pg)
    qg   = var(pm, n, c, :qg)
    p    = var(pm, n, c, :p)
    q    = var(pm, n, c, :q)
    p_dc = var(pm, n, c, :p_dc)
    q_dc = var(pm, n, c, :q_dc)

    con(pm, n, c, :kcl_p)[i] = JuMP.@constraint(pm.model, sum(p[a] for a in bus_arcs) + sum(p_dc[a_dc] for a_dc in bus_arcs_dc) == sum(pg[g] for g in bus_gens) - sum(pd for pd in values(bus_pd)) - sum(gs for gs in values(bus_gs))*w)
    con(pm, n, c, :kcl_q)[i] = JuMP.@constraint(pm.model, sum(q[a] for a in bus_arcs) + sum(q_dc[a_dc] for a_dc in bus_arcs_dc) == sum(qg[g] for g in bus_gens) - sum(qd for qd in values(bus_qd)) + sum(bs for bs in values(bus_bs))*w)
end

Thus far I have not tested extracting duals from the SOC or SDP models, so it would not surprise me if there are bugs there. If you find one, feel free to post an issue in the PowerModels repo.

Your suggestion appears to be correct in this case, you need to add con(pm, n, c, :kcl_p)[i]=... and con(pm, n, c, :kcl_q)[i]=... to the W-space constraint_power_balance_shunt constraint.

1 Like

Thanks @ccoffrin! I will fork the repo to test the idea and, if it works, I will create the PR.

This should be fixed as of PowerModels v0.12.5. Let me know if you still have any issue.

1 Like

The issue seams to be resolved. At least in my case! Thanks again @ccoffrin!

Glad to hear it @andrewrosemberg!

1 Like