Performance tips

The package ADNLPModels.jl is designed to easily model optimization problems andto allow an efficient access to the NLPModel API. In this tutorial, we will see some tips to ensure the maximum performance of the model.

Use in-place constructor

When dealing with a constrained optimization problem, it is recommended to use in-place constraint functions.

using ADNLPModels, NLPModels
f(x) = sum(x)
x0 = ones(2)
lcon = ucon = ones(1)
c_out(x) = [x[1]]
nlp_out = ADNLPModel(f, x0, c_out, lcon, ucon)

c_in(cx, x) = begin
  cx[1] = x[1]
  return cx
end
nlp_in = ADNLPModel!(f, x0, c_in, lcon, ucon)
ADNLPModel - Model with automatic differentiation backend ADModelBackend{
  ForwardDiffADGradient,
  ForwardDiffADHvprod,
  ForwardDiffADJprod,
  ForwardDiffADJtprod,
  ForwardDiffADJacobian,
  ForwardDiffADHessian,
  ForwardDiffADGHjvprod,
}
  Problem name: Generic
   All variables: ████████████████████ 2      All constraints: ████████████████████ 1     
            free: ████████████████████ 2                 free: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           lower: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                lower: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           upper: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                upper: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
         low/upp: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0              low/upp: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           fixed: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                fixed: ████████████████████ 1     
          infeas: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0               infeas: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
            nnzh: (  0.00% sparsity)   3               linear: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
                                                    nonlinear: ████████████████████ 1     
                                                         nnzj: (  0.00% sparsity)   2     

  Counters:
             obj: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 grad: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 cons: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
        cons_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0             cons_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 jcon: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           jgrad: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                  jac: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0              jac_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
         jac_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                jprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0            jprod_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
       jprod_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0               jtprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0           jtprod_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
      jtprod_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 hess: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                hprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           jhess: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0               jhprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
using BenchmarkTools
cx = rand(1)
x = 18 * ones(2)
@btime cons!(nlp_out, x, cx)
1-element Vector{Float64}:
 18.0
@btime cons!(nlp_in, x, cx)
1-element Vector{Float64}:
 18.0

The difference between the two increases with the dimension.

Note that the same applies to nonlinear least squares problems.

F(x) = [
    x[1];
    x[1] + x[2]^2;
    sin(x[2]);
    exp(x[1] + 0.5)
]
x0 = ones(2)
nequ = 4
nls_out = ADNLSModel(F, x0, nequ)

F!(Fx, x) = begin
  Fx[1] = x[1]
  Fx[2] = x[1] + x[2]^2
  Fx[3] = sin(x[2])
  Fx[4] = exp(x[1] + 0.5)
  return Fx
end
nls_in = ADNLSModel!(F!, x0, nequ)
ADNLSModel - Nonlinear least-squares model with automatic differentiation backend ADModelBackend{
  ForwardDiffADGradient,
  ForwardDiffADHvprod,
  EmptyADbackend,
  EmptyADbackend,
  EmptyADbackend,
  ForwardDiffADHessian,
  EmptyADbackend,
  ForwardDiffADHvprod,
  ForwardDiffADJprod,
  ForwardDiffADJtprod,
  ForwardDiffADJacobian,
  ForwardDiffADHessian,
}
  Problem name: Generic
   All variables: ████████████████████ 2      All constraints: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0        All residuals: ████████████████████ 4     
            free: ████████████████████ 2                 free: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0               linear: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           lower: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                lower: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0            nonlinear: ████████████████████ 4     
           upper: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                upper: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 nnzj: (  0.00% sparsity)   8     
         low/upp: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0              low/upp: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 nnzh: (  0.00% sparsity)   3     
           fixed: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                fixed: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
          infeas: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0               infeas: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
            nnzh: (  0.00% sparsity)   3               linear: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
                                                    nonlinear: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
                                                         nnzj: (------% sparsity)         

  Counters:
             obj: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 grad: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 cons: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
        cons_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0             cons_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 jcon: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           jgrad: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                  jac: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0              jac_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
         jac_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                jprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0            jprod_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
       jprod_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0               jtprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0           jtprod_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
      jtprod_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 hess: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                hprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           jhess: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0               jhprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0             residual: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
    jac_residual: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0       jprod_residual: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0      jtprod_residual: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
   hess_residual: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0       jhess_residual: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0       hprod_residual: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
Fx = rand(4)
@btime residual!(nls_out, x, Fx)
4-element Vector{Float64}:
  18.0
 342.0
  -0.7509872467716762
   1.0825498775023076e8
@btime residual!(nls_in, x, Fx)
4-element Vector{Float64}:
  18.0
 342.0
  -0.7509872467716762
   1.0825498775023076e8

This phenomenon also extends to related backends.

Fx = rand(4)
v = ones(2)
@btime jprod_residual!(nls_out, x, v, Fx)
4-element Vector{Float64}:
  1.0
 37.0
  0.6603167082440802
  1.0825498775023076e8
@btime jprod_residual!(nls_in, x, v, Fx)
4-element Vector{Float64}:
  1.0
 37.0
  0.6603167082440802
  1.0825498775023076e8

Use only the needed operations

It is tempting to define the most generic and efficient ADNLPModel from the start.

using ADNLPModels, NLPModels, Symbolics
f(x) = (x[1] - x[2])^2
x0 = ones(2)
lcon = ucon = ones(1)
c_in(cx, x) = begin
  cx[1] = x[1]
  return cx
