lanl-ansi / rosetta-opf

AC-OPF Implementations in Various NLP Modeling Frameworks
Other
52 stars 11 forks source link

Add optimization based on SciMLBenchmarks #41

Closed odow closed 8 months ago

odow commented 8 months ago

Based on https://github.com/SciML/SciMLBenchmarks.jl/blob/master/benchmarks/OptimizationFrameworks/optimal_powerflow.jmd

I get:

ERROR: ArgumentError: The passed automatic differentiation backend choice is not available. Please load the corresponding AD package SparseReverseDiff.
Stacktrace:
 [1] instantiate_function(f::Function, x::Vector{…}, adtype::ADTypes.AutoSparseReverseDiff, p::Nothing, num_cons::Int64)
   @ Optimization ~/.julia/packages/Optimization/y5ns2/src/function.jl:114
 [2] build_opf_optimization_prob(dataset::DataRepresentation{…})
   @ Main ~/Documents/lanl-ansi/rosetta-opf/optimization2.jl:485
 [3] solve_opf(file_name::String)
   @ Main ~/Documents/lanl-ansi/rosetta-opf/optimization2.jl:504
 [4] top-level scope
   @ REPL[26]:1
Some type information was truncated. Use `show(err)` to see complete types.

But I couldn't figure out how to install SparseReverseDiff.

x-ref https://discourse.julialang.org/t/ac-optimal-power-flow-in-various-nonlinear-optimization-frameworks/78486/71?u=odow

ccoffrin commented 8 months ago

I confirm that I run into the same issue. Next step is to understand how to load this dependency.

Vaibhavdixit02 commented 8 months ago

Sorry that error shows up from a heuristic https://github.com/SciML/Optimization.jl/blob/master/src/function.jl#L113 that wasn't updated to take AutoSparseReverseDiff into account.

odow commented 8 months ago

Thanks @Vaibhavdixit02! Let me know if there is a better choice than

adchoice = Optimization.AutoSparseReverseDiff(true) 

Here are a few runs I did on my 2018 MacBook. Some look 2x faster. Some look pretty similar to https://discourse.julialang.org/t/ac-optimal-power-flow-in-various-nonlinear-optimization-frameworks/78486/70?u=odow, but I'll let @ccoffrin re-run on his machines.

julia> solve_opf("data/pglib_opf_case5_pjm.m")
[info | PowerModels]: extending matpower format with data: areas 1x3
[info | PowerModels]: removing 1 cost terms from generator 4: [4000.0, 0.0]
[info | PowerModels]: removing 1 cost terms from generator 1: [1400.0, 0.0]
[info | PowerModels]: removing 1 cost terms from generator 5: [1000.0, 0.0]
[info | PowerModels]: removing 1 cost terms from generator 2: [1500.0, 0.0]
[info | PowerModels]: removing 1 cost terms from generator 3: [3000.0, 0.0]
[info | PowerModels]: updated generator 4 cost function with order 2 to a function of order 3: [0.0, 4000.0, 0.0]
[info | PowerModels]: updated generator 1 cost function with order 2 to a function of order 3: [0.0, 1400.0, 0.0]
[info | PowerModels]: updated generator 5 cost function with order 2 to a function of order 3: [0.0, 1000.0, 0.0]
[info | PowerModels]: updated generator 2 cost function with order 2 to a function of order 3: [0.0, 1500.0, 0.0]
[info | PowerModels]: updated generator 3 cost function with order 2 to a function of order 3: [0.0, 3000.0, 0.0]
This is Ipopt version 3.14.4, running with linear solver MUMPS 5.4.1.

Number of nonzeros in equality constraint Jacobian...:      155
Number of nonzeros in inequality constraint Jacobian.:       36
Number of nonzeros in Lagrangian Hessian.............:      240

Total number of variables............................:       44
                     variables with only lower bounds:        0
                variables with lower and upper bounds:       39
                     variables with only upper bounds:        0
Total number of equality constraints.................:       35
Total number of inequality constraints...............:       18
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:        6
        inequality constraints with only upper bounds:       12

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  1.0059989e+02 3.99e+00 2.88e+01  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1  8.3066346e+03 2.47e+00 1.01e+02  -1.0 2.78e+00    -  4.11e-03 3.82e-01h  1
   2  6.7182484e+03 2.36e+00 9.62e+01  -1.0 1.60e+01    -  7.37e-02 4.44e-02f  1
   3  6.6691211e+03 2.30e+00 9.34e+01  -1.0 1.30e+01    -  4.95e-01 2.40e-02f  1
   4  6.5744238e+03 2.04e+00 8.25e+01  -1.0 1.29e+01    -  3.67e-01 1.12e-01f  2
   5  6.8265929e+03 1.80e+00 7.10e+01  -1.0 1.23e+01    -  8.72e-01 1.20e-01h  2
   6  8.8541540e+03 1.08e+00 4.20e+01  -1.0 9.14e+00    -  5.92e-01 4.00e-01h  1
   7  1.0572759e+04 8.62e-01 3.58e+01  -1.0 2.94e+00    -  4.94e-01 2.00e-01h  1
   8  1.7308372e+04 3.63e-02 1.47e+01  -1.0 2.41e+00    -  7.66e-01 9.58e-01h  1
   9  1.7572883e+04 1.33e-02 1.10e+00  -1.0 2.11e+00    -  1.00e+00 1.00e+00h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  10  1.7590632e+04 1.69e-03 1.61e-01  -1.0 5.03e-01    -  1.00e+00 1.00e+00h  1
  11  1.7558725e+04 5.24e-03 5.03e-01  -2.5 6.03e-01    -  8.35e-01 9.36e-01f  1
  12  1.7553111e+04 3.34e-03 4.11e+00  -2.5 2.84e-01    -  1.00e+00 8.20e-01h  1
  13  1.7552956e+04 3.24e-05 1.26e-02  -2.5 6.35e-02    -  1.00e+00 1.00e+00h  1
  14  1.7551990e+04 1.35e-05 1.09e+00  -3.8 2.53e-02    -  1.00e+00 9.25e-01h  1
  15  1.7551938e+04 4.46e-08 1.23e-02  -3.8 7.00e-03    -  1.00e+00 1.00e+00f  1
  16  1.7551940e+04 2.36e-10 2.06e-04  -3.8 3.84e-04    -  1.00e+00 1.00e+00h  1
  17  1.7551892e+04 1.75e-07 2.11e-01  -5.7 2.49e-03    -  1.00e+00 9.68e-01f  1
  18  1.7551891e+04 6.82e-11 3.10e-05  -5.7 2.38e-04    -  1.00e+00 1.00e+00f  1
  19  1.7551891e+04 1.60e-14 6.53e-10  -5.7 5.20e-07    -  1.00e+00 1.00e+00h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  20  1.7551891e+04 6.34e-12 3.03e-07  -8.6 3.52e-05    -  1.00e+00 1.00e+00f  1
  21  1.7551891e+04 1.82e-14 2.21e-12  -8.6 3.34e-08    -  1.00e+00 1.00e+00h  1

Number of Iterations....: 21

                                   (scaled)                 (unscaled)
Objective...............:   4.3879727096486897e+02    1.7551890838594758e+04
Dual infeasibility......:   2.2126691395576679e-12    8.8506765582306717e-11
Constraint violation....:   1.3544720900426910e-14    1.8207657603852567e-14
Variable bound violation:   2.9463905093507492e-08    2.9463905093507492e-08
Complementarity.........:   2.5059076302144483e-09    1.0023630520857793e-07
Overall NLP error.......:   2.5059076302144483e-09    1.0023630520857793e-07

Number of objective function evaluations             = 28
Number of objective gradient evaluations             = 22
Number of equality constraint evaluations            = 28
Number of inequality constraint evaluations          = 28
Number of equality constraint Jacobian evaluations   = 22
Number of inequality constraint Jacobian evaluations = 22
Number of Lagrangian Hessian evaluations             = 21
Total seconds in IPOPT                               = 0.068

