Skip to content

Add OPF benchmark #2739

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions perf/opf/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
PGLib = "07a8691f-3d11-4330-951b-3c50f98338be"
PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These need compat


[compat]
PGLib = "0.2"
PowerModels = "0.21"
34 changes: 34 additions & 0 deletions perf/opf/opf.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import Ipopt
import JuMP
import MathOptInterface as MOI
import PGLib
import PowerModels

model = JuMP.direct_model(Ipopt.Optimizer())
pm = PowerModels.instantiate_model(
PGLib.pglib("pglib_opf_case10000_goc"),
PowerModels.ACPPowerModel,
PowerModels.build_opf;
jump_model = model,
);

ipopt = JuMP.backend(model)
x = MOI.get(ipopt, MOI.ListOfVariableIndices())
m, n = length(ipopt.nlp_model.constraints), length(x)

evaluator = MOI.Nonlinear.Evaluator(
ipopt.nlp_model,
MOI.Nonlinear.SparseReverseMode(),
x,
)
MOI.initialize(evaluator, [:Grad, :Jac, :Hess])

H_struct = MOI.hessian_lagrangian_structure(evaluator)
H = zeros(length(H_struct))
μ = rand(m)
σ = 0.0
v = rand(n)
@time MOI.eval_hessian_lagrangian(evaluator, H, v, σ, μ)

using BenchmarkTools
@benchmark MOI.eval_hessian_lagrangian($evaluator, $H, $v, $σ, $μ) seconds = 100
Loading