end
nlp = ADNLPModel!(f, x0, c_in, lcon, ucon, show_time = true)
ADNLPModel - Model with automatic differentiation backend ADModelBackend{
  ForwardDiffADGradient,
  ForwardDiffADHvprod,
  ForwardDiffADJprod,
  ForwardDiffADJtprod,
  SparseADJacobian,
  SparseADHessian,
  ForwardDiffADGHjvprod,
}
  Problem name: Generic
   All variables: ████████████████████ 2      All constraints: ████████████████████ 1     
            free: ████████████████████ 2                 free: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           lower: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                lower: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           upper: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                upper: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
         low/upp: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0              low/upp: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           fixed: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                fixed: ████████████████████ 1     
          infeas: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0               infeas: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
            nnzh: (  0.00% sparsity)   3               linear: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
                                                    nonlinear: ████████████████████ 1     
                                                         nnzj: ( 50.00% sparsity)   1     

  Counters:
             obj: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 grad: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 cons: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
        cons_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0             cons_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 jcon: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           jgrad: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                  jac: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0              jac_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
         jac_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                jprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0            jprod_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
       jprod_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0               jtprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0           jtprod_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
      jtprod_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 hess: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                hprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           jhess: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0               jhprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     

However, depending on the size of the problem this might time consuming as initializing each backend takes time. Besides, some solvers may not require all the API to solve the problem. For instance, Percival.jl is matrix-free solver in the sense that it only uses jprod, jtprod and hprod.

using Percival
stats = percival(nlp)
"Execution stats: first-order stationary"
nlp.counters
  Counters:
             obj: ████████████████████ 1                 grad: ████████████████████ 1                 cons: ████████████████████ 1     
        cons_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0             cons_nln: ████████████████████ 1                 jcon: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           jgrad: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                  jac: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0              jac_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
         jac_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                jprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0            jprod_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
       jprod_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0               jtprod: ████████████████████ 1           jtprod_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
      jtprod_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 hess: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                hprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           jhess: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0               jhprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     

Therefore, it is more efficient to avoid preparing Jacobian and Hessian backends in this case.

nlp = ADNLPModel!(f, x0, c_in, lcon, ucon, jacobian_backend = ADNLPModels.EmptyADbackend, hessian_backend = ADNLPModels.EmptyADbackend, show_time = true)
ADNLPModel - Model with automatic differentiation backend ADModelBackend{
  ForwardDiffADGradient,
  ForwardDiffADHvprod,
  ForwardDiffADJprod,
  ForwardDiffADJtprod,
  EmptyADbackend,
  EmptyADbackend,
  ForwardDiffADGHjvprod,
}
  Problem name: Generic
   All variables: ████████████████████ 2      All constraints: ████████████████████ 1     
            free: ████████████████████ 2                 free: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           lower: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                lower: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           upper: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                upper: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
         low/upp: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0              low/upp: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           fixed: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                fixed: ████████████████████ 1     
          infeas: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0               infeas: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
            nnzh: (  0.00% sparsity)   3               linear: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
                                                    nonlinear: ████████████████████ 1     
                                                         nnzj: (  0.00% sparsity)   2     

  Counters:
             obj: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 grad: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 cons: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
        cons_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0             cons_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 jcon: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           jgrad: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                  jac: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0              jac_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
         jac_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                jprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0            jprod_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
       jprod_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0               jtprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0           jtprod_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
      jtprod_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 hess: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                hprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           jhess: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0               jhprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     

or, equivalently, using the matrix_free keyword argument

nlp = ADNLPModel!(f, x0, c_in, lcon, ucon, show_time = true, matrix_free = true)
ADNLPModel - Model with automatic differentiation backend ADModelBackend{
  ForwardDiffADGradient,
  ForwardDiffADHvprod,
  ForwardDiffADJprod,
  ForwardDiffADJtprod,
  EmptyADbackend,
  EmptyADbackend,
  ForwardDiffADGHjvprod,
}
  Problem name: Generic
   All variables: ████████████████████ 2      All constraints: ████████████████████ 1     
            free: ████████████████████ 2                 free: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           lower: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                lower: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           upper: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                upper: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
         low/upp: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0              low/upp: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           fixed: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                fixed: ████████████████████ 1     
          infeas: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0               infeas: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
            nnzh: (  0.00% sparsity)   3               linear: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
                                                    nonlinear: ████████████████████ 1     
                                                         nnzj: (  0.00% sparsity)   2     

  Counters:
             obj: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 grad: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 cons: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
        cons_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0             cons_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 jcon: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           jgrad: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                  jac: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0              jac_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
         jac_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                jprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0            jprod_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
       jprod_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0               jtprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0           jtprod_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
      jtprod_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 hess: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                hprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     
           jhess: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0               jhprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0     

Benchmarks

This package implements several backends for each method and it is possible to design your own backend as well. Then, one way to choose the most efficient one is to run benchmarks.

using ADNLPModels, NLPModels, OptimizationProblems
WARNING: method definition for #DataFrame#195 at /juliateam/.julia/packages/DataFrames/JZ7x5/src/dataframe/dataframe.jl:397 declares type variable T but does not use it.
WARNING: method definition for col_ordering at /juliateam/.julia/packages/DataFrames/JZ7x5/src/abstractdataframe/sort.jl:145 declares type variable O but does not use it.

