Various optimization algorithms from NLopt.jl
Description
NLopt is an optimization library with a collection of optimization algorithms implemented. NLopt.jl is the Julia wrapper of NLopt
. NonconvexNLopt
allows the use of NLopt.jl
using the NLoptAlg
algorithm struct.
Quick start
Given a model model
and an initial solution x0
, the following can be used to optimize the model using NLopt.
using Nonconvex
Nonconvex.@load NLopt
alg = NLoptAlg(:LD_SLSQP)
options = NLoptOptions()
result = optimize(model, alg, x0, options = options)
NLopt is an optional dependency of Nonconvex so you need to load the package to be able to use it.
Construct an instance
To construct an instance of NLopt's NLOPT_LD_SLSQP
algorithm, use:
alg = NLoptAlg(:LD_SLSQP)
All the algorithms available in NLopt are:
:GN_DIRECT
:GN_DIRECT_L
:GNL_DIRECT_NOSCAL
:GN_DIRECT_L_NOSCAL
:GN_DIRECT_L_RAND_NOSCAL
:GN_ORIG_DIRECT
:GN_ORIG_DIRECT_L
:GN_CRS2_LM
:G_MLSL_LDS
:G_MLSL
:GD_STOGO
:GD_STOGO_RAND
:GN_AGS
:GN_ISRES
:GN_ESCH
:LN_COBYLA
:LN_BOBYQA
:LN_NEWUOA
:LN_NEWUOA_BOUND
:LN_PRAXIS
:LN_NELDERMEAD
:LN_SBPLX
:LD_MMA
:LD_CCSAQ
:LD_SLSQP
:LD_TNEWTON_PRECOND_RESTART
:LD_TNEWTON_PRECOND
:LD_TNEWTON_RESTART
:LD_TNEWTON
:LD_VAR2
:LD_VAR1
:AUGLAG
:AUGLAG_EQ
For a description of the above algorithms, please refer to the algorithms section of NLopt's documentation.
Disclaimer:
Not all the algorithms have been tested with Nonconvex
. So if you try one and it doesn't work, please open an issue.
Options
The options keyword argument to the optimize
function shown above must be an instance of the NLoptOptions
struct when the algorihm is an NLoptAlg
. To specify options use keyword arguments in the constructor of NLoptOptions
, e.g:
options = NLoptOptions(ftol_rel = 1e-4)
All the other options that can be set for each algorithm can be found in the algorithms section section of NLopt's documentation.