Local Optimization#
Available algorithms#
LocalOptimizer performs a local search of the optimal configuration which is close to an initial guess,
see LocalOptimizer for more detail.
The algorithms available in LocalOptimizer are listed below.
Name |
Numerical gradient |
Bounds |
Reference |
|---|---|---|---|
Powell |
No |
Yes |
|
Nelder-Mead |
No |
Yes |
|
COBYQA |
No |
Yes |
|
COBYLA |
No |
Yes |
|
L-BFGS-B |
Yes |
Yes |
|
SLSQP |
Yes |
Yes |
To select the algorithm,pass its name to the method argument of LocalOptimizer.run.
result = optimizer.run(x0=[6.0], method="Nelder-Mead")
The numerical gradient column says whether the method needs derivative information:
Powell, Nelder-Mead, COBYQA and COBYLA are derivative-free, while L-BFGS-B
and SLSQP estimate the gradients numerically. To estimate the gradient numerically, additional \(D\)
evaluations are made every optimization step, where \(D\) is the number of optimization variables.
Common settings#
All local optimization algorithms support the following additional parameters:
bounds: a list of tuples specifying the lower and upper bounds for each optimization variable. If not specified, the variables are assumed to be unbounded.tol: a float specifying the tolerance for termination. The behaviour is method dependent, seeoptionsof corresponding methods for better control.options: a dictionary of method-specific options.
An example of setting the method and bounds is shown below.
result = optimizer.run(x0=[6.0], bounds=[(0.0, 10.0)], method="Nelder-Mead")
Note
It is recommended to always specify bounds, as most optimization variables in the input file have physical limits.
Method dependent options#
The options parameter is a dictionary of method-specific options:
result = optimizer.run(
x0=[6.0],
bounds=[(0.0, 10.0)],
method="Nelder-Mead",
options={"xatol": 1e-3, "fatol": 1e-6, "maxfev": 50},
)
Every method has its own set of options. The sections below give a brief overview of the method and its options. For the full list of options, see the corresponding scipy documentation.
Powell#
Derivative-free. Minimizes along one direction at a time and builds the next set of directions from the progress made.
Option |
Default |
Description |
|---|---|---|
|
|
Relative error in the variables accepted as converged. |
|
|
Relative error in the metric accepted as converged. |
|
|
Maximum number of iterations. |
|
|
Maximum number of metric evaluations. |
|
|
Initial set of search directions, one row per variable. |
|
|
Print the progress in the terminal. |
The direc option is a 2D array of shape (D, D), where \(D\) is the number of optimization variables.
By default, the method uses the identity matrix as the initial set of search directions (i.e. orthogonal Cartesian axes).
Nelder-Mead#
Derivative-free. Maintains a simplex of D + 1 points and moves it by reflecting,
expanding and contracting around its worst vertex.
Option |
Default |
Description |
|---|---|---|
|
|
Absolute change in the variables accepted as converged. |
|
|
Absolute change in the metric accepted as converged. |
|
|
Maximum number of iterations. |
|
|
Maximum number of metric evaluations. |
|
|
Starting simplex of shape |
|
|
Adapt the simplex parameters to the number of variables. |
|
|
Print the progress in the terminal. |
Note
The adaptive=True is recommended for problems with more than 5 variables, as it improves convergence.
COBYQA#
A derivative-free local optimization algorithm that builds a quadratic approximation of the objective function using a set of previously evaluated points. It uses this model to select new points within an adaptive trust region, updating the approximation as optimization progresses.
Option |
Default |
Description |
|---|---|---|
|
|
Initial trust-region radius. |
|
|
Final trust-region radius, so the accuracy required of the result. |
|
|
Maximum number of metric evaluations. |
|
|
Maximum number of iterations. |
|
|
Absolute tolerance on the bound and constraint violation. |
|
|
Scale the variables to \([-1, 1]\), if all bounds are finite. |
|
|
Stop once a feasible point reaches this metric value. |
|
|
Print the progress in the terminal. |
COBYLA#
A derivative-free local optimization algorithm that builds linear approximations of the objective function and constraints using a set of previously evaluated points. It uses these models to select new points within an adaptive trust region, updating the approximations as optimization progresses.
Option |
Default |
Description |
|---|---|---|
|
|
Initial trust-region radius, so the size of the first steps. |
|
|
Final trust-region radius, so the accuracy required of the result. |
|
|
Maximum number of metric evaluations. |
|
|
Stop once a feasible point reaches this metric value. |
|
|
Verbosity of the printed output, from |
L-BFGS-B#
L-BFGS-B: A local optimization algorithm that estimates gradients numerically using finite differences and approximates the inverse Hessian using information from previous iterations. It uses these approximations to determine search directions while respecting variable bounds.
Option |
Default |
Description |
|---|---|---|
|
|
Relative decrease of the metric below which the run stops. |
|
|
Largest projected gradient component below which the run stops. |
|
|
Absolute step of the finite-difference gradient. |
|
|
Maximum number of iterations. |
|
|
Maximum number of metric evaluations. |
|
|
Number of correction pairs kept in the Hessian approximation. |
|
|
Maximum number of line-search steps per iteration. |
|
|
Relative step of the finite-difference gradient, used instead of |
SLSQP#
SLSQP: A local optimization algorithm that estimates gradients numerically using finite differences and solves a sequence of quadratic optimization subproblems to determine search directions. It updates an approximation of the Hessian using information from previous iterations to guide the optimization toward a minimum.
Option |
Default |
Description |
|---|---|---|
|
|
Precision goal for the metric in the stopping criterion. |
|
|
Absolute step of the finite-difference gradient. |
|
|
Maximum number of iterations. |
|
|
Relative step of the finite-difference gradient, used instead of |
|
|
Print the progress in the terminal. |