The package OptimizationProblems.jl provides a collection of optimization problems in JuMP and ADNLPModels syntax.

meta = OptimizationProblems.meta;

372 rows × 17 columns

nvarvariable_nvarnconvariable_nconminimizenamehas_equalities_onlyhas_inequalities_onlyhas_boundshas_fixed_variablesobjtypecontypebest_known_lower_boundbest_known_upper_boundis_feasibledefined_everywhereorigin
Int64BoolInt64BoolBoolStringBoolBoolBoolBoolSymbolSymbolRealRealBool?Bool?Symbol
110001AMPGO020000otherunconstrained-Inf0.8394981missingunknown
210001AMPGO030000otherunconstrained-Inf2.889611missingunknown
310001AMPGO040000otherunconstrained-Inf-2.56661missingunknown
410001AMPGO050000otherunconstrained-Inf-0.01missingunknown
510001AMPGO060000otherunconstrained-Inf3.5177e-431missingunknown
610001AMPGO070000otherunconstrained-Inf2.564751missingunknown
710001AMPGO080000otherunconstrained-Inf-2.09281missingunknown
810001AMPGO090000otherunconstrained-Inf0.9211361missingunknown
910001AMPGO100000otherunconstrained-Inf-0.01missingunknown
1010001AMPGO110000otherunconstrained-Inf-1.01missingunknown
1110001AMPGO120000otherunconstrained-Inf1.01missingunknown
1210001AMPGO130000otherunconstrained-1.5874-1.58741missingunknown
1310001AMPGO140000otherunconstrained-Inf-0.01missingunknown
1410001AMPGO150000otherunconstrained-Inf2.153851missingunknown
1510001AMPGO180000otherunconstrained-Inf4.01missingunknown
1610001AMPGO200000otherunconstrained-Inf3.92246e-431missingunknown
1710001AMPGO210000otherunconstrained-Inf0.01missingunknown
1810001AMPGO220000otherunconstrained-Inf1.01missingunknown
1930101BOX21000otherlinear-Inf0.9422841missingunknown
2030001BOX30000otherunconstrained-Inf662.8681missingunknown
2110001Dus2_10000otherunconstrained-Inf7.389061missingunknown
2210001Dus2_30000otherunconstrained-Inf0.9729731missingunknown
2310001Dus2_90000otherunconstrained-Inf1.01missingunknown
2410001Duscube0000otherunconstrained-Inf-108.01missingunknown
25911001NZF10000otherunconstrained-Inf34698.41missingunknown
2610001Shpak10000otherunconstrained-Inf0.8394981missingunknown
2710001Shpak20000otherunconstrained-Inf-0.7470361missingunknown
2810001Shpak30000otherunconstrained-Inf2.630551missingunknown
2910001Shpak40000otherunconstrained-Inf-0.6774391missingunknown
3010001Shpak50000otherunconstrained-Inf-1.008421missingunknown
3110001Shpak60000otherunconstrained-Inf-1.256671missingunknown
3280501aircrfta1011othergeneral-Inf01missingunknown
3340301allinit0000othergeneral-InfInfmissingmissingunknown
3440401allinitc0000othergeneral-InfInfmissingmissingunknown
3540001allinitu0000otherunconstrained-Inf13.01missingunknown
3620301alsotame0000othergeneral-InfInfmissingmissingunknown
37301501argauss1000othergeneral-InfInfmissingmissingunknown
381001001arglina0000least_squaresunconstrained-Inf500.01missingunknown
391001001arglinb0000least_squaresunconstrained-Inf6.85174e131missingunknown
401001001arglinc0000otherunconstrained-Inf6.38544e131missingunknown
411001001argtrig0000otherunconstrained-Inf0.01missingunknown
421001001arwhead0000otherunconstrained-Inf297.01missingunknown
434901501avion21010othergeneral-InfInfmissingmissingunknown
4430001bard0000least_squaresunconstrained-Inf500.01missingunknown
451001001bdqrtic0000least_squaresunconstrained-Inf21696.01missingunknown
4620001beale0000least_squaresunconstrained-Inf14.20311missingunknown
471001001bearing0011otherunconstrained-Inf15.06621missingunknown
4830001bennett50000least_squaresunconstrained-Inf500.01missingunknown
4960001biggs50011otherunconstrained-Inf-3.156211missingunknown
5060001biggs60000otherunconstrained-Inf-3.156211missingunknown
5120201booth1000othergeneral-InfInfmissingmissingunknown
5220001boxbod0000least_squaresunconstrained-Inf500.01missingunknown
5310101bqp1var0100othergeneral-Inf0.31251missingunknown
54450036001britgas1010othergeneral-InfInfmissingmissingunknown
551001001brownal0000least_squaresunconstrained-Inf0.01missingunknown
5620001brownbs0000least_squaresunconstrained-Inf9.99998e111missingunknown
5740001brownden0000least_squaresunconstrained-Inf7.92669e61missingunknown
581001001broyden3d0000least_squaresunconstrained-Inf0.01missingunknown
591001001broydn7d0000otherunconstrained-Inf274.2041missingunknown
601001001brybnd0000least_squaresunconstrained-Inf3600.01missingunknown
6120101bt11000othergeneral-InfInfmissingmissingunknown
62100120311camshape0110othergeneral-InfInfmissingmissingunknown
639913211catenary1011linearquadratic-InfInfmissingmissingacademic
6410017711chain1000othergeneral-InfInfmissingmissingunknown
651001001chainwoo0000otherunconstrained-Inf3.71954e51missingunknown
669619611channel1000othergeneral-InfInfmissingmissingunknown
671001001chnrosnb_mod0000otherunconstrained-Inf17637.91missingunknown
6830001chwirut10000least_squaresunconstrained-Inf500.01missingunknown
6930001chwirut20000least_squaresunconstrained-Inf500.01missingunknown
7020001cliff0000otherunconstrained-Inf4.85165e81missingunknown
719916411clnlbeam1010othergeneral-Inf350.01missingunknown
721001001clplatea0000otherunconstrained-Inf0.01missingunknown
731001001clplateb0000otherunconstrained-Inf0.01missingunknown
741001001clplatec0000otherunconstrained-Inf0.01missingunknown
7510015011controlinvestment1010othergeneral-Inf-0.981missingunknown
761001001cosine0000otherunconstrained-Inf86.88071missingunknown
771001001cragglvy0000otherunconstrained-Inf52823.11missingunknown
781001001cragglvy20000otherunconstrained-Inf52823.11missingunknown
791001001curly0000otherunconstrained-Inf-0.006237221missingunknown
801001001curly100000otherunconstrained-Inf-0.006237221missingunknown
811001001curly200000otherunconstrained-Inf-0.01296541missingunknown
821001001curly300000otherunconstrained-Inf-0.0203831missingunknown
8320001danwood0000least_squaresunconstrained-Inf500.01missingunknown
84991001dixmaane0000otherunconstrained-Inf731.8331missingunknown
85991001dixmaanf0000otherunconstrained-Inf1348.421missingunknown
86991001dixmaang0000otherunconstrained-Inf2495.831missingunknown
87991001dixmaanh0000otherunconstrained-Inf4974.251missingunknown
88991001dixmaani0000otherunconstrained-Inf663.6461missingunknown
89991001dixmaanj0000otherunconstrained-Inf1281.331missingunknown
90991001dixmaank0000otherunconstrained-Inf2427.651missingunknown
91991001dixmaanl0000otherunconstrained-Inf4903.71missingunknown
92991001dixmaanm0000otherunconstrained-Inf314.3131missingunknown
93991001dixmaann0000otherunconstrained-Inf665.661missingunknown
94991001dixmaano0000otherunconstrained-Inf1196.311missingunknown
95991001dixmaanp0000otherunconstrained-Inf2342.521missingunknown
961001001dixon3dq0000least_squaresunconstrained-Inf8.01missingunknown
971001001dqdrtic0000otherunconstrained-Inf177282.01missingunknown
981001001dqrtic0000otherunconstrained-Inf1.85427e91missingunknown
9930001eckerle40000least_squaresunconstrained-Inf500.01missingunknown
1001001001edensch0000otherunconstrained-Inf1699.01missingunknown
1011001001eg20000otherunconstrained-Inf-83.30561missingunknown
1029913311elec1000otherquadratic-InfInfmissingmissingunknown
1031001001engval10000otherunconstrained-Inf5841.01missingunknown
10490001enso0000least_squaresunconstrained-Inf500.01missingunknown
1051001001errinros_mod0000least_squaresunconstrained-Inf3.13991e51missingunknown
1061001001extrosnb0000otherunconstrained-Inf39604.01missingunknown
1071001001fletcbv20000otherunconstrained-Inf-0.5131081missingunknown
1081001001fletcbv3_mod0000otherunconstrained-Inf-0.01879251missingunknown
1091001001fletchcr0000otherunconstrained-Inf9900.01missingunknown
1101000001fminsrf20000otherunconstrained-Inf2504.271missingunknown
1111001001freuroth0000least_squaresunconstrained-Inf99556.51missingunknown
11280001gauss10000least_squaresunconstrained-Inf500.01missingunknown
11380001gauss20000least_squaresunconstrained-Inf500.01missingunknown
11480001gauss30000least_squaresunconstrained-Inf500.01missingunknown
11530001gaussian0000least_squaresunconstrained-Inf3.88811e-61missingunknown
1161001001genhumps0000otherunconstrained-Inf2.53684e61missingunknown
1171001001genrose0000otherunconstrained-Inf405.1061missingunknown
1181001001genrose_nash0000otherunconstrained-Inf404.1261missingunknown
11930001gulf0000least_squaresunconstrained-Inf0.01missingunknown
12070001hahn10000least_squaresunconstrained-Inf500.01missingunknown
12130001helical0000otherunconstrained-Inf0.01missingunknown
1229816811hovercraft1d1000least_squareslinear-InfInfmissingmissingunknown
12320001hs10010otherunconstrained-Inf909.01missingunknown
12420101hs100100othergeneral-InfInfmissingmissingunknown
12570401hs1000100othergeneral-Inf714.01missingunknown
12670501hs1010110othergeneral-InfInfmissingmissingunknown
12770501hs1020110othergeneral-InfInfmissingmissingunknown
12870501hs1030110othergeneral-InfInfmissingmissingunknown
12980501hs1040110othergeneral-InfInfmissingmissingunknown
13080101hs1050110otherlinear-InfInfmissingmissingunknown
13180601hs1060110othergeneral-InfInfmissingmissingunknown
13290601hs1071010othergeneral-InfInfmissingmissingunknown
133901201hs1080110othergeneral-InfInfmissingmissingunknown
13490901hs1090010othergeneral-InfInfmissingmissingunknown
13520101hs110100othergeneral-InfInfmissingmissingunknown
136100001hs1100010otherunconstrained-Inf-43.13431missingunknown
137100301hs1111010othergeneral-InfInfmissingmissingunknown
138100301hs1121010otherlinear-InfInfmissingmissingunknown
139100801hs1130100othergeneral-Inf753.01missingunknown
1401001101hs1140010othergeneral-InfInfmissingmissingunknown
1411301501hs1160110othergeneral-InfInfmissingmissingunknown
142150501hs1170110othergeneral-Inf2400.111missingunknown
1431501701hs1180110otherlinear-Inf942.7161missingunknown
144160801hs1191010otherlinear-InfInfmissingmissingunknown
14520101hs120100othergeneral-Inf0.01missingunknown
14620101hs130110least_squaresgeneral-InfInfmissingmissingunknown
14720201hs140000least_squaresgeneral-InfInfmissingmissingunknown
14820201hs150110othergeneral-InfInfmissingmissingunknown
14920201hs160110othergeneral-InfInfmissingmissingunknown
15020201hs170110othergeneral-InfInfmissingmissingunknown
15120201hs180110othergeneral-InfInfmissingmissingunknown
15220201hs190110othergeneral-InfInfmissingmissingunknown
15320001hs20010otherunconstrained-Inf909.01missingunknown
15420301hs200110othergeneral-InfInfmissingmissingunknown
15520101hs210110otherlinear-InfInfmissingmissingunknown
15640201hs2191000lineargeneral-1.0-1.011unknown
15720201hs220100least_squaresgeneral-InfInfmissingmissingunknown
15820101hs2201010othergeneral1250001missingunknown
15920101hs2210110othergeneral-1-0.251missingunknown
16020101hs2220110othergeneral-1.5-1.31missingunknown
16120201hs2230110othergeneral-0.834032-0.11missingunknown
16220401hs2240110otherlinear-304-3041missingunknown
16320501hs2250100othergeneral221missingunknown
16420201hs2260110othergeneral-0.5-0.51missingunknown
16520201hs2270100othergeneral111missingunknown
16620201hs2280100othergeneral-3-31missingunknown
16720001hs2290010otherunconstrained001missingunknown
16820501hs230110least_squaresgeneral-InfInfmissingmissingunknown
16920201hs2300100othergeneral0.3750.3751missingunknown
17020201hs2310100otherlinear001missingunknown
17120301hs2320110otherlinear-1-11missingunknown
17220101hs2330100otherunconstrained001missingunknown
17320101hs2340110othergeneral-0.8-0.81missingunknown
17430101hs2351000othergeneral0.040.041missingunknown
17520201hs2360110othergeneral-58.9034-58.90341missingunknown
17620301hs2370110othergeneral-58.9034-58.90341missingunknown
17720301hs2380110othergeneral-58.9034-58.90341missingunknown
17820101hs2390110othergeneral-58.9034-58.90341missingunknown
17920201hs240110otherlinear-Inf-0.01336461missingunknown
18030001hs2400000otherunconstrained001missingunknown
18130001hs2410000otherunconstrained001missingunknown
18230001hs2420010otherunconstrained001missingunknown
18330001hs2430000otherunconstrained0.79660.79661missingunknown
18430001hs2440000otherunconstrained001missingunknown
18530001hs2450000otherunconstrained001missingunknown
18630001hs2460000otherunconstrained001missingunknown
18730201hs2480000othergeneral-0.8-0.81missingunknown
18830101hs2490110othergeneral111missingunknown
18930001hs250010otherunconstrained-Inf32.8351missingunknown
19030201hs2500110otherlinear-3300-33001missingunknown
19130101hs2510110otherlinear-3456-34561missingunknown
19230101hs2521000otherunconstrained0.040.041missingunknown
19330101hs2530110otherlinear87.379487.37941missingunknown
19430201hs2541010othergeneral-1.73205-1.732051missingunknown
19540001hs2550000otherunconstrained001missingunknown
19640001hs2560000otherunconstrained001missingunknown
19740001hs2570010otherunconstrained001missingunknown
19840001hs2580000otherunconstrained001missingunknown
19940001hs2590000otherunconstrained001missingunknown
20030101hs261000othergeneral-Inf21.161missingunknown
20140001hs2600000otherunconstrained001missingunknown
20240001hs2610000otherunconstrained001missingunknown
20340401hs2620010otherlinear-10-101missingunknown
20440401hs2630000othergeneral-1-11missingunknown
20540301hs2640100othergeneral-44-441missingunknown
20640201hs2651010otherlinear0.9747470.9747471missingunknown
20730101hs271000othergeneral-InfInfmissingmissingunknown
20830101hs281000least_squareslinear-Inf13.01missingunknown
20930101hs290100othergeneral-Inf-1.01missingunknown
21020001hs30010otherunconstrained-Inf1.000811missingunknown
21130101hs300110least_squaresgeneral-Inf3.01missingunknown
21230101hs310110othergeneral-Inf19.01missingunknown
21320101hs3161000quadraticquadratic-InfInf1missingacademic
21420101hs3171000quadraticquadratic-InfInf1missingacademic
21520101hs3181000quadraticquadratic-InfInf1missingacademic
21620101hs3191000quadraticquadratic-InfInf1missingacademic
21730201hs320010othergeneral-Inf7.21missingunknown
21820101hs3201000quadraticquadratic-InfInf1missingacademic
21920101hs3211000quadraticquadratic-InfInf1missingacademic
22020101hs3221000quadraticquadratic-InfInf1missingacademic
22130201hs330110othergeneral-Inf-3.01missingunknown
22230201hs340110othergeneral-Inf0.01missingunknown
22330101hs350110otherlinear-Inf2.251missingunknown
22430101hs360110otherlinear-Inf-1000.01missingunknown
22530101hs370110otherlinear-Inf-1000.01missingunknown
226100301hs3781000othergeneral-InfInf1missingacademic
22740001hs380010otherunconstrained-Inf19192.01missingunknown
22840201hs391000othergeneral-InfInfmissingmissingunknown
22920001hs40010otherunconstrained-Inf3.323571missingunknown
23040301hs401000othergeneral-InfInfmissingmissingunknown
23140101hs411010otherlinear-InfInfmissingmissingunknown
23240201hs421000least_squaresgeneral-InfInfmissingmissingunknown
23340301hs430100othergeneral-Inf0.01missingunknown
23440601hs440110otherlinear-Inf0.01missingunknown
23550001hs450010otherunconstrained-Inf1.733331missingunknown
23650201hs461000othergeneral-InfInfmissingmissingunknown
23750301hs471000othergeneral-Inf20.73811missingunknown
23850201hs481000least_squareslinear-Inf84.01missingunknown
23950201hs491000otherlinear-Inf266.01missingunknown
24020001hs50010otherunconstrained-Inf1.01missingunknown
24150301hs501000otherlinear-Inf7516.01missingunknown
24250301hs511000least_squareslinear-Inf8.51missingunknown
24350301hs521000least_squareslinear-InfInfmissingmissingunknown
24450301hs531010least_squareslinear-InfInfmissingmissingunknown
24560101hs541010otherlinear-InfInfmissingmissingunknown
24660601hs551010otherlinear-InfInfmissingmissingunknown
24770401hs561000othergeneral-InfInfmissingmissingunknown
24820101hs570110least_squaresgeneral-Inf0.03079861missingunknown
24920301hs590110othergeneral-InfInfmissingmissingunknown
25020101hs61000least_squaresgeneral-InfInfmissingmissingunknown
25130101hs601010othergeneral-InfInfmissingmissingunknown
25230201hs611000othergeneral-InfInfmissingmissingunknown
25330101hs621010otherlinear-InfInfmissingmissingunknown
25430201hs631010othergeneral-InfInfmissingmissingunknown
25530101hs640110othergeneral-InfInfmissingmissingunknown
25630101hs650110othergeneral-InfInfmissingmissingunknown
25730201hs660110othergeneral-Inf0.581missingunknown
25840201hs681010othergeneral-InfInf1missingunknown
25940201hs691010othergeneral-InfInf1missingunknown
26020101hs71000othergeneral-InfInfmissingmissingunknown
26140101hs700110othergeneral-Inf0.9878591missingunknown
26240201hs710010othergeneral-InfInfmissingmissingunknown
26340201hs720110othergeneral-InfInfmissingmissingunknown
26440301hs730010othergeneral-InfInfmissingmissingunknown
26540401hs740010othergeneral-InfInfmissingmissingunknown
26640401hs750010othergeneral-InfInfmissingmissingunknown
26740301hs760110otherlinear-Inf-1.251missingunknown
26850201hs771000othergeneral-InfInfmissingmissingunknown
26950301hs781000othergeneral-InfInfmissingmissingunknown
27050301hs791000othergeneral-InfInfmissingmissingunknown
27120201hs81000othergeneral-InfInfmissingmissingunknown
27250301hs801010othergeneral-InfInfmissingmissingunknown
27350301hs811010othergeneral-InfInfmissingmissingunknown
27450301hs830110othergeneral-InfInfmissingmissingunknown
27550301hs840110othergeneral-Inf-2.35124e61missingunknown
276501001hs860110otherlinear-Inf20.01missingunknown
27760401hs871010othergeneral-InfInf1missingunknown
27820101hs91000otherlinear-Inf0.01missingunknown
27960201hs930110othergeneral-Inf137.0661missingunknown
28060401hs950110othergeneral-InfInfmissingmissingunknown
28160401hs960110othergeneral-InfInfmissingmissingunknown
28260401hs970110othergeneral-InfInfmissingmissingunknown
28360401hs980110othergeneral-InfInfmissingmissingunknown
28470201hs991010othergeneral-InfInfmissingmissingunknown
2851001001indef_mod0000otherunconstrained-Inf91.66551missingunknown
2861001001integreq0000least_squaresunconstrained-Inf0.01missingunknown
28720001jennrichsampson0000least_squaresunconstrained-Inf4171.311missingunknown
28850001kirby20000least_squaresunconstrained-Inf500.01missingunknown
28940001kowosb0000least_squaresunconstrained-Inf0.02649781missingunknown
29060001lanczos10000least_squaresunconstrained-Inf500.01missingunknown
29160001lanczos20000least_squaresunconstrained-Inf500.01missingunknown
29260001lanczos30000least_squaresunconstrained-Inf500.01missingunknown
2931001001liarwhd0000otherunconstrained-Inf58500.01missingunknown
2941501101lincon0000otherlinear-InfInfmissingmissingunknown
29520201linsv0100otherlinear-InfInfmissingmissingunknown
29611114011marine1010othergeneral-InfInfmissingmissingunknown
29730001meyer30000least_squaresunconstrained-Inf1.69361e91missingunknown
29820201mgh01feas1000othergeneral-InfInfmissingmissingunknown
29940001mgh090000least_squaresunconstrained-Inf500.01missingunknown
30030001mgh100000least_squaresunconstrained-Inf500.01missingunknown
30150001mgh170000least_squaresunconstrained-Inf500.01missingunknown
30220001misra1a0000least_squaresunconstrained-Inf500.01missingunknown
30320001misra1b0000least_squaresunconstrained-Inf500.01missingunknown
30420001misra1c0000least_squaresunconstrained-Inf500.01missingunknown
30520001misra1d0000least_squaresunconstrained-Inf500.01missingunknown
3061001001morebv0000least_squaresunconstrained-Inf0.5009421missingunknown
30720001nasty0000otherunconstrained-Inf0.51missingunknown
3081001001ncb200000otherunconstrained-Inf182.0021missingunknown
3091001001ncb20b0000otherunconstrained-Inf200.01missingunknown
31030001nelson0000least_squaresunconstrained-Inf500.01missingunknown
3111001001noncvxu20000otherunconstrained-Inf2.63975e61missingunknown
3121001001noncvxun0000otherunconstrained-Inf2.72701e61missingunknown
3131001001nondia0000otherunconstrained-Inf39604.01missingunknown
3141001001nondquar0000otherunconstrained-Inf106.01missingunknown
31550001osborne10000least_squaresunconstrained-Inf7.068761missingunknown
316110001osborne20000least_squaresunconstrained-Inf2.093421missingunknown
31780001palmer1c0000least_squaresunconstrained-Inf3.45295e81missingunknown
31870001palmer1d0000least_squaresunconstrained-Inf2.87266e71missingunknown
31980001palmer2c0000least_squaresunconstrained-Inf2.6894e71missingunknown
32080001palmer3c0000least_squaresunconstrained-Inf8.12197e61missingunknown
32180001palmer4c0000least_squaresunconstrained-Inf8.09445e61missingunknown
32260001palmer5c0000least_squaresunconstrained-Inf25495.01missingunknown
32340001palmer5d0000least_squaresunconstrained-Inf22262.61missingunknown
32480001palmer6c0000least_squaresunconstrained-Inf7.72166e51missingunknown
32580001palmer7c0000least_squaresunconstrained-Inf3.20513e61missingunknown
32680001palmer8c0000least_squaresunconstrained-Inf850271.01missingunknown
3271001001penalty10000least_squaresunconstrained-Inf1.01missingunknown
3281001001penalty20000otherunconstrained-Inf1.68848e61missingunknown
3291001001penalty30000otherunconstrained-Inf1.00639e81missingunknown
33010015011polygon0010otherlinear-InfInf0missingunknown
33110015011polygon10010otherlinear-InfInf0missingunknown
3321001101polygon21010otherlinear-InfInf0missingunknown
333100110011polygon30100othergeneral-Inf-0.01missingunknown
33420001powellbs0000otherunconstrained-Inf0.5676311missingunknown
3351001001powellsg0000otherunconstrained-Inf5375.01missingunknown
3361001001power0000least_squaresunconstrained-Inf2.55025e71missingunknown
3371001001quartc0000otherunconstrained-Inf1.85427e91missingunknown
33830001rat420000least_squaresunconstrained-Inf500.01missingunknown
33940001rat430000least_squaresunconstrained-Inf500.01missingunknown
340109110211robotarm0011othergeneral-InfInfmissingmissingunknown
34120001rosenbrock0000otherunconstrained-Inf32.30861missingunknown
34240001rozman10000least_squaresunconstrained-Inf500.01missingunknown
3431001001sbrybnd0000least_squaresunconstrained-Inf1568.01missingunknown
3441001001schmvett0000otherunconstrained-Inf-189.0681missingunknown
3451001001scosine0000otherunconstrained-Inf86.88071missingunknown
3461001001sinquad0000otherunconstrained-Inf0.65611missingunknown
3471001001sparsine0000otherunconstrained-Inf20893.31missingunknown
3481001001sparsqur0000otherunconstrained-Inf1420.311missingunknown
3491001001spmsrtls0000least_squaresunconstrained-Inf49.32391missingunknown
3501001001srosenbr0000otherunconstrained-Inf1210.01missingunknown
35160014411structural0010otherlinear-InfInfmissingmissingunknown
352150401tetra0111othergeneral-InfInfmissingmissingunknown
3531259701922201tetra_duct120111othergeneral-Inf23246.11missingunknown
35464170900001tetra_duct150111othergeneral-Inf10890.91missingunknown
35532010410401tetra_duct200111othergeneral-Inf4959.81missingunknown
35640110484701tetra_foam50111othergeneral-Inf6497.11missingunknown
35725980311601tetra_gear0111othergeneral-Inf4256.381missingunknown
35835700467501tetra_hook0111othergeneral-Inf6157.141missingunknown
359300001threepk0010otherunconstrained-Inf20236.51missingunknown
36070001thurber0000least_squaresunconstrained-Inf500.01missingunknown
3611001001tointgss0000otherunconstrained-Inf891.6081missingunknown
3621001001tquartic0000least_squaresunconstrained-Inf0.811missingunknown
36380301triangle0111othergeneral-Inf11.3281missingunknown
36422440189601triangle_deer0111othergeneral-Inf2014.341missingunknown
36513660118201triangle_pacman0111othergeneral-Inf1316.281missingunknown
36644440402501triangle_turtle0111othergeneral-Inf4467.581missingunknown
3671001001tridia0000otherunconstrained-Inf5049.01missingunknown
3681001001vardim0000otherunconstrained-Inf1.31058e141missingunknown
36980001vibrbeam0000least_squaresunconstrained-Inf8231.281missingunknown
370310001watson0000least_squaresunconstrained-Inf500.01missingunknown
3711001001woods0000otherunconstrained-Inf180451.01missingunknown
37230301zangwil31000otherlinear-InfInfmissingmissingunknown

