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.

Table 1 Supported local optimization algorithms.#

Name

Numerical gradient

Bounds

Reference

Powell

No

Yes

scipy Powell

Nelder-Mead

No

Yes

scipy Nelder-Mead

COBYQA

No

Yes

scipy COBYQA

COBYLA

No

Yes

scipy COBYLA

L-BFGS-B

Yes

Yes

scipy L-BFGS-B

SLSQP

Yes

Yes

scipy SLSQP

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, see options of 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

xtol

1e-4

Relative error in the variables accepted as converged.

ftol

1e-4

Relative error in the metric accepted as converged.

maxiter

1000 * D

Maximum number of iterations.

maxfev

1000 * D

Maximum number of metric evaluations.

direc

None

Initial set of search directions, one row per variable.

disp

False

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

xatol

1e-4

Absolute change in the variables accepted as converged.

fatol

1e-4

Absolute change in the metric accepted as converged.

maxiter

200 * D

Maximum number of iterations.

maxfev

200 * D

Maximum number of metric evaluations.

initial_simplex

None

Starting simplex of shape (D + 1, D), used instead of x0.

adaptive

False

Adapt the simplex parameters to the number of variables.

disp

False

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_tr_radius

1.0

Initial trust-region radius.

final_tr_radius

1e-6

Final trust-region radius, so the accuracy required of the result.

maxfev

500 * D

Maximum number of metric evaluations.

maxiter

1000 * D

Maximum number of iterations.

feasibility_tol

1e-8

Absolute tolerance on the bound and constraint violation.

scale

False

Scale the variables to \([-1, 1]\), if all bounds are finite.

f_target

-numpy.inf

Stop once a feasible point reaches this metric value.

disp

False

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

rhobeg

1.0

Initial trust-region radius, so the size of the first steps.

tol

1e-4

Final trust-region radius, so the accuracy required of the result.

maxiter

1000

Maximum number of metric evaluations.

f_target

-numpy.inf

Stop once a feasible point reaches this metric value.

disp

0

Verbosity of the printed output, from 0 (silent) to 3.

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

ftol

2.2e-9

Relative decrease of the metric below which the run stops.

gtol

1e-5

Largest projected gradient component below which the run stops.

eps

1e-8

Absolute step of the finite-difference gradient.

maxiter

15000

Maximum number of iterations.

maxfun

15000

Maximum number of metric evaluations.

maxcor

10

Number of correction pairs kept in the Hessian approximation.

maxls

20

Maximum number of line-search steps per iteration.

finite_diff_rel_step

None

Relative step of the finite-difference gradient, used instead of eps.

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

ftol

1e-6

Precision goal for the metric in the stopping criterion.

eps

1.5e-8

Absolute step of the finite-difference gradient.

maxiter

100

Maximum number of iterations.

finite_diff_rel_step

None

Relative step of the finite-difference gradient, used instead of eps.

disp

False

Print the progress in the terminal.