PowerModels.jl icon indicating copy to clipboard operation
PowerModels.jl copied to clipboard

solve_pf() does not work with LPACCPowerModel

Open grecht opened this issue 2 years ago • 3 comments

Run this small example using PGLIB to reproduce the error:

using PowerModels
using Ipopt 

pglib_path = "../pglib-opf"
case = "pglib_opf_case14_ieee.m"

case_file = joinpath(pglib_path, case)

result_lpac = solve_pf(case_file, LPACCPowerModel, Ipopt.Optimizer)

print_summary(result_lpac["solution"])

It results in the following error:

[info | PowerModels]: removing 3 cost terms from generator 4: Float64[]
[info | PowerModels]: removing 1 cost terms from generator 1: [792.0951, 0.0]
[info | PowerModels]: removing 3 cost terms from generator 5: Float64[]
[info | PowerModels]: removing 1 cost terms from generator 2: [2326.9494, 0.0]
[info | PowerModels]: removing 3 cost terms from generator 3: Float64[]
ERROR: MethodError: no method matching expression_branch_power_ohms_yt_from(::LPACCPowerModel, ::Int64, ::Int64, ::Int64, ::Tuple{Int64, Int64, Int64}, ::Tuple{Int64, Int64, Int64}, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64)
Closest candidates are:
  expression_branch_power_ohms_yt_from(::AbstractACPModel, ::Int64, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) at C:\Users\rech_ge\.julia\packages\PowerModels\bcmVu\src\form\acp.jl:234
  expression_branch_power_ohms_yt_from(::AbstractACRModel, ::Int64, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) at C:\Users\rech_ge\.julia\packages\PowerModels\bcmVu\src\form\acr.jl:166
  expression_branch_power_ohms_yt_from(::AbstractDCMPPModel, ::Int64, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) at C:\Users\rech_ge\.julia\packages\PowerModels\bcmVu\src\form\dcp.jl:103
  ...