EXIT: Optimal Solution Found.

Summary
   case........: data/pglib_opf_case5_pjm.m
   variables...: 44
   constraints.: 53
   feasible....: true
   cost........: 17552
   total time..: 0.26991891860961914
     data time.: 0.006615877151489258
     build time: 0.14377903938293457
     solve time: 0.11952400207519531

Dict{String, Any} with 9 entries:
  "cost"        => 17551.9
  "variables"   => 44
  "constraints" => 53
  "case"        => "data/pglib_opf_case5_pjm.m"
  "time_total"  => 0.269919
  "time_build"  => 0.143779
  "time_solve"  => 0.119524
  "time_data"   => 0.00661588
  "feasible"    => true

julia> solve_opf("data/pglib_opf_case14_ieee.m")
[info | PowerModels]: removing 3 cost terms from generator 4: Float64[]
[info | PowerModels]: removing 1 cost terms from generator 1: [792.0951, 0.0]
[info | PowerModels]: removing 3 cost terms from generator 5: Float64[]
[info | PowerModels]: removing 1 cost terms from generator 2: [2326.9494, 0.0]
[info | PowerModels]: removing 3 cost terms from generator 3: Float64[]
[info | PowerModels]: updated generator 4 cost function with order 0 to a function of order 3: [0.0, 0.0, 0.0]
[info | PowerModels]: updated generator 1 cost function with order 2 to a function of order 3: [0.0, 792.0951, 0.0]
[info | PowerModels]: updated generator 5 cost function with order 0 to a function of order 3: [0.0, 0.0, 0.0]
[info | PowerModels]: updated generator 2 cost function with order 2 to a function of order 3: [0.0, 2326.9494, 0.0]
[info | PowerModels]: updated generator 3 cost function with order 0 to a function of order 3: [0.0, 0.0, 0.0]
This is Ipopt version 3.14.4, running with linear solver MUMPS 5.4.1.

Number of nonzeros in equality constraint Jacobian...:      489
Number of nonzeros in inequality constraint Jacobian.:      120
Number of nonzeros in Lagrangian Hessian.............:      791

Total number of variables............................:      115
                     variables with only lower bounds:        0
                variables with lower and upper bounds:      101
                     variables with only upper bounds:        0
Total number of equality constraints.................:      109
Total number of inequality constraints...............:       60
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:       20
        inequality constraints with only upper bounds:       40

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  2.1649922e+01 9.42e-01 1.88e+01  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1  2.4463824e+03 2.50e-01 1.33e+02  -1.0 1.81e+00    -  5.61e-03 7.34e-01H  1
   2  2.3972492e+03 4.57e-02 8.70e+01  -1.0 1.75e+00    -  1.74e-02 9.87e-01f  1
   3  2.1579593e+03 4.44e-02 8.51e+01  -1.0 2.62e+01    -  2.19e-01 1.99e-02f  1
   4  2.1814861e+03 8.56e-04 1.40e+01  -1.0 8.90e-01    -  7.59e-01 1.00e+00h  1
   5  2.1893330e+03 3.73e-03 7.27e-01  -1.0 6.70e-02    -  1.00e+00 1.00e+00f  1
   6  2.1849626e+03 4.28e-04 5.19e-01  -1.7 1.38e-02    -  9.64e-01 1.00e+00h  1
   7  2.1794127e+03 2.31e-03 2.33e-02  -1.7 4.15e-02    -  1.00e+00 1.00e+00f  1
   8  2.1786671e+03 6.12e-04 2.89e-01  -3.8 7.92e-03    -  8.46e-01 7.40e-01h  1
   9  2.1780966e+03 1.45e-04 3.04e-01  -3.8 4.14e-02    -  4.43e-01 9.69e-01h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  10  2.1780936e+03 6.98e-06 6.64e-04  -3.8 1.35e-02    -  1.00e+00 1.00e+00h  1
  11  2.1780803e+03 1.65e-06 9.75e-04  -5.7 4.57e-03    -  9.56e-01 9.45e-01h  1
  12  2.1780805e+03 1.82e-07 1.04e-05  -5.7 1.67e-03    -  1.00e+00 1.00e+00h  1
  13  2.1780804e+03 2.20e-09 2.92e-06  -8.6 1.68e-04    -  1.00e+00 9.98e-01h  1
  14  2.1780804e+03 1.10e-09 1.44e-05  -8.6 2.02e-06    -  1.00e+00 5.00e-01f  2
  15  2.1780804e+03 6.58e-14 3.97e-12  -8.6 1.01e-06    -  1.00e+00 1.00e+00h  1

Number of Iterations....: 15

                                   (scaled)                 (unscaled)
Objective...............:   9.3602396804143680e+01    2.1780804108196407e+03
Dual infeasibility......:   3.9701575360595598e-12    9.2383556964392718e-11
Constraint violation....:   6.5752958633424896e-14    6.5752958633424896e-14
Variable bound violation:   1.0340993394919451e-08    1.0340993394919451e-08
Complementarity.........:   2.5059040524323666e-09    5.8311119312650641e-08
Overall NLP error.......:   2.5059040524323666e-09    5.8311119312650641e-08

Number of objective function evaluations             = 18
Number of objective gradient evaluations             = 16
Number of equality constraint evaluations            = 18
Number of inequality constraint evaluations          = 18
Number of equality constraint Jacobian evaluations   = 16
Number of inequality constraint Jacobian evaluations = 16
Number of Lagrangian Hessian evaluations             = 15
Total seconds in IPOPT                               = 1.292

EXIT: Optimal Solution Found.

Summary
   case........: data/pglib_opf_case14_ieee.m
   variables...: 118
   constraints.: 169
   feasible....: true
   cost........: 2178
   total time..: 5.6155688762664795
     data time.: 0.0984809398651123
     build time: 1.7552690505981445
     solve time: 3.7618188858032227

Dict{String, Any} with 9 entries:
  "cost"        => 2178.08
  "variables"   => 118
  "constraints" => 169
  "case"        => "data/pglib_opf_case14_ieee.m"
  "time_total"  => 5.61557
  "time_build"  => 1.75527
  "time_solve"  => 3.76182
  "time_data"   => 0.0984809
  "feasible"    => true

julia> solve_opf("data/pglib_opf_case14_ieee.m")
[info | PowerModels]: removing 3 cost terms from generator 4: Float64[]
[info | PowerModels]: removing 1 cost terms from generator 1: [792.0951, 0.0]
[info | PowerModels]: removing 3 cost terms from generator 5: Float64[]
[info | PowerModels]: removing 1 cost terms from generator 2: [2326.9494, 0.0]
[info | PowerModels]: removing 3 cost terms from generator 3: Float64[]
[info | PowerModels]: updated generator 4 cost function with order 0 to a function of order 3: [0.0, 0.0, 0.0]
[info | PowerModels]: updated generator 1 cost function with order 2 to a function of order 3: [0.0, 792.0951, 0.0]
[info | PowerModels]: updated generator 5 cost function with order 0 to a function of order 3: [0.0, 0.0, 0.0]
[info | PowerModels]: updated generator 2 cost function with order 2 to a function of order 3: [0.0, 2326.9494, 0.0]
[info | PowerModels]: updated generator 3 cost function with order 0 to a function of order 3: [0.0, 0.0, 0.0]
This is Ipopt version 3.14.4, running with linear solver MUMPS 5.4.1.

Number of nonzeros in equality constraint Jacobian...:      489
Number of nonzeros in inequality constraint Jacobian.:      120
Number of nonzeros in Lagrangian Hessian.............:      791

Total number of variables............................:      115
                     variables with only lower bounds:        0
                variables with lower and upper bounds:      101
                     variables with only upper bounds:        0
