1+ import MathOptInterface as MOI
12ROSETTA_OPF_DIR = " /home/blegat/git/rosetta-opf"
23include (joinpath (ROSETTA_OPF_DIR, " jump.jl" ))
34model = 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 )
56JuMP. optimize! (model)
67ipopt = JuMP. unsafe_backend (model)
78ipopt. nlp_model
89ad = ipopt. nlp_data. evaluator
910x = ipopt. inner. x
1011g = zeros (length (ipopt. nlp_data. constraint_bounds))
11- bench0 (ad, x, g)
12- bench1 (ad, x, g)
13- bench2 (ad, x, g)
1412
1513function 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
1719end
1820
1921function 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)
3032end
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