Stacktrace:
  [1] expression_branch_power_ohms_yt_from(pm::LPACCPowerModel, i::Int64; nw::Int64)
    @ PowerModels C:\Users\rech_ge\.julia\packages\PowerModels\bcmVu\src\core\expression_template.jl:88
  [2] expression_branch_power_ohms_yt_from(pm::LPACCPowerModel, i::Int64)
    @ PowerModels C:\Users\rech_ge\.julia\packages\PowerModels\bcmVu\src\core\expression_template.jl:69
  [3] build_pf(pm::LPACCPowerModel)
    @ PowerModels C:\Users\rech_ge\.julia\packages\PowerModels\bcmVu\src\prob\pf.jl:23
  [4] instantiate_model(data::Dict{String, Any}, model_type::Type, build_method::typeof(build_pf), ref_add_core!::typeof(ref_add_core!), global_keys::Set{String}, it::Symbol; ref_extensions::Vector{Any}, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ InfrastructureModels C:\Users\rech_ge\.julia\packages\InfrastructureModels\C2xBM\src\core\base.jl:370
  [5] #instantiate_model#321
    @ C:\Users\rech_ge\.julia\packages\PowerModels\bcmVu\src\core\base.jl:67 [inlined]
  [6] solve_model(data::Dict{String, Any}, model_type::Type, optimizer::Type, build_method::typeof(build_pf); ref_extensions::Vector{Any}, solution_processors::Vector{Any}, relax_integrality::Bool, multinetwork::Bool, multiconductor::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ PowerModels C:\Users\rech_ge\.julia\packages\PowerModels\bcmVu\src\core\base.jl:48
  [7] solve_model(data::Dict{String, Any}, model_type::Type, optimizer::Type, build_method::Function)
    @ PowerModels C:\Users\rech_ge\.julia\packages\PowerModels\bcmVu\src\core\base.jl:35
  [8] solve_model(file::String, model_type::Type, optimizer::Type, build_method::Function; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ PowerModels C:\Users\rech_ge\.julia\packages\PowerModels\bcmVu\src\core\base.jl:27
  [9] solve_model
    @ C:\Users\rech_ge\.julia\packages\PowerModels\bcmVu\src\core\base.jl:26 [inlined]
 [10] #solve_pf#1065
    @ C:\Users\rech_ge\.julia\packages\PowerModels\bcmVu\src\prob\pf.jl:13 [inlined]
 [11] solve_pf(file::String, model_type::Type, optimizer::Type)
    @ PowerModels C:\Users\rech_ge\.julia\packages\PowerModels\bcmVu\src\prob\pf.jl:13
 [12] top-level scope
    @ REPL[8]:1

grecht avatar Oct 05 '23 09:10 grecht

Right now the LPAC model is only supported for OPF. In this example you are running PF. I will leave this issue open to explore how this could be supported in the future.

On Thu, Oct 5, 2023 at 5:14 AM Gereon Recht @.***> wrote:

Run this small example using PGLIB https://github.com/power-grid-lib/pglib-opf to reproduce the error:

using PowerModelsusing Ipopt

pglib_path = "../pglib-opf" case = "pglib_opf_case14_ieee.m"

case_file = joinpath(pglib_path, case)

result_lpac = solve_pf(case_file, LPACCPowerModel, Ipopt.Optimizer) print_summary(result_lpac["solution"])

It results in the following error:

[info | PowerModels]: removing 3 cost terms from generator 4: Float64[] [info | PowerModels]: removing 1 cost terms from generator 1: [792.0951, 0.0] [info | PowerModels]: removing 3 cost terms from generator 5: Float64[] [info | PowerModels]: removing 1 cost terms from generator 2: [2326.9494, 0.0] [info | PowerModels]: removing 3 cost terms from generator 3: Float64[] ERROR: MethodError: no method matching expression_branch_power_ohms_yt_from(::LPACCPowerModel, ::Int64, ::Int64, ::Int64, ::Tuple{Int64, Int64, Int64}, ::Tuple{Int64, Int64, Int64}, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64) Closest candidates are: expression_branch_power_ohms_yt_from(::AbstractACPModel, ::Int64, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) at C:\Users\rech_ge.julia\packages\PowerModels\bcmVu\src\form\acp.jl:234 expression_branch_power_ohms_yt_from(::AbstractACRModel, ::Int64, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) at C:\Users\rech_ge.julia\packages\PowerModels\bcmVu\src\form\acr.jl:166 expression_branch_power_ohms_yt_from(::AbstractDCMPPModel, ::Int64, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) at C:\Users\rech_ge.julia\packages\PowerModels\bcmVu\src\form\dcp.jl:103 ... Stacktrace: [1] expression_branch_power_ohms_yt_from(pm::LPACCPowerModel, i::Int64; nw::Int64) @ PowerModels C:\Users\rech_ge.julia\packages\PowerModels\bcmVu\src\core\expression_template.jl:88 [2] expression_branch_power_ohms_yt_from(pm::LPACCPowerModel, i::Int64) @ PowerModels C:\Users\rech_ge.julia\packages\PowerModels\bcmVu\src\core\expression_template.jl:69 [3] build_pf(pm::LPACCPowerModel) @ PowerModels C:\Users\rech_ge.julia\packages\PowerModels\bcmVu\src\prob\pf.jl:23 [4] instantiate_model(data::Dict{String, Any}, model_type::Type, build_method::typeof(build_pf), ref_add_core!::typeof(ref_add_core!), global_keys::Set{String}, it::Symbol; ref_extensions::Vector{Any}, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) @ InfrastructureModels C:\Users\rech_ge.julia\packages\InfrastructureModels\C2xBM\src\core\base.jl:370 [5] #instantiate_model#321 @ C:\Users\rech_ge.julia\packages\PowerModels\bcmVu\src\core\base.jl:67 [inlined] [6] solve_model(data::Dict{String, Any}, model_type::Type, optimizer::Type, build_method::typeof(build_pf); ref_extensions::Vector{Any}, solution_processors::Vector{Any}, relax_integrality::Bool, multinetwork::Bool, multiconductor::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) @ PowerModels C:\Users\rech_ge.julia\packages\PowerModels\bcmVu\src\core\base.jl:48 [7] solve_model(data::Dict{String, Any}, model_type::Type, optimizer::Type, build_method::Function) @ PowerModels C:\Users\rech_ge.julia\packages\PowerModels\bcmVu\src\core\base.jl:35 [8] solve_model(file::String, model_type::Type, optimizer::Type, build_method::Function; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) @ PowerModels C:\Users\rech_ge.julia\packages\PowerModels\bcmVu\src\core\base.jl:27 [9] solve_model @ C:\Users\rech_ge.julia\packages\PowerModels\bcmVu\src\core\base.jl:26 [inlined] [10] #solve_pf#1065 @ C:\Users\rech_ge.julia\packages\PowerModels\bcmVu\src\prob\pf.jl:13 [inlined] [11] solve_pf(file::String, model_type::Type, optimizer::Type) @ PowerModels C:\Users\rech_ge.julia\packages\PowerModels\bcmVu\src\prob\pf.jl:13 [12] top-level scope @ REPL[8]:1

— Reply to this email directly, view it on GitHub https://github.com/lanl-ansi/PowerModels.jl/issues/891, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIN5KSKIZ5QAB64ILTNSATX5Z26VAVCNFSM6AAAAAA5T5RLI2VHI2DSMVQWIX3LMV43ASLTON2WKOZRHEZDONZYGE4TCOI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ccoffrin avatar Oct 05 '23 12:10 ccoffrin

Ah, I see. Thanks!

grecht avatar Oct 05 '23 14:10 grecht

I though of a reasonable workaround for this issue.

If you would like to solve a PF problem with a formulation that does not currently support PF you can instead pose your PF problem as an OPF problem where the generator cost functions are constant values or identical linear functions.

ccoffrin avatar Oct 07 '23 23:10 ccoffrin