Total number of equality constraints.................:      109
Total number of inequality constraints...............:       60
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:       20
        inequality constraints with only upper bounds:       40

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  2.1649922e+01 9.42e-01 1.88e+01  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1  2.4463824e+03 2.50e-01 1.33e+02  -1.0 1.81e+00    -  5.61e-03 7.34e-01H  1
   2  2.3972492e+03 4.57e-02 8.70e+01  -1.0 1.75e+00    -  1.74e-02 9.87e-01f  1
   3  2.1579593e+03 4.44e-02 8.51e+01  -1.0 2.62e+01    -  2.19e-01 1.99e-02f  1
   4  2.1814861e+03 8.56e-04 1.40e+01  -1.0 8.90e-01    -  7.59e-01 1.00e+00h  1
   5  2.1893330e+03 3.73e-03 7.27e-01  -1.0 6.70e-02    -  1.00e+00 1.00e+00f  1
   6  2.1849626e+03 4.28e-04 5.19e-01  -1.7 1.38e-02    -  9.64e-01 1.00e+00h  1
   7  2.1794127e+03 2.31e-03 2.33e-02  -1.7 4.15e-02    -  1.00e+00 1.00e+00f  1
   8  2.1786671e+03 6.12e-04 2.89e-01  -3.8 7.92e-03    -  8.46e-01 7.40e-01h  1
   9  2.1780966e+03 1.45e-04 3.04e-01  -3.8 4.14e-02    -  4.43e-01 9.69e-01h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  10  2.1780936e+03 6.98e-06 6.64e-04  -3.8 1.35e-02    -  1.00e+00 1.00e+00h  1
  11  2.1780803e+03 1.65e-06 9.75e-04  -5.7 4.57e-03    -  9.56e-01 9.45e-01h  1
  12  2.1780805e+03 1.82e-07 1.04e-05  -5.7 1.67e-03    -  1.00e+00 1.00e+00h  1
  13  2.1780804e+03 2.20e-09 2.92e-06  -8.6 1.68e-04    -  1.00e+00 9.98e-01h  1
  14  2.1780804e+03 1.10e-09 1.44e-05  -8.6 2.02e-06    -  1.00e+00 5.00e-01f  2
  15  2.1780804e+03 6.58e-14 3.97e-12  -8.6 1.01e-06    -  1.00e+00 1.00e+00h  1

Number of Iterations....: 15

                                   (scaled)                 (unscaled)
Objective...............:   9.3602396804143680e+01    2.1780804108196407e+03
Dual infeasibility......:   3.9701575360595598e-12    9.2383556964392718e-11
Constraint violation....:   6.5752958633424896e-14    6.5752958633424896e-14
Variable bound violation:   1.0340993394919451e-08    1.0340993394919451e-08
Complementarity.........:   2.5059040524323666e-09    5.8311119312650641e-08
Overall NLP error.......:   2.5059040524323666e-09    5.8311119312650641e-08

Number of objective function evaluations             = 18
Number of objective gradient evaluations             = 16
Number of equality constraint evaluations            = 18
Number of inequality constraint evaluations          = 18
Number of equality constraint Jacobian evaluations   = 16
Number of inequality constraint Jacobian evaluations = 16
Number of Lagrangian Hessian evaluations             = 15
Total seconds in IPOPT                               = 0.419

EXIT: Optimal Solution Found.

Summary
   case........: data/pglib_opf_case14_ieee.m
   variables...: 118
   constraints.: 169
   feasible....: true
   cost........: 2178
   total time..: 2.280452013015747
     data time.: 0.009251117706298828
     build time: 1.6778240203857422
     solve time: 0.593376874923706

Dict{String, Any} with 9 entries:
  "cost"        => 2178.08
  "variables"   => 118
  "constraints" => 169
  "case"        => "data/pglib_opf_case14_ieee.m"
  "time_total"  => 2.28045
  "time_build"  => 1.67782
  "time_solve"  => 0.593377
  "time_data"   => 0.00925112
  "feasible"    => true

julia> solve_opf("data/pglib_opf_case14_ieee.m")
[info | PowerModels]: removing 3 cost terms from generator 4: Float64[]
[info | PowerModels]: removing 1 cost terms from generator 1: [792.0951, 0.0]
[info | PowerModels]: removing 3 cost terms from generator 5: Float64[]
[info | PowerModels]: removing 1 cost terms from generator 2: [2326.9494, 0.0]
[info | PowerModels]: removing 3 cost terms from generator 3: Float64[]
[info | PowerModels]: updated generator 4 cost function with order 0 to a function of order 3: [0.0, 0.0, 0.0]
[info | PowerModels]: updated generator 1 cost function with order 2 to a function of order 3: [0.0, 792.0951, 0.0]
[info | PowerModels]: updated generator 5 cost function with order 0 to a function of order 3: [0.0, 0.0, 0.0]
[info | PowerModels]: updated generator 2 cost function with order 2 to a function of order 3: [0.0, 2326.9494, 0.0]
[info | PowerModels]: updated generator 3 cost function with order 0 to a function of order 3: [0.0, 0.0, 0.0]
This is Ipopt version 3.14.4, running with linear solver MUMPS 5.4.1.

Number of nonzeros in equality constraint Jacobian...:      489
Number of nonzeros in inequality constraint Jacobian.:      120
Number of nonzeros in Lagrangian Hessian.............:      791

Total number of variables............................:      115
                     variables with only lower bounds:        0
                variables with lower and upper bounds:      101
                     variables with only upper bounds:        0
Total number of equality constraints.................:      109
Total number of inequality constraints...............:       60
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:       20
        inequality constraints with only upper bounds:       40

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  2.1649922e+01 9.42e-01 1.88e+01  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1  2.4463824e+03 2.50e-01 1.33e+02  -1.0 1.81e+00    -  5.61e-03 7.34e-01H  1
   2  2.3972492e+03 4.57e-02 8.70e+01  -1.0 1.75e+00    -  1.74e-02 9.87e-01f  1
   3  2.1579593e+03 4.44e-02 8.51e+01  -1.0 2.62e+01    -  2.19e-01 1.99e-02f  1
   4  2.1814861e+03 8.56e-04 1.40e+01  -1.0 8.90e-01    -  7.59e-01 1.00e+00h  1
   5  2.1893330e+03 3.73e-03 7.27e-01  -1.0 6.70e-02    -  1.00e+00 1.00e+00f  1
   6  2.1849626e+03 4.28e-04 5.19e-01  -1.7 1.38e-02    -  9.64e-01 1.00e+00h  1
   7  2.1794127e+03 2.31e-03 2.33e-02  -1.7 4.15e-02    -  1.00e+00 1.00e+00f  1
   8  2.1786671e+03 6.12e-04 2.89e-01  -3.8 7.92e-03    -  8.46e-01 7.40e-01h  1
   9  2.1780966e+03 1.45e-04 3.04e-01  -3.8 4.14e-02    -  4.43e-01 9.69e-01h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  10  2.1780936e+03 6.98e-06 6.64e-04  -3.8 1.35e-02    -  1.00e+00 1.00e+00h  1
  11  2.1780803e+03 1.65e-06 9.75e-04  -5.7 4.57e-03    -  9.56e-01 9.45e-01h  1
  12  2.1780805e+03 1.82e-07 1.04e-05  -5.7 1.67e-03    -  1.00e+00 1.00e+00h  1
  13  2.1780804e+03 2.20e-09 2.92e-06  -8.6 1.68e-04    -  1.00e+00 9.98e-01h  1
  14  2.1780804e+03 1.10e-09 1.44e-05  -8.6 2.02e-06    -  1.00e+00 5.00e-01f  2
  15  2.1780804e+03 6.58e-14 3.97e-12  -8.6 1.01e-06    -  1.00e+00 1.00e+00h  1

Number of Iterations....: 15

                                   (scaled)                 (unscaled)
Objective...............:   9.3602396804143680e+01    2.1780804108196407e+03
Dual infeasibility......:   3.9701575360595598e-12    9.2383556964392718e-11
Constraint violation....:   6.5752958633424896e-14    6.5752958633424896e-14
Variable bound violation:   1.0340993394919451e-08    1.0340993394919451e-08
Complementarity.........:   2.5059040524323666e-09    5.8311119312650641e-08
Overall NLP error.......:   2.5059040524323666e-09    5.8311119312650641e-08