We select the problems that are scalable, so that there size can be modified. By default, the size is close to 100.

scalable_problems = meta[(meta.variable_nvar .== true) .& (meta.ncon .> 0), :name]
15-element Vector{String}:
 "camshape"
 "catenary"
 "chain"
 "channel"
 "clnlbeam"
 "controlinvestment"
 "elec"
 "hovercraft1d"
 "marine"
 "polygon"
 "polygon1"
 "polygon2"
 "polygon3"
 "robotarm"
 "structural"
using NLPModelsJuMP
list_backends = Dict(
  :forward => ADNLPModels.ForwardDiffADGradient,
  :reverse => ADNLPModels.ReverseDiffADGradient,
)
Dict{Symbol, DataType} with 2 entries:
  :reverse => ReverseDiffADGradient
  :forward => ForwardDiffADGradient
using DataFrames
nprob = length(scalable_problems)
stats = Dict{Symbol, DataFrame}()
for back in union(keys(list_backends), [:jump])
  stats[back] = DataFrame("name" => scalable_problems,
                 "time" => zeros(nprob),
                 "allocs" => zeros(Int, nprob))
end
using BenchmarkTools
nscal = 1000
for name in scalable_problems
  n = eval(Meta.parse("OptimizationProblems.get_" * name * "_nvar(n = $(nscal))"))
  m = eval(Meta.parse("OptimizationProblems.get_" * name * "_ncon(n = $(nscal))"))
  @info " $(name) with $n vars and $m cons"
  global x = ones(n)
  global g = zeros(n)
  global pb = Meta.parse(name)
  global nlp = MathOptNLPModel(OptimizationProblems.PureJuMP.eval(pb)(n = nscal))
  b = @benchmark grad!(nlp, x, g)
  stats[:jump][stats[:jump].name .== name, :time] = [median(b.times)]
  stats[:jump][stats[:jump].name .== name, :allocs] = [median(b.allocs)]
  for back in keys(list_backends)
    nlp = OptimizationProblems.ADNLPProblems.eval(pb)(n = nscal, gradient_backend = list_backends[back], matrix_free = true)
    b = @benchmark grad!(nlp, x, g)
    stats[back][stats[back].name .== name, :time] = [median(b.times)]
    stats[back][stats[back].name .== name, :allocs] = [median(b.allocs)]
  end
