Skip to content

Commit 7ff519d

Browse files
authored
Add opf benchmark (#2)
1 parent 3090b3f commit 7ff519d

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

perf/opf/Project.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[deps]
2+
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
3+
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
4+
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
5+
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
6+
PGLib = "07a8691f-3d11-4330-951b-3c50f98338be"
7+
PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655"
8+
9+
[compat]
10+
PGLib = "0.2"
11+
PowerModels = "0.21"

perf/opf/opf.jl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import Ipopt
2+
import JuMP
3+
import MathOptInterface as MOI
4+
import PGLib
5+
import PowerModels
6+
7+
model = JuMP.direct_model(Ipopt.Optimizer())
8+
pm = PowerModels.instantiate_model(
9+
PGLib.pglib("pglib_opf_case10000_goc"),
10+
PowerModels.ACPPowerModel,
11+
PowerModels.build_opf;
12+
jump_model = model,
13+
);
14+
15+
ipopt = JuMP.backend(model)
16+
x = MOI.get(ipopt, MOI.ListOfVariableIndices())
17+
m, n = length(ipopt.nlp_model.constraints), length(x)
18+
19+
evaluator = MOI.Nonlinear.Evaluator(
20+
ipopt.nlp_model,
21+
MOI.Nonlinear.SparseReverseMode(),
22+
x,
23+
)
24+
MOI.initialize(evaluator, [:Grad, :Jac, :Hess])
25+
26+
H_struct = MOI.hessian_lagrangian_structure(evaluator)
27+
H = zeros(length(H_struct))
28+
μ = rand(m)
29+
σ = 0.0
30+
v = rand(n)
31+
@time MOI.eval_hessian_lagrangian(evaluator, H, v, σ, μ)
32+
33+
using BenchmarkTools
34+
@benchmark MOI.eval_hessian_lagrangian($evaluator, $H, $v, $σ, $μ) seconds = 100

0 commit comments

Comments
 (0)