Number of objective function evaluations             = 18
Number of objective gradient evaluations             = 16
Number of equality constraint evaluations            = 18
Number of inequality constraint evaluations          = 18
Number of equality constraint Jacobian evaluations   = 16
Number of inequality constraint Jacobian evaluations = 16
Number of Lagrangian Hessian evaluations             = 15
Total seconds in IPOPT                               = 0.361

EXIT: Optimal Solution Found.

Summary
   case........: data/pglib_opf_case14_ieee.m
   variables...: 118
   constraints.: 169
   feasible....: true
   cost........: 2178
   total time..: 1.6498079299926758
     data time.: 0.006332874298095703
     build time: 1.1016969680786133
     solve time: 0.5417780876159668

Dict{String, Any} with 9 entries:
  "cost"        => 2178.08
  "variables"   => 118
  "constraints" => 169
  "case"        => "data/pglib_opf_case14_ieee.m"
  "time_total"  => 1.64981
  "time_build"  => 1.1017
  "time_solve"  => 0.541778
  "time_data"   => 0.00633287
  "feasible"    => true

julia> solve_opf("data/pglib_opf_case24_ieee_rts.m")
[info | PowerModels]: extending matpower format with data: areas 4x3
[info | PowerModels]: removing 1 cost terms from generator 1: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 29: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 2: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 6: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 25: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 5: [13000.0, 400.6849]
[info | PowerModels]: removing 3 cost terms from generator 15: Float64[]
[info | PowerModels]: removing 1 cost terms from generator 27: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 28: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 26: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 30: [0.1, 0.001]
[info | PowerModels]: updated generator 1 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 29 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 2 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 6 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 25 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 5 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 15 cost function with order 0 to a function of order 3: [0.0, 0.0, 0.0]
[info | PowerModels]: updated generator 27 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 28 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 26 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 30 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
This is Ipopt version 3.14.4, running with linear solver MUMPS 5.4.1.

Number of nonzeros in equality constraint Jacobian...:      979
Number of nonzeros in inequality constraint Jacobian.:      228
Number of nonzeros in Lagrangian Hessian.............:     1543

Total number of variables............................:      265
                     variables with only lower bounds:        0
                variables with lower and upper bounds:      241
                     variables with only upper bounds:        0
Total number of equality constraints.................:      201
Total number of inequality constraints...............:      114
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:       38
        inequality constraints with only upper bounds:       76

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  4.0097983e+04 2.52e+00 4.56e+01  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1  5.6173127e+04 1.56e+00 6.27e+01  -1.0 2.38e+00    -  1.00e-02 3.79e-01h  1
   2  5.3163863e+04 1.35e+00 5.42e+01  -1.0 6.42e+00    -  1.34e-02 1.39e-01f  1
   3  5.2197470e+04 1.33e+00 5.02e+01  -1.0 8.86e+00    -  3.43e-01 1.34e-02f  1
   4  5.3182708e+04 1.06e+00 3.73e+01  -1.0 7.58e+00    -  7.33e-01 2.03e-01h  1
   5  5.5138602e+04 3.87e-01 1.31e+01  -1.0 9.48e+00    -  9.74e-01 6.34e-01H  1
   6  5.4943501e+04 3.18e-01 1.19e+01  -1.0 1.03e+01    -  4.67e-01 1.79e-01f  1
   7  5.5363621e+04 2.73e-01 1.12e+01  -1.0 7.18e+00    -  1.00e+00 1.42e-01h  1
   8  5.5936174e+04 2.33e-01 6.61e+00  -1.0 3.08e+00    -  2.59e-01 1.44e-01h  1
   9  6.2387718e+04 6.41e-02 5.12e+00  -1.0 1.40e+00    -  6.92e-01 8.81e-01h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  10  6.3791569e+04 2.81e-03 8.66e-01  -1.0 1.80e+00    -  7.56e-01 1.00e+00h  1
  11  6.3501036e+04 8.45e-04 6.21e-01  -1.7 1.69e-01    -  8.51e-01 1.00e+00f  1
  12  6.3454929e+04 1.01e-03 1.25e-02  -1.7 1.02e-01    -  1.00e+00 1.00e+00h  1
  13  6.3378076e+04 8.53e-04 1.25e-01  -3.8 1.49e-01    -  8.03e-01 7.30e-01f  1
  14  6.3364846e+04 4.37e-04 2.13e+00  -3.8 2.00e-01    -  7.95e-01 5.13e-01h  1
  15  6.3352718e+04 1.22e-04 8.48e-02  -3.8 2.47e-01    -  1.00e+00 9.79e-01h  1
  16  6.3352941e+04 1.86e-06 2.89e-05  -3.8 9.06e-03    -  1.00e+00 1.00e+00h  1
  17  6.3352216e+04 3.36e-07 5.07e-04  -5.7 9.37e-03    -  9.90e-01 9.93e-01h  1
  18  6.3352210e+04 1.17e-09 2.51e-08  -5.7 1.81e-04    -  1.00e+00 1.00e+00h  1
  19  6.3352201e+04 5.65e-11 8.23e-10  -8.6 1.04e-04    -  1.00e+00 1.00e+00h  1

Number of Iterations....: 19

                                   (scaled)                 (unscaled)
Objective...............:   4.8732462373895538e+02    6.3352201086064197e+04
Dual infeasibility......:   8.2334011441596248e-10    1.0703421487407512e-07
Constraint violation....:   5.6515458979333744e-11    5.6515458979333744e-11
Variable bound violation:   3.9922449346363464e-08    3.9922449346363464e-08
Complementarity.........:   3.7502722384538056e-09    4.8753539099899472e-07
Overall NLP error.......:   3.7502722384538056e-09    4.8753539099899472e-07

Number of objective function evaluations             = 21
Number of objective gradient evaluations             = 20
Number of equality constraint evaluations            = 21
Number of inequality constraint evaluations          = 21
Number of equality constraint Jacobian evaluations   = 20
Number of inequality constraint Jacobian evaluations = 20
Number of Lagrangian Hessian evaluations             = 19
Total seconds in IPOPT                               = 2.706

EXIT: Optimal Solution Found.

Summary
   case........: data/pglib_opf_case24_ieee_rts.m
   variables...: 266
   constraints.: 315
   feasible....: true
   cost........: 63352
   total time..: 11.19380807876587
     data time.: 0.01564502716064453
     build time: 5.677052974700928
     solve time: 5.501110076904297

Dict{String, Any} with 9 entries:
  "cost"        => 63352.2
  "variables"   => 266
  "constraints" => 315
  "case"        => "data/pglib_opf_case24_ieee_rts.m"
  "time_total"  => 11.1938
  "time_build"  => 5.67705
  "time_solve"  => 5.50111
  "time_data"   => 0.015645
  "feasible"    => true

julia> solve_opf("data/pglib_opf_case24_ieee_rts.m")
[info | PowerModels]: extending matpower format with data: areas 4x3
[info | PowerModels]: removing 1 cost terms from generator 1: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 29: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 2: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 6: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 25: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 5: [13000.0, 400.6849]
[info | PowerModels]: removing 3 cost terms from generator 15: Float64[]
[info | PowerModels]: removing 1 cost terms from generator 27: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 28: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 26: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 30: [0.1, 0.001]
[info | PowerModels]: updated generator 1 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 29 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 2 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 6 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 25 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 5 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 15 cost function with order 0 to a function of order 3: [0.0, 0.0, 0.0]
[info | PowerModels]: updated generator 27 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 28 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 26 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 30 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
This is Ipopt version 3.14.4, running with linear solver MUMPS 5.4.1.

Number of nonzeros in equality constraint Jacobian...:      979
Number of nonzeros in inequality constraint Jacobian.:      228
Number of nonzeros in Lagrangian Hessian.............:     1543

