Skip to content

Commit ce48631

Browse files
committed
Add bench
1 parent 45abf13 commit ce48631

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

perf/opf/opf.jl

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1+
import MathOptInterface as MOI
12
ROSETTA_OPF_DIR = "/home/blegat/git/rosetta-opf"
23
include(joinpath(ROSETTA_OPF_DIR, "jump.jl"))
34
model = opf_model(parse_data(joinpath(ROSETTA_OPF_DIR, "data/opf_warmup.m")))
4-
import MathOptInterface as MOI
5+
JuMP.set_attribute(model, "max_iter", 1)
56
JuMP.optimize!(model)
67
ipopt = JuMP.unsafe_backend(model)
78
ipopt.nlp_model
89
ad = ipopt.nlp_data.evaluator
910
x = ipopt.inner.x
1011
g = zeros(length(ipopt.nlp_data.constraint_bounds))
11-
bench0(ad, x, g)
12-
bench1(ad, x, g)
13-
bench2(ad, x, g)
1412

1513
function bench0(ad, x, y)
14+
if !isnothing(ad.backend.objective)
15+
@time MOI.eval_objective(ad, x)
16+
end
1617
@time MOI.eval_constraint(ad, g, x)
18+
return
1719
end
1820

1921
function bench1(ad, x, y)
@@ -28,3 +30,15 @@ function bench2(ad, x, y)
2830
σ = 1.0
2931
@time MOI.eval_hessian_lagrangian(ad, V, x, σ, y)
3032
end
33+
34+
function bench_opt(model)
35+
@time JuMP.optimize!(model)
36+
end
37+
38+
JuMP.set_attribute(model, "max_iter", 1)
39+
@profview_allocs JuMP.optimize!(model)
40+
41+
bench_opt(model)
42+
bench0(ad, x, g)
43+
bench1(ad, x, g)
44+
bench2(ad, x, g)

0 commit comments

Comments
 (0)