Interior point method using Ipopt.jl
Description
Ipopt is a well known interior point optimizer developed and maintained by COIN-OR. The Julia wrapper of Ipopt is Ipopt.jl. Ipopt.jl is wrapped in NonconvexIpopt.jl. NonconvexIpopt allows the use of Ipopt.jl using the IpoptAlg algorithm struct. IpoptAlg can be used as a second order optimizer computing the Hessian of the Lagrangian in every iteration. Alternatively, an l-BFGS approximation of the Hessian can be used instead turning IpoptAlg into a first order optimizer tha only requires the gradient of the Lagrangian.
Quick start
Given a model model and an initial solution x0, the following can be used to optimize the model using Ipopt.
using Nonconvex
Nonconvex.@load Ipopt
alg = IpoptAlg()
options = IpoptOptions()
result = optimize(model, alg, x0, options = options)Construct an instance
To construct an instance of the Ipopt algorithm, use:
alg = IpoptAlg()Options
The options keyword argument to the optimize function shown above must be an instance of the IpoptOptions struct when the algorihm is an IpoptAlg. To specify options use keyword arguments in the constructor of IpoptOptions, e.g:
options = IpoptOptions(first_order = false, tol = 1e-4, sparse = false, symbolic = false)There are 4 important and special options:
first_order:trueby default. Whenfirst_orderistrue, the first order Ipopt algorithm will be used. And when it isfalse, the second order Ipopt algorithm will be used.symbolic:falseby default. Whensymbolicis set totrue, the gradients, Jacobians and Hessians of the objective, constraint and Lagrangian functions will be calculated using symbolic differentiation fromSymbolics.jl. This is the same approach used bysymbolifywhich is described in the symbolic differentiation section in the documentation.sparse:falseby default. Whensparseis set totrue, the gradients, Jacobians and Hessians of the objective, constraint and Lagrangian functions will be treated as sparse vectors/matrices. When combined withsymbolic = true, the output of symbolic differentiation will be a sparse vector/matrix, akin to settingsparse = truein thesymbolifyfunction discussed in symbolic differentiation section in the documentation. When used alone withsymbolic = false,SparseDiffTools.jlis used instead for the differentiation andSymbolicsis only used to get the sparsity pattern, much like howsparsifyworks. For more details onsparsifyand the waySparseDiffToolsworks, see the sparsity section in the documentation is used instead.linear_constraints:falseby default. Whenlinear_constraintsistrue, the Jacobian of the constraints will be computed and sparsified once at the beginning. When it isfalse, dense Jacobians will be computed in every iteration.
Note that there is no need to use
sparsifyorsymbolifyon the model or functions before optimizing it with anIpoptAlg. Setting thesparseandsymbolicoptions above are enough to trigger the symbolic differentiation and/or sparsity exploitation.
All the other options that can be set can be found on the Ipopt options section of Ipopt's documentation.