Total number of variables............................:      265
                     variables with only lower bounds:        0
                variables with lower and upper bounds:      241
                     variables with only upper bounds:        0
Total number of equality constraints.................:      201
Total number of inequality constraints...............:      114
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:       38
        inequality constraints with only upper bounds:       76

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  4.0097983e+04 2.52e+00 4.56e+01  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1  5.6173127e+04 1.56e+00 6.27e+01  -1.0 2.38e+00    -  1.00e-02 3.79e-01h  1
   2  5.3163863e+04 1.35e+00 5.42e+01  -1.0 6.42e+00    -  1.34e-02 1.39e-01f  1
   3  5.2197470e+04 1.33e+00 5.02e+01  -1.0 8.86e+00    -  3.43e-01 1.34e-02f  1
   4  5.3182708e+04 1.06e+00 3.73e+01  -1.0 7.58e+00    -  7.33e-01 2.03e-01h  1
   5  5.5138602e+04 3.87e-01 1.31e+01  -1.0 9.48e+00    -  9.74e-01 6.34e-01H  1
   6  5.4943501e+04 3.18e-01 1.19e+01  -1.0 1.03e+01    -  4.67e-01 1.79e-01f  1
   7  5.5363621e+04 2.73e-01 1.12e+01  -1.0 7.18e+00    -  1.00e+00 1.42e-01h  1
   8  5.5936174e+04 2.33e-01 6.61e+00  -1.0 3.08e+00    -  2.59e-01 1.44e-01h  1
   9  6.2387718e+04 6.41e-02 5.12e+00  -1.0 1.40e+00    -  6.92e-01 8.81e-01h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  10  6.3791569e+04 2.81e-03 8.66e-01  -1.0 1.80e+00    -  7.56e-01 1.00e+00h  1
  11  6.3501036e+04 8.45e-04 6.21e-01  -1.7 1.69e-01    -  8.51e-01 1.00e+00f  1
  12  6.3454929e+04 1.01e-03 1.25e-02  -1.7 1.02e-01    -  1.00e+00 1.00e+00h  1
  13  6.3378076e+04 8.53e-04 1.25e-01  -3.8 1.49e-01    -  8.03e-01 7.30e-01f  1
  14  6.3364846e+04 4.37e-04 2.13e+00  -3.8 2.00e-01    -  7.95e-01 5.13e-01h  1
  15  6.3352718e+04 1.22e-04 8.48e-02  -3.8 2.47e-01    -  1.00e+00 9.79e-01h  1
  16  6.3352941e+04 1.86e-06 2.89e-05  -3.8 9.06e-03    -  1.00e+00 1.00e+00h  1
  17  6.3352216e+04 3.36e-07 5.07e-04  -5.7 9.37e-03    -  9.90e-01 9.93e-01h  1
  18  6.3352210e+04 1.17e-09 2.51e-08  -5.7 1.81e-04    -  1.00e+00 1.00e+00h  1
  19  6.3352201e+04 5.65e-11 8.23e-10  -8.6 1.04e-04    -  1.00e+00 1.00e+00h  1

Number of Iterations....: 19

                                   (scaled)                 (unscaled)
Objective...............:   4.8732462373895538e+02    6.3352201086064197e+04
Dual infeasibility......:   8.2334011441596248e-10    1.0703421487407512e-07
Constraint violation....:   5.6515458979333744e-11    5.6515458979333744e-11
Variable bound violation:   3.9922449346363464e-08    3.9922449346363464e-08
Complementarity.........:   3.7502722384538056e-09    4.8753539099899472e-07
Overall NLP error.......:   3.7502722384538056e-09    4.8753539099899472e-07

Number of objective function evaluations             = 21
Number of objective gradient evaluations             = 20
Number of equality constraint evaluations            = 21
Number of inequality constraint evaluations          = 21
Number of equality constraint Jacobian evaluations   = 20
Number of inequality constraint Jacobian evaluations = 20
Number of Lagrangian Hessian evaluations             = 19
Total seconds in IPOPT                               = 1.808

EXIT: Optimal Solution Found.

Summary
   case........: data/pglib_opf_case24_ieee_rts.m
   variables...: 266
   constraints.: 315
   feasible....: true
   cost........: 63352
   total time..: 7.0010809898376465
     data time.: 0.013874053955078125
     build time: 4.764988899230957
     solve time: 2.2222180366516113

Dict{String, Any} with 9 entries:
  "cost"        => 63352.2
  "variables"   => 266
  "constraints" => 315
  "case"        => "data/pglib_opf_case24_ieee_rts.m"
  "time_total"  => 7.00108
  "time_build"  => 4.76499
  "time_solve"  => 2.22222
  "time_data"   => 0.0138741
  "feasible"    => true

julia> solve_opf("data/pglib_opf_case73_ieee_rts.m")
[info | PowerModels]: extending matpower format with data: areas 3x3
[info | PowerModels]: removing 1 cost terms from generator 29: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 1: [13000.0, 400.6849]
[info | PowerModels]: removing 3 cost terms from generator 81: Float64[]
[info | PowerModels]: removing 1 cost terms from generator 2: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 27: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 28: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 63: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 92: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 93: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 26: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 58: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 25: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 59: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 5: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 62: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 39: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 34: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 94: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 71: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 6: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 96: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 91: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 60: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 35: [13000.0, 400.6849]
[info | PowerModels]: removing 3 cost terms from generator 15: Float64[]
[info | PowerModels]: removing 1 cost terms from generator 61: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 67: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 38: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 72: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 68: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 95: [0.1, 0.001]
[info | PowerModels]: removing 3 cost terms from generator 48: Float64[]
[info | PowerModels]: removing 1 cost terms from generator 30: [0.1, 0.001]
[info | PowerModels]: updated generator 29 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 1 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 81 cost function with order 0 to a function of order 3: [0.0, 0.0, 0.0]
[info | PowerModels]: updated generator 2 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 27 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 28 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 63 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 92 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 93 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 26 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 58 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 25 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 59 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 5 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 62 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 39 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 34 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 94 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 71 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 6 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 96 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 91 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 60 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 35 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 15 cost function with order 0 to a function of order 3: [0.0, 0.0, 0.0]
[info | PowerModels]: updated generator 61 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 67 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 38 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 72 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 68 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 95 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 48 cost function with order 0 to a function of order 3: [0.0, 0.0, 0.0]
[info | PowerModels]: updated generator 30 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
This is Ipopt version 3.14.4, running with linear solver MUMPS 5.4.1.

Number of nonzeros in equality constraint Jacobian...:     3079
Number of nonzeros in inequality constraint Jacobian.:      720
Number of nonzeros in Lagrangian Hessian.............:     4867

Total number of variables............................:      821
                     variables with only lower bounds:        0
                variables with lower and upper bounds:      748
                     variables with only upper bounds:        0
