Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The length of result['solution']['gen'] did not match the inputted pm_data['gen] #929

Closed
yasirroni opened this issue Oct 9, 2024 · 5 comments

Comments

@yasirroni
Copy link

I'm testing PowerModels on PGLib. In running pglib_opf_case2746wop_k.m, the length of input is pm_data['gen] is 514, while the output is result['solution']['gen']. Can you enlighten me the meaning of this? Thank you.

@yasirroni
Copy link
Author

Related to #928, debug and understanding the behavior of pm_data = _matpower_to_powermodels!(mp_data).

@ccoffrin
Copy link
Member

ccoffrin commented Oct 9, 2024

I cannot follow your question. Please review the package docs and elaborate on what you think may be going wrong.

@yasirroni
Copy link
Author

Same data, why solve_opf result has fewer generator.

using InfrastructureModels
using PowerModels
using Ipopt
using JuMP

case = "pglib-opf/pglib_opf_case2746wop_k.m"
nlp_solver = JuMP.optimizer_with_attributes(Ipopt.Optimizer, "tol"=>1e-6, "print_level"=>0)

result_ac = solve_opf(case, ACPPowerModel, nlp_solver)

result_ac["solution"]["gen"]
# Dict{String, Any} with 431 entries:
#   "306" => Dict{String, Any}("qg"=>2.05902e-7, "pg"=>0.15)
#   "1"   => Dict{String, Any}("qg"=>-0.0961256, "pg"=>1.4)
#   "54"  => Dict{String, Any}("qg"=>0.601058, "pg"=>1.2)
#   "101" => Dict{String, Any}("qg"=>0.151089, "pg"=>0.4)
#   "371" => Dict{String, Any}("qg"=>0.0749997, "pg"=>0.5)
#   "464" => Dict{String, Any}("qg"=>0.000998251, "pg"=>0.001)
#   "475" => Dict{String, Any}("qg"=>0.0, "pg"=>0.012)
#   "447" => Dict{String, Any}("qg"=>0.0, "pg"=>0.008)
#   "335" => Dict{String, Any}("qg"=>5.1374e-8, "pg"=>0.25)
#   "362" => Dict{String, Any}("qg"=>0.00999991, "pg"=>0.53376)
#   "505" => Dict{String, Any}("qg"=>0.00761, "pg"=>0.19344)
#   "491" => Dict{String, Any}("qg"=>0.01699, "pg"=>0.058)
#   "299" => Dict{String, Any}("qg"=>0.32169, "pg"=>0.8)
#   "168" => Dict{String, Any}("qg"=>1.06376e-7, "pg"=>0.09)
#   "159" => Dict{String, Any}("qg"=>-0.199888, "pg"=>1.35)
#   "403" => Dict{String, Any}("qg"=>0.0, "pg"=>0.03)
#   "228" => Dict{String, Any}("qg"=>1.76333e-7, "pg"=>0.06999)
#   "332" => Dict{String, Any}("qg"=>3.76483e-8, "pg"=>0.4)
#   "270" => Dict{String, Any}("qg"=>0.697152, "pg"=>1.4)
#   ⋮     => ⋮

pm_data = open(case) do io
    mp_data = PowerModels._parse_matpower_string(read(io, String))
    pm_data = PowerModels._matpower_to_powermodels!(mp_data)
end

pm_data["gen"]
# Dict{String, Any} with 514 entries:
#   "306" => Dict{String, Any}("vg"=>1.035, "mbase"=>25.6, "source_id"=>Any["gen"…
#   "407" => Dict{String, Any}("vg"=>1.035, "mbase"=>3.6, "source_id"=>Any["gen",…
#   "1"   => Dict{String, Any}("vg"=>1.03, "mbase"=>233.2, "source_id"=>Any["gen"…
#   "54"  => Dict{String, Any}("vg"=>1.03, "mbase"=>150.0, "source_id"=>Any["gen"…
#   "101" => Dict{String, Any}("vg"=>1.035, "mbase"=>57.5, "source_id"=>Any["gen"…
#   "371" => Dict{String, Any}("vg"=>1.035, "mbase"=>55.5, "source_id"=>Any["gen"…
#   "41"  => Dict{String, Any}("vg"=>1.03, "mbase"=>150.0, "source_id"=>Any["gen"…
#   "464" => Dict{String, Any}("vg"=>1.035, "mbase"=>0.1, "source_id"=>Any["gen",…
#   "65"  => Dict{String, Any}("vg"=>1.0, "mbase"=>252.4, "source_id"=>Any["gen",…
#   "475" => Dict{String, Any}("vg"=>1.035, "mbase"=>1.2, "source_id"=>Any["gen",…
#   "447" => Dict{String, Any}("vg"=>1.035, "mbase"=>0.8, "source_id"=>Any["gen",…
#   "335" => Dict{String, Any}("vg"=>1.035, "mbase"=>30.2, "source_id"=>Any["gen"…
#   "362" => Dict{String, Any}("vg"=>1.035, "mbase"=>53.4, "source_id"=>Any["gen"…
#   "505" => Dict{String, Any}("vg"=>1.035, "mbase"=>19.4, "source_id"=>Any["gen"…
#   "491" => Dict{String, Any}("vg"=>1.035, "mbase"=>6.0, "source_id"=>Any["gen",…
#   "326" => Dict{String, Any}("vg"=>1.035, "mbase"=>52.2, "source_id"=>Any["gen"…
#   "299" => Dict{String, Any}("vg"=>1.035, "mbase"=>129.3, "source_id"=>Any["gen…
#   "168" => Dict{String, Any}("vg"=>1.035, "mbase"=>9.2, "source_id"=>Any["gen",…
#   "159" => Dict{String, Any}("vg"=>1.035, "mbase"=>255.0, "source_id"=>Any["gen…
#   ⋮     => ⋮

@yasirroni
Copy link
Author

I will assume that missing value in result_ac["solution"]["gen"] means the generator is not available and the value of qg and pg is 0. If that is not what intended, please let me know. I'm on my way writing a benchmark of various solver out there.

@ccoffrin
Copy link
Member

That is the correct. Any component that is deactivated via the status field will not appear in the solution data. You may be interested in the basic-data feature, where this kind of situation does not occur, https://lanl-ansi.github.io/PowerModels.jl/stable/basic-data-utilities/

If you are interested in benchmarks you may find this effort interesting, https://github.com/lanl-ansi/rosetta-opf and https://youtu.be/tvBNQcuU-hY

I am going to close this issue now because the software is working as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants