Skip to content

Commit

Permalink
REF: Ensure all PMD functions' phase loops are internal
Browse files Browse the repository at this point in the history
This refactor ensures that all variable and constraint functions internal to PowerModelsDistribution, e.g. those containing `_mc_`, have any loops over the phases internal to that function, instead of requiring an explicit loop inside the problem definition.

Updates changelog

Closes #81
Closes #61
Closes #152
  • Loading branch information
pseudocubic committed Sep 5, 2019
1 parent d84ac6c commit e49279c
Show file tree
Hide file tree
Showing 13 changed files with 282 additions and 247 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ PowerModelsDistribution.jl Change Log
===================================

### staged
- Change internal variable and constraint functions to loop over phases internally (breaking) (#168)
- Fix bug in OpenDSS parser on Lines where the connected phases are listed out of order (#167)
- Add ability to "bank" single phase OpenDSS transformers into a single multiphase transformer (#166)
- Add virtual line to sourcebus to model source impedance (#165)
Expand Down
222 changes: 120 additions & 102 deletions src/core/constraint_template.jl
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
""
function constraint_mc_power_balance_slack(pm::_PMs.AbstractPowerModel, i::Int; nw::Int=pm.cnw, cnd::Int=pm.ccnd)
if !haskey(_PMs.con(pm, nw, cnd), :kcl_p)
_PMs.con(pm, nw, cnd)[:kcl_p] = Dict{Int,JuMP.ConstraintRef}()
end
if !haskey(_PMs.con(pm, nw, cnd), :kcl_q)
_PMs.con(pm, nw, cnd)[:kcl_q] = Dict{Int,JuMP.ConstraintRef}()
end
function constraint_mc_power_balance_slack(pm::_PMs.AbstractPowerModel, i::Int; nw::Int=pm.cnw)
for cnd in _PMs.conductor_ids(pm)
if !haskey(_PMs.con(pm, nw, cnd), :kcl_p)
_PMs.con(pm, nw, cnd)[:kcl_p] = Dict{Int,JuMP.ConstraintRef}()
end
if !haskey(_PMs.con(pm, nw, cnd), :kcl_q)
_PMs.con(pm, nw, cnd)[:kcl_q] = Dict{Int,JuMP.ConstraintRef}()
end

bus = _PMs.ref(pm, nw, :bus, i)
bus_arcs = _PMs.ref(pm, nw, :bus_arcs, i)
bus_arcs_dc = _PMs.ref(pm, nw, :bus_arcs_dc, i)
bus_arcs_trans = _PMs.ref(pm, nw, :bus_arcs_trans, i)
bus_gens = _PMs.ref(pm, nw, :bus_gens, i)
bus_loads = _PMs.ref(pm, nw, :bus_loads, i)
bus_shunts = _PMs.ref(pm, nw, :bus_shunts, i)
bus = _PMs.ref(pm, nw, :bus, i)
bus_arcs = _PMs.ref(pm, nw, :bus_arcs, i)
bus_arcs_dc = _PMs.ref(pm, nw, :bus_arcs_dc, i)
bus_arcs_trans = _PMs.ref(pm, nw, :bus_arcs_trans, i)
bus_gens = _PMs.ref(pm, nw, :bus_gens, i)
bus_loads = _PMs.ref(pm, nw, :bus_loads, i)
bus_shunts = _PMs.ref(pm, nw, :bus_shunts, i)

bus_pd = Dict(k => _PMs.ref(pm, nw, :load, k, "pd", cnd) for k in bus_loads)
bus_qd = Dict(k => _PMs.ref(pm, nw, :load, k, "qd", cnd) for k in bus_loads)
bus_pd = Dict(k => _PMs.ref(pm, nw, :load, k, "pd", cnd) for k in bus_loads)
bus_qd = Dict(k => _PMs.ref(pm, nw, :load, k, "qd", cnd) for k in bus_loads)

bus_gs = Dict(k => _PMs.ref(pm, nw, :shunt, k, "gs", cnd) for k in bus_shunts)
bus_bs = Dict(k => _PMs.ref(pm, nw, :shunt, k, "bs", cnd) for k in bus_shunts)
bus_gs = Dict(k => _PMs.ref(pm, nw, :shunt, k, "gs", cnd) for k in bus_shunts)
bus_bs = Dict(k => _PMs.ref(pm, nw, :shunt, k, "bs", cnd) for k in bus_shunts)

constraint_mc_power_balance_slack(pm, nw, cnd, i, bus_arcs, bus_arcs_dc, bus_arcs_trans, bus_gens, bus_pd, bus_qd, bus_gs, bus_bs)
constraint_mc_power_balance_slack(pm, nw, cnd, i, bus_arcs, bus_arcs_dc, bus_arcs_trans, bus_gens, bus_pd, bus_qd, bus_gs, bus_bs)
end
end


Expand All @@ -40,7 +42,7 @@ end


"ohms constraint for branches on the from-side"
function constraint_mc_ohms_yt_from(pm::_PMs.AbstractPowerModel, i::Int; nw::Int=pm.cnw, cnd::Int=pm.ccnd)
function constraint_mc_ohms_yt_from(pm::_PMs.AbstractPowerModel, i::Int; nw::Int=pm.cnw)
branch = _PMs.ref(pm, nw, :branch, i)
f_bus = branch["f_bus"]
t_bus = branch["t_bus"]
Expand All @@ -53,12 +55,14 @@ function constraint_mc_ohms_yt_from(pm::_PMs.AbstractPowerModel, i::Int; nw::Int
b_fr = branch["b_fr"]
tm = branch["tap"]

constraint_mc_ohms_yt_from(pm, nw, cnd, f_bus, t_bus, f_idx, t_idx, g, b, g_fr, b_fr, tr, ti, tm)
for cnd in _PMs.conductor_ids(pm)
constraint_mc_ohms_yt_from(pm, nw, cnd, f_bus, t_bus, f_idx, t_idx, g, b, g_fr, b_fr, tr, ti, tm)
end
end


"ohms constraint for branches on the to-side"
function constraint_mc_ohms_yt_to(pm::_PMs.AbstractPowerModel, i::Int; nw::Int=pm.cnw, cnd::Int=pm.ccnd)
function constraint_mc_ohms_yt_to(pm::_PMs.AbstractPowerModel, i::Int; nw::Int=pm.cnw)
branch = _PMs.ref(pm, nw, :branch, i)
f_bus = branch["f_bus"]
t_bus = branch["t_bus"]
Expand All @@ -71,12 +75,14 @@ function constraint_mc_ohms_yt_to(pm::_PMs.AbstractPowerModel, i::Int; nw::Int=p
b_to = branch["b_to"]
tm = branch["tap"]

constraint_mc_ohms_yt_to(pm, nw, cnd, f_bus, t_bus, f_idx, t_idx, g, b, g_to, b_to, tr, ti, tm)
for cnd in _PMs.conductor_ids(pm)
constraint_mc_ohms_yt_to(pm, nw, cnd, f_bus, t_bus, f_idx, t_idx, g, b, g_to, b_to, tr, ti, tm)
end
end


"on/off ohms constraint for branches on the from-side"
function constraint_mc_ohms_yt_from_on_off(pm::_PMs.AbstractPowerModel, i::Int; nw::Int=pm.cnw, cnd::Int=pm.ccnd)
function constraint_mc_ohms_yt_from_on_off(pm::_PMs.AbstractPowerModel, i::Int; nw::Int=pm.cnw)
branch = _PMs.ref(pm, nw, :branch, i)
f_bus = branch["f_bus"]
t_bus = branch["t_bus"]
Expand All @@ -92,12 +98,14 @@ function constraint_mc_ohms_yt_from_on_off(pm::_PMs.AbstractPowerModel, i::Int;
vad_min = [_PMs.ref(pm, nw, :off_angmin, c) for c in _PMs.conductor_ids(pm)]
vad_max = [_PMs.ref(pm, nw, :off_angmax, c) for c in _PMs.conductor_ids(pm)]

constraint_mc_ohms_yt_from_on_off(pm, nw, cnd, i, f_bus, t_bus, f_idx, t_idx, g, b, g_fr, b_fr, tr, ti, tm, vad_min, vad_max)
for cnd in _PMs.conductor_ids(pm)
constraint_mc_ohms_yt_from_on_off(pm, nw, cnd, i, f_bus, t_bus, f_idx, t_idx, g, b, g_fr, b_fr, tr, ti, tm, vad_min, vad_max)
end
end


"on/off ohms constraint for branches on the from-side"
function constraint_mc_ohms_yt_to_on_off(pm::_PMs.AbstractPowerModel, i::Int; nw::Int=pm.cnw, cnd::Int=pm.ccnd)
function constraint_mc_ohms_yt_to_on_off(pm::_PMs.AbstractPowerModel, i::Int; nw::Int=pm.cnw)
branch = _PMs.ref(pm, nw, :branch, i)
f_bus = branch["f_bus"]
t_bus = branch["t_bus"]
Expand All @@ -113,7 +121,9 @@ function constraint_mc_ohms_yt_to_on_off(pm::_PMs.AbstractPowerModel, i::Int; nw
vad_min = [_PMs.ref(pm, nw, :off_angmin, c) for c in _PMs.conductor_ids(pm)]
vad_max = [_PMs.ref(pm, nw, :off_angmax, c) for c in _PMs.conductor_ids(pm)]

constraint_mc_ohms_yt_to_on_off(pm, nw, cnd, i, f_bus, t_bus, f_idx, t_idx, g, b, g_to, b_to, tr, ti, tm, vad_min, vad_max)
for cnd in _PMs.conductor_ids(pm)
constraint_mc_ohms_yt_to_on_off(pm, nw, cnd, i, f_bus, t_bus, f_idx, t_idx, g, b, g_to, b_to, tr, ti, tm, vad_min, vad_max)
end
end


Expand Down Expand Up @@ -225,57 +235,61 @@ end


"KCL including transformer arcs."
function constraint_mc_power_balance(pm::_PMs.AbstractPowerModel, i::Int; nw::Int=pm.cnw, cnd::Int=pm.ccnd)
if !haskey(_PMs.con(pm, nw, cnd), :kcl_p)
_PMs.con(pm, nw, cnd)[:kcl_p] = Dict{Int,JuMP.ConstraintRef}()
end
if !haskey(_PMs.con(pm, nw, cnd), :kcl_q)
_PMs.con(pm, nw, cnd)[:kcl_q] = Dict{Int,JuMP.ConstraintRef}()
end
function constraint_mc_power_balance(pm::_PMs.AbstractPowerModel, i::Int; nw::Int=pm.cnw)
for cnd in _PMs.conductor_ids(pm)
if !haskey(_PMs.con(pm, nw, cnd), :kcl_p)
_PMs.con(pm, nw, cnd)[:kcl_p] = Dict{Int,JuMP.ConstraintRef}()
end
if !haskey(_PMs.con(pm, nw, cnd), :kcl_q)
_PMs.con(pm, nw, cnd)[:kcl_q] = Dict{Int,JuMP.ConstraintRef}()
end

bus = _PMs.ref(pm, nw, :bus, i)
bus_arcs = _PMs.ref(pm, nw, :bus_arcs, i)
bus_arcs_dc = _PMs.ref(pm, nw, :bus_arcs_dc, i)
bus_gens = _PMs.ref(pm, nw, :bus_gens, i)
bus_loads = _PMs.ref(pm, nw, :bus_loads, i)
bus_shunts = _PMs.ref(pm, nw, :bus_shunts, i)
bus_arcs_trans = _PMs.ref(pm, nw, :bus_arcs_trans, i)
bus = _PMs.ref(pm, nw, :bus, i)
bus_arcs = _PMs.ref(pm, nw, :bus_arcs, i)
bus_arcs_dc = _PMs.ref(pm, nw, :bus_arcs_dc, i)
bus_gens = _PMs.ref(pm, nw, :bus_gens, i)
bus_loads = _PMs.ref(pm, nw, :bus_loads, i)
bus_shunts = _PMs.ref(pm, nw, :bus_shunts, i)
bus_arcs_trans = _PMs.ref(pm, nw, :bus_arcs_trans, i)

bus_pd = Dict(k => _PMs.ref(pm, nw, :load, k, "pd", cnd) for k in bus_loads)
bus_qd = Dict(k => _PMs.ref(pm, nw, :load, k, "qd", cnd) for k in bus_loads)
bus_pd = Dict(k => _PMs.ref(pm, nw, :load, k, "pd", cnd) for k in bus_loads)
bus_qd = Dict(k => _PMs.ref(pm, nw, :load, k, "qd", cnd) for k in bus_loads)

bus_gs = Dict(k => _PMs.ref(pm, nw, :shunt, k, "gs", cnd) for k in bus_shunts)
bus_bs = Dict(k => _PMs.ref(pm, nw, :shunt, k, "bs", cnd) for k in bus_shunts)
bus_gs = Dict(k => _PMs.ref(pm, nw, :shunt, k, "gs", cnd) for k in bus_shunts)
bus_bs = Dict(k => _PMs.ref(pm, nw, :shunt, k, "bs", cnd) for k in bus_shunts)

constraint_mc_power_balance(pm, nw, cnd, i, bus_arcs, bus_arcs_dc, bus_arcs_trans, bus_gens, bus_pd, bus_qd, bus_gs, bus_bs)
constraint_mc_power_balance(pm, nw, cnd, i, bus_arcs, bus_arcs_dc, bus_arcs_trans, bus_gens, bus_pd, bus_qd, bus_gs, bus_bs)
end
end


"KCL including transformer arcs and storage."
function constraint_mc_power_balance_storage(pm::_PMs.AbstractPowerModel, i::Int; nw::Int=pm.cnw, cnd::Int=pm.ccnd)
if !haskey(_PMs.con(pm, nw, cnd), :kcl_p)
_PMs.con(pm, nw, cnd)[:kcl_p] = Dict{Int,JuMP.ConstraintRef}()
end
if !haskey(_PMs.con(pm, nw, cnd), :kcl_q)
_PMs.con(pm, nw, cnd)[:kcl_q] = Dict{Int,JuMP.ConstraintRef}()
end
function constraint_mc_power_balance_storage(pm::_PMs.AbstractPowerModel, i::Int; nw::Int=pm.cnw)
for cnd in _PMs.conductor_ids(pm)
if !haskey(_PMs.con(pm, nw, cnd), :kcl_p)
_PMs.con(pm, nw, cnd)[:kcl_p] = Dict{Int,JuMP.ConstraintRef}()
end
if !haskey(_PMs.con(pm, nw, cnd), :kcl_q)
_PMs.con(pm, nw, cnd)[:kcl_q] = Dict{Int,JuMP.ConstraintRef}()
end

bus = _PMs.ref(pm, nw, :bus, i)
bus_arcs = _PMs.ref(pm, nw, :bus_arcs, i)
bus_arcs_dc = _PMs.ref(pm, nw, :bus_arcs_dc, i)
bus_gens = _PMs.ref(pm, nw, :bus_gens, i)
bus_loads = _PMs.ref(pm, nw, :bus_loads, i)
bus_shunts = _PMs.ref(pm, nw, :bus_shunts, i)
bus_arcs_trans = _PMs.ref(pm, nw, :bus_arcs_trans, i)
bus_storage = _PMs.ref(pm, nw, :bus_storage, i)
bus = _PMs.ref(pm, nw, :bus, i)
bus_arcs = _PMs.ref(pm, nw, :bus_arcs, i)
bus_arcs_dc = _PMs.ref(pm, nw, :bus_arcs_dc, i)
bus_gens = _PMs.ref(pm, nw, :bus_gens, i)
bus_loads = _PMs.ref(pm, nw, :bus_loads, i)
bus_shunts = _PMs.ref(pm, nw, :bus_shunts, i)
bus_arcs_trans = _PMs.ref(pm, nw, :bus_arcs_trans, i)
bus_storage = _PMs.ref(pm, nw, :bus_storage, i)

bus_pd = Dict(k => _PMs.ref(pm, nw, :load, k, "pd", cnd) for k in bus_loads)
bus_qd = Dict(k => _PMs.ref(pm, nw, :load, k, "qd", cnd) for k in bus_loads)
bus_pd = Dict(k => _PMs.ref(pm, nw, :load, k, "pd", cnd) for k in bus_loads)
bus_qd = Dict(k => _PMs.ref(pm, nw, :load, k, "qd", cnd) for k in bus_loads)

bus_gs = Dict(k => _PMs.ref(pm, nw, :shunt, k, "gs", cnd) for k in bus_shunts)
bus_bs = Dict(k => _PMs.ref(pm, nw, :shunt, k, "bs", cnd) for k in bus_shunts)
bus_gs = Dict(k => _PMs.ref(pm, nw, :shunt, k, "gs", cnd) for k in bus_shunts)
bus_bs = Dict(k => _PMs.ref(pm, nw, :shunt, k, "bs", cnd) for k in bus_shunts)

constraint_mc_power_balance_storage(pm, nw, cnd, i, bus_arcs, bus_arcs_dc, bus_arcs_trans, bus_gens, bus_storage, bus_pd, bus_qd, bus_gs, bus_bs)
constraint_mc_power_balance_storage(pm, nw, cnd, i, bus_arcs, bus_arcs_dc, bus_arcs_trans, bus_gens, bus_storage, bus_pd, bus_qd, bus_gs, bus_bs)
end
end


Expand Down Expand Up @@ -321,26 +335,28 @@ end


"KCL including transformer arcs and load variables."
function constraint_mc_power_balance_load(pm::_PMs.AbstractPowerModel, i::Int; nw::Int=pm.cnw, cnd::Int=pm.ccnd)
if !haskey(_PMs.con(pm, nw, cnd), :kcl_p)
_PMs.con(pm, nw, cnd)[:kcl_p] = Dict{Int,JuMP.ConstraintRef}()
end
if !haskey(_PMs.con(pm, nw, cnd), :kcl_q)
_PMs.con(pm, nw, cnd)[:kcl_q] = Dict{Int,JuMP.ConstraintRef}()
end
function constraint_mc_power_balance_load(pm::_PMs.AbstractPowerModel, i::Int; nw::Int=pm.cnw)
for cnd in _PMs.conductor_ids(pm)
if !haskey(_PMs.con(pm, nw, cnd), :kcl_p)
_PMs.con(pm, nw, cnd)[:kcl_p] = Dict{Int,JuMP.ConstraintRef}()
end
if !haskey(_PMs.con(pm, nw, cnd), :kcl_q)
_PMs.con(pm, nw, cnd)[:kcl_q] = Dict{Int,JuMP.ConstraintRef}()
end

bus = _PMs.ref(pm, nw, :bus, i)
bus_arcs = _PMs.ref(pm, nw, :bus_arcs, i)
bus_arcs_dc = _PMs.ref(pm, nw, :bus_arcs_dc, i)
bus_gens = _PMs.ref(pm, nw, :bus_gens, i)
bus_loads = _PMs.ref(pm, nw, :bus_loads, i)
bus_shunts = _PMs.ref(pm, nw, :bus_shunts, i)
bus_arcs_trans = _PMs.ref(pm, nw, :bus_arcs_trans, i)
bus = _PMs.ref(pm, nw, :bus, i)
bus_arcs = _PMs.ref(pm, nw, :bus_arcs, i)
bus_arcs_dc = _PMs.ref(pm, nw, :bus_arcs_dc, i)
bus_gens = _PMs.ref(pm, nw, :bus_gens, i)
bus_loads = _PMs.ref(pm, nw, :bus_loads, i)
bus_shunts = _PMs.ref(pm, nw, :bus_shunts, i)
bus_arcs_trans = _PMs.ref(pm, nw, :bus_arcs_trans, i)

bus_gs = Dict(k => _PMs.ref(pm, nw, :shunt, k, "gs", cnd) for k in bus_shunts)
bus_bs = Dict(k => _PMs.ref(pm, nw, :shunt, k, "bs", cnd) for k in bus_shunts)
bus_gs = Dict(k => _PMs.ref(pm, nw, :shunt, k, "gs", cnd) for k in bus_shunts)
bus_bs = Dict(k => _PMs.ref(pm, nw, :shunt, k, "bs", cnd) for k in bus_shunts)

constraint_mc_power_balance_load(pm, nw, cnd, i, bus_arcs, bus_arcs_dc, bus_arcs_trans, bus_gens, bus_loads, bus_gs, bus_bs)
constraint_mc_power_balance_load(pm, nw, cnd, i, bus_arcs, bus_arcs_dc, bus_arcs_trans, bus_gens, bus_loads, bus_gs, bus_bs)
end
end


Expand Down Expand Up @@ -442,29 +458,31 @@ end


"KCL for load shed problem with transformers"
function constraint_mc_power_balance_shed(pm::_PMs.AbstractPowerModel, i::Int; nw::Int=pm.cnw, cnd::Int=pm.ccnd)
if !haskey(_PMs.con(pm, nw, cnd), :kcl_p)
_PMs.con(pm, nw, cnd)[:kcl_p] = Dict{Int,JuMP.ConstraintRef}()
end
if !haskey(_PMs.con(pm, nw, cnd), :kcl_q)
_PMs.con(pm, nw, cnd)[:kcl_q] = Dict{Int,JuMP.ConstraintRef}()
end
function constraint_mc_power_balance_shed(pm::_PMs.AbstractPowerModel, i::Int; nw::Int=pm.cnw)
for cnd in _PMs.conductor_ids(pm)
if !haskey(_PMs.con(pm, nw, cnd), :kcl_p)
_PMs.con(pm, nw, cnd)[:kcl_p] = Dict{Int,JuMP.ConstraintRef}()
end
if !haskey(_PMs.con(pm, nw, cnd), :kcl_q)
_PMs.con(pm, nw, cnd)[:kcl_q] = Dict{Int,JuMP.ConstraintRef}()
end

bus = _PMs.ref(pm, nw, :bus, i)
bus_arcs = _PMs.ref(pm, nw, :bus_arcs, i)
bus_arcs_dc = _PMs.ref(pm, nw, :bus_arcs_dc, i)
bus_arcs_trans = _PMs.ref(pm, nw, :bus_arcs_trans, i)
bus_gens = _PMs.ref(pm, nw, :bus_gens, i)
bus_loads = _PMs.ref(pm, nw, :bus_loads, i)
bus_shunts = _PMs.ref(pm, nw, :bus_shunts, i)
bus = _PMs.ref(pm, nw, :bus, i)
bus_arcs = _PMs.ref(pm, nw, :bus_arcs, i)
bus_arcs_dc = _PMs.ref(pm, nw, :bus_arcs_dc, i)
bus_arcs_trans = _PMs.ref(pm, nw, :bus_arcs_trans, i)
bus_gens = _PMs.ref(pm, nw, :bus_gens, i)
bus_loads = _PMs.ref(pm, nw, :bus_loads, i)
bus_shunts = _PMs.ref(pm, nw, :bus_shunts, i)

bus_pd = Dict(k => _PMs.ref(pm, nw, :load, k, "pd", cnd) for k in bus_loads)
bus_qd = Dict(k => _PMs.ref(pm, nw, :load, k, "qd", cnd) for k in bus_loads)
bus_pd = Dict(k => _PMs.ref(pm, nw, :load, k, "pd", cnd) for k in bus_loads)
bus_qd = Dict(k => _PMs.ref(pm, nw, :load, k, "qd", cnd) for k in bus_loads)

bus_gs = Dict(k => _PMs.ref(pm, nw, :shunt, k, "gs", cnd) for k in bus_shunts)
bus_bs = Dict(k => _PMs.ref(pm, nw, :shunt, k, "bs", cnd) for k in bus_shunts)
bus_gs = Dict(k => _PMs.ref(pm, nw, :shunt, k, "gs", cnd) for k in bus_shunts)
bus_bs = Dict(k => _PMs.ref(pm, nw, :shunt, k, "bs", cnd) for k in bus_shunts)

constraint_mc_power_balance_shed(pm, nw, cnd, i, bus_arcs, bus_arcs_dc, bus_arcs_trans, bus_gens, bus_pd, bus_qd, bus_gs, bus_bs)
constraint_mc_power_balance_shed(pm, nw, cnd, i, bus_arcs, bus_arcs_dc, bus_arcs_trans, bus_gens, bus_pd, bus_qd, bus_gs, bus_bs)
end
end


Expand Down
20 changes: 13 additions & 7 deletions src/core/variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ end

"generates variables for both `active` and `reactive` slack at each bus"
function variable_mc_bus_power_slack(pm::_PMs.AbstractPowerModel; kwargs...)
variable_mc_active_bus_power_slack(pm; kwargs...)
variable_mc_reactive_bus_power_slack(pm; kwargs...)
for cnd in _PMs.conductor_ids(pm)
variable_mc_active_bus_power_slack(pm; cnd=cnd, kwargs...)
variable_mc_reactive_bus_power_slack(pm; cnd=cnd, kwargs...)
end
end


Expand Down Expand Up @@ -211,9 +213,11 @@ Create a dictionary with values of type Any for the load.
Depending on the load model, this can be a parameter or a NLexpression.
These will be inserted into KCL.
"""
function variable_mc_load(pm::_PMs.AbstractPowerModel; nw=pm.cnw, cnd::Int=pm.ccnd, bounded=true)
_PMs.var(pm, nw, cnd)[:pd] = Dict{Int, Any}()
_PMs.var(pm, nw, cnd)[:qd] = Dict{Int, Any}()
function variable_mc_load(pm::_PMs.AbstractPowerModel; nw=pm.cnw, bounded=true)
for cnd in _PMs.conductor_ids(pm)
_PMs.var(pm, nw, cnd)[:pd] = Dict{Int, Any}()
_PMs.var(pm, nw, cnd)[:qd] = Dict{Int, Any}()
end
end


Expand Down Expand Up @@ -301,8 +305,10 @@ end

"Create variables for `active` and `reactive` storage injection"
function variable_mc_on_off_storage(pm::_PMs.AbstractPowerModel; kwargs...)
variabe_mc_on_off_storage_active(pm; kwargs...)
variable_mc_on_off_storage_reactive(pm; kwargs...)
for cnd in _PMs.conductor_ids(pm)
variabe_mc_on_off_storage_active(pm; cnd=cnd, kwargs...)
variable_mc_on_off_storage_reactive(pm; cnd=cnd, kwargs...)
end
end


Expand Down
Loading

0 comments on commit e49279c

Please sign in to comment.