Skip to content

Commit 45abf13

Browse files
committed
Add OPF benchmark
1 parent 2bd236f commit 45abf13

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

perf/opf/Project.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
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+
PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655"

perf/opf/opf.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
ROSETTA_OPF_DIR = "/home/blegat/git/rosetta-opf"
2+
include(joinpath(ROSETTA_OPF_DIR, "jump.jl"))
3+
model = opf_model(parse_data(joinpath(ROSETTA_OPF_DIR, "data/opf_warmup.m")))
4+
import MathOptInterface as MOI
5+
JuMP.optimize!(model)
6+
ipopt = JuMP.unsafe_backend(model)
7+
ipopt.nlp_model
8+
ad = ipopt.nlp_data.evaluator
9+
x = ipopt.inner.x
10+
g = zeros(length(ipopt.nlp_data.constraint_bounds))
11+
bench0(ad, x, g)
12+
bench1(ad, x, g)
13+
bench2(ad, x, g)
14+
15+
function bench0(ad, x, y)
16+
@time MOI.eval_constraint(ad, g, x)
17+
end
18+
19+
function bench1(ad, x, y)
20+
J = @time MOI.jacobian_structure(ad)
21+
V = zeros(length(J))
22+
@time MOI.eval_constraint_jacobian(ad, V, x)
23+
end
24+
25+
function bench2(ad, x, y)
26+
J = @time MOI.hessian_lagrangian_structure(ad)
27+
V = zeros(length(J))
28+
σ = 1.0
29+
@time MOI.eval_hessian_lagrangian(ad, V, x, σ, y)
30+
end

0 commit comments

Comments
 (0)