Total number of equality constraints.................:      627
Total number of inequality constraints...............:      360
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:      120
        inequality constraints with only upper bounds:      240

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  1.2029395e+05 2.52e+00 4.58e+01  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1  1.6840160e+05 1.57e+00 6.28e+01  -1.0 2.15e+00    -  9.96e-03 3.79e-01h  1
   2  1.5864026e+05 1.38e+00 5.54e+01  -1.0 5.37e+00    -  1.33e-02 1.21e-01f  1
   3  1.5548762e+05 1.36e+00 5.17e+01  -1.0 7.22e+00    -  3.52e-01 1.30e-02f  1
   4  1.5695972e+05 1.11e+00 4.06e+01  -1.0 6.22e+00    -  7.22e-01 1.83e-01h  1
   5  1.5887821e+05 6.95e-01 2.54e+01  -1.0 7.76e+00    -  3.89e-01 3.74e-01h  1
   6  1.5957584e+05 4.99e-01 2.10e+01  -1.0 9.38e+00    -  1.00e+00 2.82e-01h  1
   7  1.6281481e+05 3.69e-01 1.55e+01  -1.0 6.50e+00    -  3.44e-01 2.60e-01h  1
   8  1.6421530e+05 3.25e-01 1.22e+01  -1.0 5.49e+00    -  1.00e+00 1.19e-01h  1
   9  1.6633038e+05 2.66e-01 7.11e+00  -1.0 3.63e+00    -  5.00e-01 1.83e-01h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  10  1.7504336e+05 1.51e-01 1.06e+01  -1.0 2.44e+00    -  6.58e-02 4.32e-01h  1
  11  1.8861450e+05 6.25e-02 1.08e+01  -1.0 2.53e+00    -  2.74e-01 8.66e-01h  1
  12  1.9092062e+05 2.17e-02 3.46e+00  -1.0 1.11e+00    -  7.53e-01 1.00e+00h  1
  13  1.9108513e+05 3.84e-03 3.77e-01  -1.0 8.49e-01    -  1.00e+00 1.00e+00h  1
  14  1.9022312e+05 1.55e-03 4.99e-01  -1.7 2.53e-01    -  8.65e-01 1.00e+00f  1
  15  1.9008605e+05 1.06e-03 1.15e-02  -1.7 1.07e-01    -  1.00e+00 1.00e+00f  1
  16  1.8987249e+05 8.00e-04 3.18e-01  -3.8 1.55e-01    -  8.03e-01 6.68e-01f  1
  17  1.8982422e+05 5.39e-04 1.68e+00  -3.8 1.76e-01    -  8.21e-01 3.99e-01f  1
  18  1.8979502e+05 3.18e-04 2.71e+00  -3.8 2.56e-01    -  8.80e-01 4.71e-01h  1
  19  1.8976750e+05 9.31e-05 3.39e-01  -3.8 1.97e-01    -  1.00e+00 9.20e-01h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  20  1.8976634e+05 3.16e-06 4.97e-05  -3.8 1.13e-02    -  1.00e+00 1.00e+00h  1
  21  1.8976428e+05 8.44e-07 4.71e-02  -5.7 1.03e-02    -  9.81e-01 9.21e-01h  1
  22  1.8976410e+05 4.22e-08 9.88e-07  -5.7 9.91e-04    -  1.00e+00 1.00e+00h  1
  23  1.8976408e+05 3.98e-10 4.49e-07  -8.6 1.35e-04    -  1.00e+00 1.00e+00h  1
  24  1.8976408e+05 4.40e-14 1.74e-12  -8.6 6.22e-05    -  1.00e+00 1.00e+00f  1

Number of Iterations....: 24

                                   (scaled)                 (unscaled)
Objective...............:   1.4597236705182577e+03    1.8976407716737350e+05
Dual infeasibility......:   1.7397727349697582e-12    2.2617045554606857e-10
Constraint violation....:   4.4013404032483550e-14    4.4013404032483550e-14
Variable bound violation:   3.9923579997491743e-08    3.9923579997491743e-08
Complementarity.........:   2.5067203633389399e-09    3.2587364723406219e-07
Overall NLP error.......:   2.5067203633389399e-09    3.2587364723406219e-07

Number of objective function evaluations             = 25
Number of objective gradient evaluations             = 25
Number of equality constraint evaluations            = 25
Number of inequality constraint evaluations          = 25
Number of equality constraint Jacobian evaluations   = 25
Number of inequality constraint Jacobian evaluations = 25
Number of Lagrangian Hessian evaluations             = 24
Total seconds in IPOPT                               = 30.039

EXIT: Optimal Solution Found.

Summary
   case........: data/pglib_opf_case73_ieee_rts.m
   variables...: 824
   constraints.: 987
   feasible....: true
   cost........: 189764
   total time..: 90.27089595794678
     data time.: 0.03355002403259277
     build time: 51.00196886062622
     solve time: 39.235377073287964

Dict{String, Any} with 9 entries:
  "cost"        => 1.89764e5
  "variables"   => 824
  "constraints" => 987
  "case"        => "data/pglib_opf_case73_ieee_rts.m"
  "time_total"  => 90.2709
  "time_build"  => 51.002
  "time_solve"  => 39.2354
  "time_data"   => 0.03355
  "feasible"    => true

julia> solve_opf("data/pglib_opf_case73_ieee_rts.m")
[info | PowerModels]: extending matpower format with data: areas 3x3
[info | PowerModels]: removing 1 cost terms from generator 29: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 1: [13000.0, 400.6849]
[info | PowerModels]: removing 3 cost terms from generator 81: Float64[]
[info | PowerModels]: removing 1 cost terms from generator 2: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 27: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 28: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 63: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 92: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 93: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 26: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 58: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 25: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 59: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 5: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 62: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 39: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 34: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 94: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 71: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 6: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 96: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 91: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 60: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 35: [13000.0, 400.6849]
[info | PowerModels]: removing 3 cost terms from generator 15: Float64[]
[info | PowerModels]: removing 1 cost terms from generator 61: [0.1, 0.001]
[info | PowerModels]: removing 1 cost terms from generator 67: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 38: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 72: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 68: [13000.0, 400.6849]
[info | PowerModels]: removing 1 cost terms from generator 95: [0.1, 0.001]
[info | PowerModels]: removing 3 cost terms from generator 48: Float64[]
[info | PowerModels]: removing 1 cost terms from generator 30: [0.1, 0.001]
[info | PowerModels]: updated generator 29 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 1 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 81 cost function with order 0 to a function of order 3: [0.0, 0.0, 0.0]
[info | PowerModels]: updated generator 2 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 27 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 28 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 63 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 92 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 93 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 26 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 58 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 25 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 59 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 5 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 62 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 39 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 34 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 94 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 71 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 6 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 96 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 91 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 60 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 35 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 15 cost function with order 0 to a function of order 3: [0.0, 0.0, 0.0]
[info | PowerModels]: updated generator 61 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 67 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 38 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 72 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 68 cost function with order 2 to a function of order 3: [0.0, 13000.0, 400.6849]
[info | PowerModels]: updated generator 95 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
[info | PowerModels]: updated generator 48 cost function with order 0 to a function of order 3: [0.0, 0.0, 0.0]
[info | PowerModels]: updated generator 30 cost function with order 2 to a function of order 3: [0.0, 0.1, 0.001]
This is Ipopt version 3.14.4, running with linear solver MUMPS 5.4.1.

Number of nonzeros in equality constraint Jacobian...:     3079
Number of nonzeros in inequality constraint Jacobian.:      720
Number of nonzeros in Lagrangian Hessian.............:     4867

Total number of variables............................:      821
                     variables with only lower bounds:        0
                variables with lower and upper bounds:      748
                     variables with only upper bounds:        0