end
[ Info:  camshape with 1000 vars and 2003 cons
[ Info:  catenary with 999 vars and 332 cons
┌ Warning: catenary: number of variables adjusted to be a multiple of 3
└ @ OptimizationProblems.PureJuMP ~/.julia/packages/OptimizationProblems/fiJkh/src/PureJuMP/catenary.jl:20
┌ Warning: catenary: number of variables adjusted to be greater or equal to 6
└ @ OptimizationProblems.PureJuMP ~/.julia/packages/OptimizationProblems/fiJkh/src/PureJuMP/catenary.jl:22
┌ Warning: catenary: number of variables adjusted to be a multiple of 3
└ @ OptimizationProblems.ADNLPProblems ~/.julia/packages/OptimizationProblems/fiJkh/src/ADNLPProblems/catenary.jl:4
┌ Warning: catenary: number of variables adjusted to be greater or equal to 6
└ @ OptimizationProblems.ADNLPProblems ~/.julia/packages/OptimizationProblems/fiJkh/src/ADNLPProblems/catenary.jl:6
┌ Warning: catenary: number of variables adjusted to be a multiple of 3
└ @ OptimizationProblems.ADNLPProblems ~/.julia/packages/OptimizationProblems/fiJkh/src/ADNLPProblems/catenary.jl:4
┌ Warning: catenary: number of variables adjusted to be greater or equal to 6
└ @ OptimizationProblems.ADNLPProblems ~/.julia/packages/OptimizationProblems/fiJkh/src/ADNLPProblems/catenary.jl:6
[ Info:  chain with 1000 vars and 752 cons
[ Info:  channel with 1000 vars and 1000 cons
[ Info:  clnlbeam with 999 vars and 664 cons
[ Info:  controlinvestment with 1000 vars and 500 cons
[ Info:  elec with 999 vars and 333 cons
[ Info:  hovercraft1d with 998 vars and 668 cons
[ Info:  marine with 1007 vars and 488 cons
[ Info:  polygon with 1000 vars and 125251 cons
[ Info:  polygon1 with 1000 vars and 500 cons
[ Info:  polygon2 with 1000 vars and 1 cons
[ Info:  polygon3 with 1000 vars and 1000 cons
[ Info:  robotarm with 1009 vars and 1002 cons
[ Info:  structural with 3540 vars and 3652 cons
using Plots, SolverBenchmark
costnames = ["median time (in ns)", "median allocs"]
costs = [
  df -> df.time,
  df -> df.allocs,
]

gr()

profile_solvers(stats, costs, costnames)