|Perform a global (G) derivative-free (N) optimization using the DIRECT-L search algorithm by Jones et al. as modified by Gablonsky et al. to be more weighted towards local search. Does not support unconstrainted optimization. There are also several other variants of the DIRECT algorithm that are supported: NLOPT_GLOBAL_DIRECT, which is the original DIRECT algorithm; NLOPT_GLOBAL_DIRECT_L_RAND, a slightly randomized version of DIRECT-L that may be better in high-dimensional search spaces; NLOPT_GLOBAL_DIRECT_NOSCAL, NLOPT_GLOBAL_DIRECT_L_NOSCAL, and NLOPT_GLOBAL_DIRECT_L_RAND_NOSCAL, which are versions of DIRECT where the dimensions are not rescaled to a unit hypercube (which means that dimensions with larger bounds are given more weight).|
|A global (G) derivative-free optimization using the DIRECT-L algorithm as above, along with NLOPT_GN_ORIG_DIRECT which is the original DIRECT algorithm. Unlike NLOPT_GN_DIRECT_L above, these two algorithms refer to code based on the original Fortran code of Gablonsky et al., which has some hard-coded limitations on the number of subdivisions etc. and does not support all of the NLopt stopping criteria, but on the other hand it supports arbitrary nonlinear inequality constraints.|
|Global (G) optimization using the StoGO algorithm by Madsen et al. StoGO exploits gradient information (D) (which must be supplied by the objective) for its local searches, and performs the global search by a branch-and-bound technique. Only bound-constrained optimization is supported. There is also another variant of this algorithm, NLOPT_GD_STOGO_RAND, which is a randomized version of the StoGO search scheme. The StoGO algorithms are only available if NLopt is compiled with C++ code enabled, and should be linked via -lnlopt_cxx instead of -lnlopt (via a C++ compiler, in order to link the C++ standard libraries).|
|Perform a local (L) derivative-free (N) optimization, starting at x, using the Nelder-Mead simplex algorithm, modified to support bound constraints. Nelder-Mead, while popular, is known to occasionally fail to converge for some objective functions, so it should be used with caution. Anecdotal evidence, on the other hand, suggests that it works fairly well for some cases that are hard to handle otherwise, e.g. noisy/discontinuous objectives. See also NLOPT_LN_SBPLX below.|
|Perform a local (L) derivative-free (N) optimization, starting at x, using an algorithm based on the Subplex algorithm of Rowan et al., which is an improved variant of Nelder-Mead (above). Our implementation does not use Rowans original code, and has some minor modifications such as explicit support for bound constraints. (Like Nelder-Mead, Subplex often works well in practice, even for noisy/discontinuous objectives, but there is no rigorous guarantee that it will converge.)|
|Local (L) derivative-free (N) optimization using the principal-axis method, based on code by Richard Brent. Designed for unconstrained optimization, although bound constraints are supported too (via the inefficient method of returning +Inf when the constraints are violated).|
|Local (L) gradient-based (D) optimization using the limited-memory BFGS (L-BFGS) algorithm. (The objective function must supply the gradient.) Unconstrained optimization is supported in addition to simple bound constraints (see above). Based on an implementation by Luksan et al.|
|Local (L) gradient-based (D) optimization using a shifted limited-memory variable-metric method based on code by Luksan et al., supporting both unconstrained and bound-constrained optimization. NLOPT_LD_VAR2 uses a rank-2 method, while .B NLOPT_LD_VAR1 is another variant using a rank-1 method.|
|Local (L) gradient-based (D) optimization using an LBFGS-preconditioned truncated Newton method with steepest-descent restarting, based on code by Luksan et al., supporting both unconstrained and bound-constrained optimization. There are several other variants of this algorithm: NLOPT_LD_TNEWTON_PRECOND (same without restarting), NLOPT_LD_TNEWTON_RESTART (same without preconditioning), and NLOPT_LD_TNEWTON (same without restarting or preconditioning).|
|Global (G) derivative-free (N) optimization using the controlled random search (CRS2) algorithm of Price, with the "local mutation" (LM) modification suggested by Kaelo and Ali.|
|Global (G) derivative-free (N) optimization using a genetic algorithm (mutation and differential evolution), using a stochastic ranking to handle nonlinear inequality and equality constraints as suggested by Runarsson and Yao.|
|Global (G) optimization using the multi-level single-linkage (MLSL) algorithm with a low-discrepancy sequence (LDS) or pseudorandom numbers, respectively. This algorithm executes a low-discrepancy or pseudorandom sequence of local searches, with a clustering heuristic to avoid multiple local searches for the same local optimum. The local search algorithm must be specified, along with termination criteria/tolerances for the local searches, by nlopt_set_local_optimizer. (This subsidiary algorithm can be with or without derivatives, and determines whether the objective function needs gradients.)|
|Local (L) gradient-based (D) optimization using the method of moving asymptotes (MMA), or rather a refined version of the algorithm as published by Svanberg (2002). (NLopt uses an independent free-software/open-source implementation of Svanbergs algorithm.) CCSAQ is a related algorithm from Svanbergs paper which uses a local quadratic approximation rather than the more-complicated MMA model; the two usually have similar convergence rates. The NLOPT_LD_MMA algorithm supports both bound-constrained and unconstrained optimization, and also supports an arbitrary number (m) of nonlinear inequality (not equality) constraints as described above.|
|Local (L) gradient-based (D) optimization using sequential quadratic programming and BFGS updates, supporting arbitrary nonlinear inequality and equality constraints, based on the code by Dieter Kraft (1988) adapted for use by the SciPy project. Note that this algorithm uses dense-matrix methods requiring O(n^2) storage and O(n^3) time, making it less practical for problems involving more than a few thousand parameters.|
|Local (L) derivative-free (N) optimization using the COBYLA algorithm of Powell (Constrained Optimization BY Linear Approximations). The NLOPT_LN_COBYLA algorithm supports both bound-constrained and unconstrained optimization, and also supports an arbitrary number (m) of nonlinear inequality/equality constraints as described above.|
|Local (L) derivative-free (N) optimization using a variant of the NEWUOA algorithm of Powell, based on successive quadratic approximations of the objective function. We have modified the algorithm to support bound constraints. The original NEWUOA algorithm is also available, as NLOPT_LN_NEWUOA, but this algorithm ignores the bound constraints lb and ub, and so it should only be used for unconstrained problems. Mostly superseded by BOBYQA.|
|Local (L) derivative-free (N) optimization using the BOBYQA algorithm of Powell, based on successive quadratic approximations of the objective function, supporting bound constraints.|
|Optimize an objective with nonlinear inequality/equality constraints via an unconstrained (or bound-constrained) optimization algorithm, using a gradually increasing "augmented Lagrangian" penalty for violated constraints. Requires you to specify another optimization algorithm for optimizing the objective+penalty function, using nlopt_set_local_optimizer. (This subsidiary algorithm can be global or local and with or without derivatives, but you must specify its own termination criteria.) A variant, NLOPT_AUGLAG_EQ, only uses the penalty approach for equality constraints, while inequality constraints are handled directly by the subsidiary algorithm (restricting the choice of subsidiary algorithms to those that can handle inequality constraints).|
Multiple stopping criteria for the optimization are supported, as specified by the functions to modify a given optimization problem opt. The optimization halts whenever any one of these criteria is satisfied. In some cases, the precise interpretation of the stopping criterion depends on the optimization algorithm above (although we have tried to make them as consistent as reasonably possible), and some algorithms do not support all of the stopping criteria.
Important: you do not need to use all of the stopping criteria! In most cases, you only need one or two, and can omit the remainder (all criteria are disabled by default).
nlopt_result nlopt_set_stopval(nlopt_opt opt, double stopval);
Stop when an objective value of at least stopval is found: stop minimizing when a value <= stopval is found, or stop maximizing when a value >= stopval is found. (Setting stopval to -HUGE_VAL for minimizing or +HUGE_VAL for maximizing disables this stopping criterion.)
nlopt_result nlopt_set_ftol_rel(nlopt_opt opt, double tol);
Set relative tolerance on function value: stop when an optimization step (or an estimate of the optimum) changes the function value by less than tol multiplied by the absolute value of the function value. (If there is any chance that your optimum function value is close to zero, you might want to set an absolute tolerance with nlopt_set_ftol_abs as well.) Criterion is disabled if tol is non-positive.
nlopt_result nlopt_set_ftol_abs(nlopt_opt opt, double tol);
Set absolute tolerance on function value: stop when an optimization step (or an estimate of the optimum) changes the function value by less than tol. Criterion is disabled if tol is non-positive.
nlopt_result nlopt_set_xtol_rel(nlopt_opt opt, double tol);
Set relative tolerance on design variables: stop when an optimization step (or an estimate of the optimum) changes every design variable by less than tol multiplied by the absolute value of the design variable. (If there is any chance that an optimal design variable is close to zero, you might want to set an absolute tolerance with nlopt_set_xtol_abs as well.) Criterion is disabled if tol is non-positive.
nlopt_result nlopt_set_xtol_abs(nlopt_opt opt, const double* tol);
Set absolute tolerances on design variables. tol is a pointer to an array of length n giving the tolerances: stop when an optimization step (or an estimate of the optimum) changes every design variable x[i] by less than tol[i].
For convenience, the following function may be used to set the absolute tolerances in all n design variables to the same value:
nlopt_result nlopt_set_xtol_abs1(nlopt_opt opt,
Criterion is disabled if tol is non-positive.
nlopt_result nlopt_set_maxeval(nlopt_opt opt, int maxeval);
Stop when the number of function evaluations exceeds maxeval. (This is not a strict maximum: the number of function evaluations may exceed maxeval slightly, depending upon the algorithm.) Criterion is disabled if maxeval is non-positive.
nlopt_result nlopt_set_maxtime(nlopt_opt opt, double maxtime);
Stop when the optimization time (in seconds) exceeds maxtime. (This is not a strict maximum: the time may exceed maxtime slightly, depending upon the algorithm and on how slow your function evaluation is.) Criterion is disabled if maxtime is non-positive.
Most of the NLopt functions return an enumerated constant of type nlopt_result, which takes on one of the following values:
NLOPT_SUCCESS Generic success return value. NLOPT_STOPVAL_REACHED Optimization stopped because stopval (above) was reached. NLOPT_FTOL_REACHED Optimization stopped because ftol_rel or ftol_abs (above) was reached. NLOPT_XTOL_REACHED Optimization stopped because xtol_rel or xtol_abs (above) was reached. NLOPT_MAXEVAL_REACHED Optimization stopped because maxeval (above) was reached. NLOPT_MAXTIME_REACHED Optimization stopped because maxtime (above) was reached.
NLOPT_FAILURE Generic failure code. NLOPT_INVALID_ARGS Invalid arguments (e.g. lower bounds are bigger than upper bounds, an unknown algorithm was specified, etcetera). NLOPT_OUT_OF_MEMORY Ran out of memory. NLOPT_ROUNDOFF_LIMITED Halted because roundoff errors limited progress. NLOPT_FORCED_STOP Halted because the user called nlopt_force_stop(opt) on the optimizations nlopt_opt object opt from the users objective function.
Some of the algorithms, especially MLSL and AUGLAG, use a different optimization algorithm as a subroutine, typically for local optimization. You can change the local search algorithm and its tolerances by calling:
nlopt_result nlopt_set_local_optimizer(nlopt_opt opt,
const nlopt_opt local_opt);
Here, local_opt is another nlopt_opt object whose parameters are used to determine the local search algorithm and stopping criteria. (The objective function, bounds, and nonlinear-constraint parameters of local_opt are ignored.) The dimension n of local_opt must match that of opt.
This function makes a copy of the local_opt object, so you can freely destroy your original local_opt afterwards.
For derivative-free local-optimization algorithms, the optimizer must somehow decide on some initial step size to perturb x by when it begins the optimization. This step size should be big enough that the value of the objective changes significantly, but not too big if you want to find the local optimum nearest to x. By default, NLopt chooses this initial step size heuristically from the bounds, tolerances, and other information, but this may not always be the best choice.
You can modify the initial step size by calling:
nlopt_result nlopt_set_initial_step(nlopt_opt opt,
const double* dx);
Here, dx is an array of length n containing the (nonzero) initial step size for each component of the design parameters x. For convenience, if you want to set the step sizes in every direction to be the same value, you can instead call:
nlopt_result nlopt_set_initial_step1(nlopt_opt opt,
Several of the stochastic search algorithms (e.g., CRS, MLSL, and ISRES) start by generating some initial "population" of random points x. By default, this initial population size is chosen heuristically in some algorithm-specific way, but the initial population can by changed by calling:
nlopt_result nlopt_set_population(nlopt_opt opt,
(A pop of zero implies that the heuristic default will be used.)
For stochastic optimization algorithms, we use pseudorandom numbers generated by the Mersenne Twister algorithm, based on code from Makoto Matsumoto. By default, the seed for the random numbers is generated from the system time, so that they will be different each time you run the program. If you want to use deterministic random numbers, you can set the seed by calling:
void nlopt_srand(unsigned long seed);
Some of the algorithms also support using low-discrepancy sequences (LDS), sometimes known as quasi-random numbers. NLopt uses the Sobol LDS, which is implemented for up to 1111 dimensions.
Written by Steven G. Johnson.
Copyright (c) 2007-2014 Massachusetts Institute of Technology.