Total number of equality constraints.................:      627
Total number of inequality constraints...............:      360
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:      120
        inequality constraints with only upper bounds:      240

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  1.2029395e+05 2.52e+00 4.58e+01  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1  1.6840160e+05 1.57e+00 6.28e+01  -1.0 2.15e+00    -  9.96e-03 3.79e-01h  1
   2  1.5864026e+05 1.38e+00 5.54e+01  -1.0 5.37e+00    -  1.33e-02 1.21e-01f  1
   3  1.5548762e+05 1.36e+00 5.17e+01  -1.0 7.22e+00    -  3.52e-01 1.30e-02f  1
   4  1.5695972e+05 1.11e+00 4.06e+01  -1.0 6.22e+00    -  7.22e-01 1.83e-01h  1
   5  1.5887821e+05 6.95e-01 2.54e+01  -1.0 7.76e+00    -  3.89e-01 3.74e-01h  1
   6  1.5957584e+05 4.99e-01 2.10e+01  -1.0 9.38e+00    -  1.00e+00 2.82e-01h  1
   7  1.6281481e+05 3.69e-01 1.55e+01  -1.0 6.50e+00    -  3.44e-01 2.60e-01h  1
   8  1.6421530e+05 3.25e-01 1.22e+01  -1.0 5.49e+00    -  1.00e+00 1.19e-01h  1
   9  1.6633038e+05 2.66e-01 7.11e+00  -1.0 3.63e+00    -  5.00e-01 1.83e-01h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  10  1.7504336e+05 1.51e-01 1.06e+01  -1.0 2.44e+00    -  6.58e-02 4.32e-01h  1
  11  1.8861450e+05 6.25e-02 1.08e+01  -1.0 2.53e+00    -  2.74e-01 8.66e-01h  1
  12  1.9092062e+05 2.17e-02 3.46e+00  -1.0 1.11e+00    -  7.53e-01 1.00e+00h  1
  13  1.9108513e+05 3.84e-03 3.77e-01  -1.0 8.49e-01    -  1.00e+00 1.00e+00h  1
  14  1.9022312e+05 1.55e-03 4.99e-01  -1.7 2.53e-01    -  8.65e-01 1.00e+00f  1
  15  1.9008605e+05 1.06e-03 1.15e-02  -1.7 1.07e-01    -  1.00e+00 1.00e+00f  1
  16  1.8987249e+05 8.00e-04 3.18e-01  -3.8 1.55e-01    -  8.03e-01 6.68e-01f  1
  17  1.8982422e+05 5.39e-04 1.68e+00  -3.8 1.76e-01    -  8.21e-01 3.99e-01f  1
  18  1.8979502e+05 3.18e-04 2.71e+00  -3.8 2.56e-01    -  8.80e-01 4.71e-01h  1
  19  1.8976750e+05 9.31e-05 3.39e-01  -3.8 1.97e-01    -  1.00e+00 9.20e-01h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  20  1.8976634e+05 3.16e-06 4.97e-05  -3.8 1.13e-02    -  1.00e+00 1.00e+00h  1
  21  1.8976428e+05 8.44e-07 4.71e-02  -5.7 1.03e-02    -  9.81e-01 9.21e-01h  1
  22  1.8976410e+05 4.22e-08 9.88e-07  -5.7 9.91e-04    -  1.00e+00 1.00e+00h  1
  23  1.8976408e+05 3.98e-10 4.49e-07  -8.6 1.35e-04    -  1.00e+00 1.00e+00h  1
  24  1.8976408e+05 4.40e-14 1.74e-12  -8.6 6.22e-05    -  1.00e+00 1.00e+00f  1

Number of Iterations....: 24

                                   (scaled)                 (unscaled)
Objective...............:   1.4597236705182577e+03    1.8976407716737350e+05
Dual infeasibility......:   1.7397727349697582e-12    2.2617045554606857e-10
Constraint violation....:   4.4013404032483550e-14    4.4013404032483550e-14
Variable bound violation:   3.9923579997491743e-08    3.9923579997491743e-08
Complementarity.........:   2.5067203633389399e-09    3.2587364723406219e-07
Overall NLP error.......:   2.5067203633389399e-09    3.2587364723406219e-07

Number of objective function evaluations             = 25
Number of objective gradient evaluations             = 25
Number of equality constraint evaluations            = 25
Number of inequality constraint evaluations          = 25
Number of equality constraint Jacobian evaluations   = 25
Number of inequality constraint Jacobian evaluations = 25
Number of Lagrangian Hessian evaluations             = 24
Total seconds in IPOPT                               = 24.536

EXIT: Optimal Solution Found.

Summary
   case........: data/pglib_opf_case73_ieee_rts.m
   variables...: 824
   constraints.: 987
   feasible....: true
   cost........: 189764
   total time..: 86.7517478466034
     data time.: 0.05579996109008789
     build time: 56.65961289405823
     solve time: 30.036334991455078

Dict{String, Any} with 9 entries:
  "cost"        => 1.89764e5
  "variables"   => 824
  "constraints" => 987
  "case"        => "data/pglib_opf_case73_ieee_rts.m"
  "time_total"  => 86.7517
  "time_build"  => 56.6596
  "time_solve"  => 30.0363
  "time_data"   => 0.0558
  "feasible"    => true
odow commented 8 months ago

I tried a few other options for adchoice

Optimization.AutoEnzyme()

This is Ipopt version 3.14.4, running with linear solver MUMPS 5.4.1.

Number of nonzeros in equality constraint Jacobian...:     1540
Number of nonzeros in inequality constraint Jacobian.:      792
Number of nonzeros in Lagrangian Hessian.............:      990

ERROR: Function to differentiate `MethodInstance for OptimizationEnzymeExt.firstapply(::var"#opf_objective#91"{Dict{Int64, Vector{Float64}}, Dict{Int64, Int64}, Vector{Int64}}, ::Vector{Float64}, ::Nothing, ::SciMLBase.NullParameters)` is guaranteed to return an error and doesn't make sense to autodiff. Giving up
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] macro expansion
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/Dd2LU/src/compiler.jl:5421 [inlined]
  [3] macro expansion
    @ Enzyme.Compiler ./none:0 [inlined]
  [4] thunk(::Val{…}, ::Type{…}, ::Type{…}, tt::Type{…}, ::Val{…}, ::Val{…}, ::Val{…}, ::Val{…}, ::Val{…}, ::Type{…})
    @ Enzyme.Compiler ./none:0
  [5] autodiff
    @ ~/.julia/packages/Enzyme/Dd2LU/src/Enzyme.jl:197 [inlined]
  [6] (::OptimizationEnzymeExt.var"#1#17"{…})(res::Vector{…}, θ::Vector{…}, args::SciMLBase.NullParameters)
    @ OptimizationEnzymeExt ~/.julia/packages/Optimization/3a8IF/ext/OptimizationEnzymeExt.jl:25
  [7] (::OptimizationEnzymeExt.var"#36#51"{…})(::Vector{…}, ::Vector{…})
    @ OptimizationEnzymeExt ~/.julia/packages/Optimization/3a8IF/ext/OptimizationEnzymeExt.jl:174
  [8] eval_objective_gradient(evaluator::OptimizationMOI.MOIOptimizationNLPEvaluator{…}, G::Vector{…}, x::Vector{…})
    @ OptimizationMOI ~/.julia/packages/OptimizationMOI/t2Upn/src/nlp.jl:252
  [9] eval_objective_gradient(model::Ipopt.Optimizer, grad::Vector{Float64}, x::Vector{Float64})
    @ Ipopt ~/.julia/packages/Ipopt/oNDpH/src/MOI_wrapper.jl:707
 [10] (::Ipopt.var"#eval_grad_f_cb#4"{Ipopt.Optimizer})(x::Vector{Float64}, grad_f::Vector{Float64})
    @ Ipopt ~/.julia/packages/Ipopt/oNDpH/src/MOI_wrapper.jl:809
 [11] _Eval_Grad_F_CB(n::Int32, x_ptr::Ptr{Float64}, ::Int32, grad_f::Ptr{Float64}, user_data::Ptr{Nothing})
    @ Ipopt ~/.julia/packages/Ipopt/oNDpH/src/C_wrapper.jl:54
 [12] IpoptSolve(prob::Ipopt.IpoptProblem)

Optimization.AutoSparseReverseDiff(false)

This is Ipopt version 3.14.4, running with linear solver MUMPS 5.4.1.

Number of nonzeros in equality constraint Jacobian...:      155
Number of nonzeros in inequality constraint Jacobian.:       36
Number of nonzeros in Lagrangian Hessian.............:      240

ERROR: MethodError: no method matching (::var"#opf_objective#91"{…})(::ReverseDiff.TrackedArray{…}, ::Nothing, ::SciMLBase.NullParameters)
An arithmetic operation was performed on a NullParameters object. This means no parameters were passed
into the AbstractSciMLProblem (e.x.: ODEProblem) but the parameters object `p` was used in an arithmetic
expression. Two common reasons for this issue are:

1. Forgetting to pass parameters into the problem constructor. For example, `ODEProblem(f,u0,tspan)` should
be `ODEProblem(f,u0,tspan,p)` in order to use parameters.

