diff --git a/CHANGELOG.md b/CHANGELOG.md index 032596da..8c239591 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ PowerModels.jl Change Log ========================= ### Staged -- nothing +- Fix `sol_component_value_edge` implementation and usage (#811) ### v0.19.3 - Add support for JuMP v0.23 diff --git a/Project.toml b/Project.toml index f11b7d83..eb5f938b 100644 --- a/Project.toml +++ b/Project.toml @@ -22,7 +22,7 @@ JuMP = "~0.22, ~0.23" Juniper = "~0.8, ~0.9" Memento = "~1.0, ~1.1, ~1.2, ~1.3" NLsolve = "4.0" -SCS = "~0.9, ~1" +SCS = "~0.9, ~1.0" julia = "1.6" [extras] diff --git a/src/core/solution.jl b/src/core/solution.jl index b9497125..89d71713 100644 --- a/src/core/solution.jl +++ b/src/core/solution.jl @@ -32,5 +32,5 @@ end "PowerModels wrapper for the InfrastructureModels `sol_component_value_edge` function." function sol_component_value_edge(aim::AbstractPowerModel, n::Int, comp_name::Symbol, field_name_fr::Symbol, field_name_to::Symbol, comp_ids_fr, comp_ids_to, variables) - return _IM.sol_component_value(aim, pm_it_sym, n, comp_name, field_name_fr, field_name_to, comp_ids_fr, comp_ids_to, variables) + return _IM.sol_component_value_edge(aim, pm_it_sym, n, comp_name, field_name_fr, field_name_to, comp_ids_fr, comp_ids_to, variables) end \ No newline at end of file diff --git a/src/core/variable.jl b/src/core/variable.jl index 9f06e447..f5079710 100644 --- a/src/core/variable.jl +++ b/src/core/variable.jl @@ -435,7 +435,7 @@ function variable_branch_power_real(pm::AbstractPowerModel; nw::Int=nw_id_defaul end end - report && _IM.sol_component_value_edge(pm, pm_it_sym, nw, :branch, :pf, :pt, ref(pm, nw, :arcs_from), ref(pm, nw, :arcs_to), p) + report && sol_component_value_edge(pm, nw, :branch, :pf, :pt, ref(pm, nw, :arcs_from), ref(pm, nw, :arcs_to), p) end "variable: `q[l,i,j]` for `(l,i,j)` in `arcs`" @@ -470,7 +470,7 @@ function variable_branch_power_imaginary(pm::AbstractPowerModel; nw::Int=nw_id_d end end - report && _IM.sol_component_value_edge(pm, pm_it_sym, nw, :branch, :qf, :qt, ref(pm, nw, :arcs_from), ref(pm, nw, :arcs_to), q) + report && sol_component_value_edge(pm, nw, :branch, :qf, :qt, ref(pm, nw, :arcs_from), ref(pm, nw, :arcs_to), q) end function variable_branch_transform(pm::AbstractPolarModels; kwargs...) @@ -546,7 +546,7 @@ function variable_branch_current_real(pm::AbstractPowerModel; nw::Int=nw_id_defa end end - report && _IM.sol_component_value_edge(pm, pm_it_sym, nw, :branch, :cr_fr, :cr_to, ref(pm, nw, :arcs_from), ref(pm, nw, :arcs_to), cr) + report && sol_component_value_edge(pm, nw, :branch, :cr_fr, :cr_to, ref(pm, nw, :arcs_from), ref(pm, nw, :arcs_to), cr) end @@ -583,7 +583,7 @@ function variable_branch_current_imaginary(pm::AbstractPowerModel; nw::Int=nw_id end end - report && _IM.sol_component_value_edge(pm, pm_it_sym, nw, :branch, :ci_fr, :ci_to, ref(pm, nw, :arcs_from), ref(pm, nw, :arcs_to), ci) + report && sol_component_value_edge(pm, nw, :branch, :ci_fr, :ci_to, ref(pm, nw, :arcs_from), ref(pm, nw, :arcs_to), ci) end @@ -704,7 +704,7 @@ function variable_dcline_power_real(pm::AbstractPowerModel; nw::Int=nw_id_defaul end end - report && _IM.sol_component_value_edge(pm, pm_it_sym, nw, :dcline, :pf, :pt, ref(pm, nw, :arcs_from_dc), ref(pm, nw, :arcs_to_dc), p_dc) + report && sol_component_value_edge(pm, nw, :dcline, :pf, :pt, ref(pm, nw, :arcs_from_dc), ref(pm, nw, :arcs_to_dc), p_dc) end "variable: `q_dc[l,i,j]` for `(l,i,j)` in `arcs_dc`" @@ -738,7 +738,7 @@ function variable_dcline_power_imaginary(pm::AbstractPowerModel; nw::Int=nw_id_d end end - report && _IM.sol_component_value_edge(pm, pm_it_sym, nw, :dcline, :qf, :qt, ref(pm, nw, :arcs_from_dc), ref(pm, nw, :arcs_to_dc), q_dc) + report && sol_component_value_edge(pm, nw, :dcline, :qf, :qt, ref(pm, nw, :arcs_from_dc), ref(pm, nw, :arcs_to_dc), q_dc) end "variable: `crdc[j]` for `j` in `dcline`" @@ -768,7 +768,7 @@ function variable_dcline_current_real(pm::AbstractPowerModel; nw::Int=nw_id_defa end end - report && _IM.sol_component_value_edge(pm, pm_it_sym, nw, :dcline, :crdc_fr, :crdc_to, ref(pm, nw, :arcs_from_dc), ref(pm, nw, :arcs_to_dc), crdc) + report && sol_component_value_edge(pm, nw, :dcline, :crdc_fr, :crdc_to, ref(pm, nw, :arcs_from_dc), ref(pm, nw, :arcs_to_dc), crdc) end "variable: `cidc[j]` for `j` in `dcline`" @@ -798,7 +798,7 @@ function variable_dcline_current_imaginary(pm::AbstractPowerModel; nw::Int=nw_id end end - report && _IM.sol_component_value_edge(pm, pm_it_sym, nw, :dcline, :cidc_fr, :cidc_to, ref(pm, nw, :arcs_from_dc), ref(pm, nw, :arcs_to_dc), cidc) + report && sol_component_value_edge(pm, nw, :dcline, :cidc_fr, :cidc_to, ref(pm, nw, :arcs_from_dc), ref(pm, nw, :arcs_to_dc), cidc) end @@ -856,7 +856,7 @@ function variable_switch_power_real(pm::AbstractPowerModel; nw::Int=nw_id_defaul psw_expr = merge(psw_expr, Dict( (l,j,i) => -1.0*psw[(l,i,j)] for (l,i,j) in ref(pm, nw, :arcs_from_sw))) var(pm, nw)[:psw] = psw_expr - report && _IM.sol_component_value_edge(pm, pm_it_sym, nw, :switch, :psw_fr, :psw_to, ref(pm, nw, :arcs_from_sw), ref(pm, nw, :arcs_to_sw), psw_expr) + report && sol_component_value_edge(pm, nw, :switch, :psw_fr, :psw_to, ref(pm, nw, :arcs_from_sw), ref(pm, nw, :arcs_to_sw), psw_expr) end @@ -886,7 +886,7 @@ function variable_switch_power_imaginary(pm::AbstractPowerModel; nw::Int=nw_id_d qsw_expr = merge(qsw_expr, Dict( (l,j,i) => -1.0*qsw[(l,i,j)] for (l,i,j) in ref(pm, nw, :arcs_from_sw))) var(pm, nw)[:qsw] = qsw_expr - report && _IM.sol_component_value_edge(pm, pm_it_sym, nw, :switch, :qsw_fr, :qsw_to, ref(pm, nw, :arcs_from_sw), ref(pm, nw, :arcs_to_sw), qsw_expr) + report && sol_component_value_edge(pm, nw, :switch, :qsw_fr, :qsw_to, ref(pm, nw, :arcs_from_sw), ref(pm, nw, :arcs_to_sw), qsw_expr) end @@ -1201,7 +1201,7 @@ function variable_ne_branch_power_real(pm::AbstractPowerModel; nw::Int=nw_id_def end end - report && _IM.sol_component_value_edge(pm, pm_it_sym, nw, :ne_branch, :pf, :pt, ref(pm, nw, :ne_arcs_from), ref(pm, nw, :ne_arcs_to), p_ne) + report && sol_component_value_edge(pm, nw, :ne_branch, :pf, :pt, ref(pm, nw, :ne_arcs_from), ref(pm, nw, :ne_arcs_to), p_ne) end "variable: `-ne_branch[l][\"rate_a\"] <= q_ne[l,i,j] <= ne_branch[l][\"rate_a\"]` for `(l,i,j)` in `ne_arcs`" @@ -1225,7 +1225,7 @@ function variable_ne_branch_power_imaginary(pm::AbstractPowerModel; nw::Int=nw_i end end - report && _IM.sol_component_value_edge(pm, pm_it_sym, nw, :ne_branch, :qf, :qt, ref(pm, nw, :ne_arcs_from), ref(pm, nw, :ne_arcs_to), q_ne) + report && sol_component_value_edge(pm, nw, :ne_branch, :qf, :qt, ref(pm, nw, :ne_arcs_from), ref(pm, nw, :ne_arcs_to), q_ne) end "variable: `0 <= z_branch[l] <= 1` for `l` in `branch`es" diff --git a/src/form/dcp.jl b/src/form/dcp.jl index 7db8e735..e1771d2c 100644 --- a/src/form/dcp.jl +++ b/src/form/dcp.jl @@ -257,7 +257,7 @@ function variable_branch_power_real(pm::AbstractAPLossLessModels; nw::Int=nw_id_ p_expr = merge(p_expr, Dict( ((l,j,i), -1.0*p[(l,i,j)]) for (l,i,j) in ref(pm, nw, :arcs_from))) var(pm, nw)[:p] = p_expr - report && _IM.sol_component_value_edge(pm, pm_it_sym, nw, :branch, :pf, :pt, ref(pm, nw, :arcs_from), ref(pm, nw, :arcs_to), p_expr) + report && sol_component_value_edge(pm, nw, :branch, :pf, :pt, ref(pm, nw, :arcs_from), ref(pm, nw, :arcs_to), p_expr) end "" @@ -280,7 +280,7 @@ function variable_ne_branch_power_real(pm::AbstractAPLossLessModels; nw::Int=nw_ p_ne_expr = merge(p_ne_expr, Dict(((l,j,i), -1.0*var(pm, nw, :p_ne, (l,i,j))) for (l,i,j) in ref(pm, nw, :ne_arcs_from))) var(pm, nw)[:p_ne] = p_ne_expr - report && _IM.sol_component_value_edge(pm, pm_it_sym, nw, :ne_branch, :p_ne_fr, :p_ne_to, ref(pm, nw, :ne_arcs_from), ref(pm, nw, :ne_arcs_to), p_ne_expr) + report && sol_component_value_edge(pm, nw, :ne_branch, :p_ne_fr, :p_ne_to, ref(pm, nw, :ne_arcs_from), ref(pm, nw, :ne_arcs_to), p_ne_expr) end "" diff --git a/src/form/iv.jl b/src/form/iv.jl index 37854fd9..ca49d5bf 100644 --- a/src/form/iv.jl +++ b/src/form/iv.jl @@ -29,8 +29,8 @@ function variable_branch_current(pm::AbstractIVRModel; nw::Int=nw_id_default, bo var(pm, nw)[:p] = p var(pm, nw)[:q] = q - report && _IM.sol_component_value_edge(pm, pm_it_sym, nw, :branch, :pf, :pt, ref(pm, nw, :arcs_from), ref(pm, nw, :arcs_to), p) - report && _IM.sol_component_value_edge(pm, pm_it_sym, nw, :branch, :qf, :qt, ref(pm, nw, :arcs_from), ref(pm, nw, :arcs_to), q) + report && sol_component_value_edge(pm, nw, :branch, :pf, :pt, ref(pm, nw, :arcs_from), ref(pm, nw, :arcs_to), p) + report && sol_component_value_edge(pm, nw, :branch, :qf, :qt, ref(pm, nw, :arcs_from), ref(pm, nw, :arcs_to), q) variable_branch_series_current_real(pm, nw=nw, bounded=bounded, report=report; kwargs...) variable_branch_series_current_imaginary(pm, nw=nw, bounded=bounded, report=report; kwargs...) @@ -93,8 +93,8 @@ function variable_dcline_current(pm::AbstractIVRModel; nw::Int=nw_id_default, bo var(pm, nw)[:p_dc] = p var(pm, nw)[:q_dc] = q - report && _IM.sol_component_value_edge(pm, pm_it_sym, nw, :dcline, :pf, :pt, ref(pm, nw, :arcs_from_dc), ref(pm, nw, :arcs_to_dc), p) - report && _IM.sol_component_value_edge(pm, pm_it_sym, nw, :dcline, :qf, :qt, ref(pm, nw, :arcs_from_dc), ref(pm, nw, :arcs_to_dc), q) + report && sol_component_value_edge(pm, nw, :dcline, :pf, :pt, ref(pm, nw, :arcs_from_dc), ref(pm, nw, :arcs_to_dc), p) + report && sol_component_value_edge(pm, nw, :dcline, :qf, :qt, ref(pm, nw, :arcs_from_dc), ref(pm, nw, :arcs_to_dc), q) if bounded for (i,dcline) in ref(pm, nw, :dcline)