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
:true
by default. Whenfirst_order
istrue
, the first order Ipopt algorithm will be used. And when it isfalse
, the second order Ipopt algorithm will be used.symbolic
:false
by default. Whensymbolic
is 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 bysymbolify
which is described in the symbolic differentiation section in the documentation.sparse
:false
by default. Whensparse
is 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 = true
in thesymbolify
function discussed in symbolic differentiation section in the documentation. When used alone withsymbolic = false
,SparseDiffTools.jl
is used instead for the differentiation andSymbolics
is only used to get the sparsity pattern, much like howsparsify
works. For more details onsparsify
and the waySparseDiffTools
works, see the sparsity section in the documentation is used instead.linear_constraints
:false
by default. Whenlinear_constraints
istrue
, 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
sparsify
orsymbolify
on the model or functions before optimizing it with anIpoptAlg
. Setting thesparse
andsymbolic
options 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.