2. Using the wrong function signature. For example, with `ODEProblem`s the function signature is always
`f(du,u,p,t)` for the in-place form or `f(u,p,t)` for the out-of-place form. Note that the `p` argument
will always be in the function signature regardless of if the problem is defined with parameters!

Closest candidates are:
  (::var"#opf_objective#91")(::Any, ::Any)
   @ Main ~/Documents/lanl-ansi/rosetta-opf/optimization2.jl:290

Stacktrace:
  [1] (::OptimizationSparseDiffExt.var"#155#183"{…})(θ::ReverseDiff.TrackedArray{…}, args::SciMLBase.NullParameters)
    @ OptimizationSparseDiffExt ~/.julia/packages/Optimization/3a8IF/ext/OptimizationSparseDiffExt.jl:498
  [2] (::OptimizationSparseDiffExt.var"#158#186"{…})(x::ReverseDiff.TrackedArray{…})
    @ OptimizationSparseDiffExt ~/.julia/packages/Optimization/3a8IF/ext/OptimizationSparseDiffExt.jl:512
  [3] ReverseDiff.GradientTape(f::OptimizationSparseDiffExt.var"#158#186"{…}, input::Vector{…}, cfg::ReverseDiff.GradientConfig{…})
    @ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/api/tape.jl:199
  [4] gradient!(result::Vector{…}, f::Function, input::Vector{…}, cfg::ReverseDiff.GradientConfig{…})
    @ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/api/gradients.jl:41
  [5] (::OptimizationSparseDiffExt.var"#157#185"{…})(res::Vector{…}, θ::Vector{…}, args::SciMLBase.NullParameters)
    @ OptimizationSparseDiffExt ~/.julia/packages/Optimization/3a8IF/ext/OptimizationSparseDiffExt.jl:511
  [6] (::OptimizationSparseDiffExt.var"#217#245"{…})(::Vector{…}, ::Vector{…})
    @ OptimizationSparseDiffExt ~/.julia/packages/Optimization/3a8IF/ext/OptimizationSparseDiffExt.jl:691
  [7] eval_objective_gradient(evaluator::OptimizationMOI.MOIOptimizationNLPEvaluator{…}, G::Vector{…}, x::Vector{…})
    @ OptimizationMOI ~/.julia/packages/OptimizationMOI/t2Upn/src/nlp.jl:252
  [8] eval_objective_gradient(model::Ipopt.Optimizer, grad::Vector{Float64}, x::Vector{Float64})
    @ Ipopt ~/.julia/packages/Ipopt/oNDpH/src/MOI_wrapper.jl:707
  [9] (::Ipopt.var"#eval_grad_f_cb#4"{Ipopt.Optimizer})(x::Vector{Float64}, grad_f::Vector{Float64})
    @ Ipopt ~/.julia/packages/Ipopt/oNDpH/src/MOI_wrapper.jl:809
 [10] _Eval_Grad_F_CB(n::Int32, x_ptr::Ptr{Float64}, ::Int32, grad_f::Ptr{Float64}, user_data::Ptr{Nothing})
    @ Ipopt ~/.julia/packages/Ipopt/oNDpH/src/C_wrapper.jl:54
 [11] IpoptSolve(prob::Ipopt.IpoptProblem)
    @ Ipopt ~/.julia/packages/Ipopt/oNDpH/src/C_wrapper.jl:442
 [12] optimize!(model::Ipopt.Optimizer)
    @ Ipopt ~/.julia/packages/Ipopt/oNDpH/src/MOI_wrapper.jl:951
Vaibhavdixit02 commented 8 months ago

Yeah AutoSparseReverseDiff(true) should be best here

odow commented 8 months ago

I think it's worth pointing out that my numbers pretty closely match the SciML table.

I get

Summary
   case........: data/pglib_opf_case24_ieee_rts.m
   variables...: 266
   constraints.: 315
   feasible....: true
   cost........: 63352
   total time..: 7.0010809898376465
     data time.: 0.013874053955078125
     build time: 4.764988899230957
     solve time: 2.2222180366516113

compared to:

image

So call it 7 seconds.

@ccoffin's post was 17 seconds so this is a nice win.

image
ccoffrin commented 8 months ago

@Vaibhavdixit02, thank you very much with your help with this.

In this implementation can you tell me how I can pass a solver parameter to Ipopt? I would like to set Ipopt's solver parameter "linear_solver" to the value "ma27". Here are examples of how this is done in JuMP and NLPModels.

ccoffrin commented 8 months ago

Here are some preliminary tests of "total solve time" (seconds) that I want to make a note of. Each one of these blocks represents a separate Julia session. You can see that doing a pre-compile run on "case5" is not sufficient to get the maximum performance on a not yet seen case "case14".

Workflow 1

include("optimization2.jl")
solve_opf("pglib_opf_case5_pjm.m") -> 32.43
solve_opf("pglib_opf_case5_pjm.m") ->  0.2571

Workflow 2

include("optimization2.jl")
solve_opf("pglib_opf_case5_pjm.m") -> 32.27
solve_opf("pglib_opf_case14_ieee.m") -> 6.887
solve_opf("pglib_opf_case14_ieee.m") -> 1.768

Workflow 3

include("optimization2.jl")
solve_opf("pglib_opf_case14_ieee.m") -> 33.76
solve_opf("pglib_opf_case14_ieee.m") -> 1.751

When I collect data rosseta-opf table I try to remove the bulk of compile time overheads using "case5" as a typical example case. Which is effectively running this,

include("<def solve_opf>")
solve_opf("pglib_opf_case5_pjm.m")
solve_opf("<new case file>")

So in the case of case14_ieee my table would report a runtime of around 6.8 seconds and not 1.7. This could be a source of some observed discrepancies in reported runtimes.

odow commented 8 months ago

Yes, that's a source of the discrepancy.

But I also think it's reasonable to include. We don't want to have to solve a large problem twice just so that it is faster on the second solve. If every input data file needs separate precompilation, then that seems like a reasonable thing to measure.

The only one it's not "fair" for is case5. I wonder if we could use case3 instead for that one?

ccoffrin commented 8 months ago

I agree, if some code has instance-by-instance compilation this too should be captured in the "total runtime". However, it does have me wondering if a more comprehensive example than case5 could be designed for the pre-compilation step.

Spot checking one larger case, it seems like this effect is less dramatic on larger instances,

include("optimization2.jl")
solve_opf("pglib_opf_case5_pjm.m") -> 33.46
solve_opf("pglib_opf_case118_ieee.m") -> 213.6 (126 build, 86 solve)
solve_opf("pglib_opf_case118_ieee.m") -> 208.7 (132 build, 76 solve)

It may even be the case that the offset is a constant of 5 seconds regardless of system size.

odow commented 8 months ago

That also makes sense. What about using case3 and then just not reporting the first row of the table?

Alternatively, do no precompilation and measure the full time. It should be up to the modeling packages to provide an interface that deals with precompilation, not the user.

ccoffrin commented 8 months ago

I agree with you that modeling packages should provide an interface that deals with pre-compilation. But I don't expect (or want) that such a package specializes on the specific model structure that occurs in AC-OPF out of the box.

This pre-compilation step is attempting to model a deployment scenario where I would use some of Julia's package compiler tools to build the compiled Julia code that is specialized to some specific representative workflows and save those into the system image for faster performance at runtime.

For this package I will design a new network model with 3-4 buses that is specifically tailored to this use-case. I hope that will mitigate any performance artifacts from using one of the benchmark instances for the pre-compilation workflow.

ccoffrin commented 8 months ago

Waiting on https://github.com/odow/MathOptSymbolicAD.jl/pull/27 so that the variants Project.toml can be setup in a way that this compatible with this optimization.jl implementation and jump-sad.jl at the same time.

ccoffrin commented 8 months ago

Updates to MathOptSymbolicAD appear to have work. Thanks @odow!

This is ready for merging. Will pick up with next steps tomorrow.