bundles / scipy latest / scipy / optimize / _optimize / show_options
function
scipy.optimize._optimize:show_options
source: build-install/usr/lib/python3.14/site-packages/scipy/optimize/_optimize.py:3950
Signature
def show_options(solver = None, method = None, disp = True)Summary
Show documentation for additional options of optimization solvers.
Extended Summary
These are method-specific options that can be supplied through the options dict.
Parameters
solver: strType of optimization solver. One of 'minimize', 'minimize_scalar', 'root', 'root_scalar', 'linprog', or 'quadratic_assignment'.
method: str, optionalIf not given, shows all methods of the specified solver. Otherwise, show only the options for the specified method. Valid values corresponds to methods' names of respective solver (e.g., 'BFGS' for 'minimize').
disp: bool, optionalWhether to print the result rather than returning it.
Returns
: textEither None (for disp=True) or the text string (disp=False)
Notes
The solver-specific methods are:
Examples
We can print documentations of a solver in stdout:from scipy.optimize import show_options
✓show_options(solver="minimize")
✗
bfgs
====
Minimization of scalar function of one or more variables using the
BFGS algorithm.
Options
-------
disp : bool
Set to True to print convergence messages.
maxiter : int
Maximum number of iterations to perform.
gtol : float
Terminate successfully if gradient norm is less than `gtol`.
norm : float
Order of norm (Inf is max, -Inf is min).
eps : float or ndarray
If `jac is None` the absolute step size used for numerical
approximation of the jacobian via forward differences.
return_all : bool, optional
Set to True to return a list of the best solution at each of the
iterations.
finite_diff_rel_step : None or array_like, optional
If ``jac in ['2-point', '3-point', 'cs']`` the relative step size to
use for numerical approximation of the jacobian. The absolute step
size is computed as ``h = rel_step * sign(x) * max(1, abs(x))``,
possibly adjusted to fit into the bounds. For ``jac='3-point'``
the sign of `h` is ignored. If None (default) then step is selected
automatically.
xrtol : float, default: 0
Relative tolerance for `x`. Terminate successfully if step size is
less than ``xk * xrtol`` where ``xk`` is the current parameter vector.
c1 : float, default: 1e-4
Parameter for Armijo condition rule.
c2 : float, default: 0.9
Parameter for curvature condition rule.
hess_inv0 : None or ndarray, optional
Initial inverse hessian estimate, shape (n, n). If None (default) then
the identity matrix is used.
workers : int, map-like callable, optional
A map-like callable, such as `multiprocessing.Pool.map` for evaluating
any numerical differentiation in parallel.
This evaluation is carried out as ``workers(fun, iterable)``.
.. versionadded:: 1.16.0
Notes
-----
Parameters `c1` and `c2` must satisfy ``0 < c1 < c2 < 1``.
If minimization doesn't complete successfully, with an error message of
``Desired error not necessarily achieved due to precision loss``, then
consider setting `gtol` to a higher value. This precision loss typically
occurs when the (finite difference) numerical differentiation cannot provide
sufficient precision to satisfy the `gtol` termination criterion.
This can happen when working in single precision and a callable jac is not
provided. For single precision problems a `gtol` of 1e-3 seems to work.
cg
==
Minimization of scalar function of one or more variables using the
conjugate gradient algorithm.
Options
-------
disp : bool
Set to True to print convergence messages.
maxiter : int
Maximum number of iterations to perform.
gtol : float
Gradient norm must be less than `gtol` before successful
termination.
norm : float
Order of norm (Inf is max, -Inf is min).
eps : float or ndarray
If `jac is None` the absolute step size used for numerical
approximation of the jacobian via forward differences.
return_all : bool, optional
Set to True to return a list of the best solution at each of the
iterations.
finite_diff_rel_step : None or array_like, optional
If ``jac in ['2-point', '3-point', 'cs']`` the relative step size to
use for numerical approximation of the jacobian. The absolute step
size is computed as ``h = rel_step * sign(x) * max(1, abs(x))``,
possibly adjusted to fit into the bounds. For ``jac='3-point'``
the sign of `h` is ignored. If None (default) then step is selected
automatically.
c1 : float, default: 1e-4
Parameter for Armijo condition rule.
c2 : float, default: 0.4
Parameter for curvature condition rule.
workers : int, map-like callable, optional
A map-like callable, such as `multiprocessing.Pool.map` for evaluating
any numerical differentiation in parallel.
This evaluation is carried out as ``workers(fun, iterable)``.
.. versionadded:: 1.16.0
Notes
-----
Parameters `c1` and `c2` must satisfy ``0 < c1 < c2 < 1``.
cobyla
======
Minimize a scalar function of one or more variables using the
Constrained Optimization BY Linear Approximation (COBYLA) algorithm.
This method uses the pure-python implementation of the algorithm from PRIMA.
Options
-------
rhobeg : float
Reasonable initial changes to the variables.
tol : float
Final accuracy in the optimization (not precisely guaranteed).
This is a lower bound on the size of the trust region.
disp : int
Controls the frequency of output:
0. (default) There will be no printing
1. A message will be printed to the screen at the end of iteration, showing
the best vector of variables found and its objective function value
2. in addition to 1, each new value of RHO is printed to the screen,
with the best vector of variables so far and its objective function
value.
3. in addition to 2, each function evaluation with its variables will
be printed to the screen.
maxiter : int
Maximum number of function evaluations.
catol : float
Tolerance (absolute) for constraint violations
f_target : float
Stop if the objective function is less than `f_target`.
.. versionchanged:: 1.16.0
The original Powell implementation was replaced by a pure
Python version from the PRIMA package, with bug fixes and
improvements being made.
References
----------
Zhang Z. (2023), "PRIMA: Reference Implementation for Powell's Methods with
Modernization and Amelioration", https://www.libprima.net,
:doi:`10.5281/zenodo.8052654`
cobyqa
======
Minimize a scalar function of one or more variables using the
Constrained Optimization BY Quadratic Approximations (COBYQA) algorithm [1]_.
.. versionadded:: 1.14.0
Options
-------
disp : bool
Set to True to print information about the optimization procedure.
Default is ``False``.
maxfev : int
Maximum number of function evaluations. Default is ``500 * n``, where
``n`` is the number of variables.
maxiter : int
Maximum number of iterations. Default is ``1000 * n``, where ``n`` is
the number of variables.
f_target : float
Target value for the objective function. The optimization procedure is
terminated when the objective function value of a feasible point (see
`feasibility_tol` below) is less than or equal to this target. Default
is ``-numpy.inf``.
feasibility_tol : float
Absolute tolerance for the constraint violation. Default is ``1e-8``.
initial_tr_radius : float
Initial trust-region radius. Typically, this value should be in the
order of one tenth of the greatest expected change to the variables.
Default is ``1.0``.
final_tr_radius : float
Final trust-region radius. It should indicate the accuracy required in
the final values of the variables. If provided, this option overrides
the value of `tol` in the `minimize` function. Default is ``1e-6``.
scale : bool
Set to True to scale the variables according to the bounds. If True and
if all the lower and upper bounds are finite, the variables are scaled
to be within the range :math:`[-1, 1]`. If any of the lower or upper
bounds is infinite, the variables are not scaled. Default is ``False``.
References
----------
.. [1] COBYQA
https://www.cobyqa.com/stable/
dogleg
======
Minimization of scalar function of one or more variables using
the dog-leg trust-region algorithm.
Options
-------
initial_trust_radius : float
Initial trust-region radius.
max_trust_radius : float
Maximum value of the trust-region radius. No steps that are longer
than this value will be proposed.
eta : float
Trust region related acceptance stringency for proposed steps.
gtol : float
Gradient norm must be less than `gtol` before successful
termination.
l-bfgs-b
========
Minimize a scalar function of one or more variables using the L-BFGS-B
algorithm.
Options
-------
maxcor : int
The maximum number of variable metric corrections used to
define the limited memory matrix. (The limited memory BFGS
method does not store the full hessian but uses this many terms
in an approximation to it.)
ftol : float
The iteration stops when ``(f^k -
f^{k+1})/max{|f^k|,|f^{k+1}|,1} <= ftol``.
gtol : float
The iteration will stop when ``max{|proj g_i | i = 1, ..., n}
<= gtol`` where ``proj g_i`` is the i-th component of the
projected gradient.
eps : float or ndarray
If `jac is None` the absolute step size used for numerical
approximation of the jacobian via forward differences.
maxfun : int
Maximum number of function evaluations before minimization terminates.
Note that this function may violate the limit if the gradients
are evaluated by numerical differentiation.
maxiter : int
Maximum number of algorithm iterations.
maxls : int, optional
Maximum number of line search steps (per iteration). Default is 20.
finite_diff_rel_step : None or array_like, optional
If ``jac in ['2-point', '3-point', 'cs']`` the relative step size to
use for numerical approximation of the jacobian. The absolute step
size is computed as ``h = rel_step * sign(x) * max(1, abs(x))``,
possibly adjusted to fit into the bounds. For ``method='3-point'``
the sign of `h` is ignored. If None (default) then step is selected
automatically.
workers : int, map-like callable, optional
A map-like callable, such as `multiprocessing.Pool.map` for evaluating
any numerical differentiation in parallel.
This evaluation is carried out as ``workers(fun, iterable)``.
.. versionadded:: 1.16.0
Notes
-----
The option `ftol` is exposed via the `scipy.optimize.minimize` interface,
but calling `scipy.optimize.fmin_l_bfgs_b` directly exposes `factr`. The
relationship between the two is ``ftol = factr * numpy.finfo(float).eps``.
I.e., `factr` multiplies the default machine floating-point precision to
arrive at `ftol`.
If the minimization is slow to converge the optimizer may halt if the
total number of function evaluations exceeds `maxfun`, or the number of
algorithm iterations has reached `maxiter` (whichever comes first). If
this is the case then ``result.success=False``, and an appropriate
error message is contained in ``result.message``.
nelder-mead
===========
Minimization of scalar function of one or more variables using the
Nelder-Mead algorithm.
Options
-------
disp : bool
Set to True to print convergence messages.
maxiter, maxfev : int
Maximum allowed number of iterations and function evaluations.
Will default to ``N*200``, where ``N`` is the number of
variables, if neither `maxiter` or `maxfev` is set. If both
`maxiter` and `maxfev` are set, minimization will stop at the
first reached.
return_all : bool, optional
Set to True to return a list of the best solution at each of the
iterations.
initial_simplex : array_like of shape (N + 1, N)
Initial simplex. If given, overrides `x0`.
``initial_simplex[j,:]`` should contain the coordinates of
the jth vertex of the ``N+1`` vertices in the simplex, where
``N`` is the dimension.
xatol : float, optional
Absolute error in xopt between iterations that is acceptable for
convergence.
fatol : number, optional
Absolute error in func(xopt) between iterations that is acceptable for
convergence.
adaptive : bool, optional
Adapt algorithm parameters to dimensionality of problem. Useful for
high-dimensional minimization [1]_.
bounds : sequence or `Bounds`, optional
Bounds on variables. There are two ways to specify the bounds:
1. Instance of `Bounds` class.
2. Sequence of ``(min, max)`` pairs for each element in `x`. None
is used to specify no bound.
Note that this just clips all vertices in simplex based on
the bounds.
References
----------
.. [1] Gao, F. and Han, L.
Implementing the Nelder-Mead simplex algorithm with adaptive
parameters. 2012. Computational Optimization and Applications.
51:1, pp. 259-277
newton-cg
=========
Minimization of scalar function of one or more variables using the
Newton-CG algorithm.
Note that the `jac` parameter (Jacobian) is required.
Options
-------
disp : bool
Set to True to print convergence messages.
xtol : float
Average relative error in solution `xopt` acceptable for
convergence.
maxiter : int
Maximum number of iterations to perform.
eps : float or ndarray
If `hessp` is approximated, use this value for the step size.
return_all : bool, optional
Set to True to return a list of the best solution at each of the
iterations.
c1 : float, default: 1e-4
Parameter for Armijo condition rule.
c2 : float, default: 0.9
Parameter for curvature condition rule.
workers : int, map-like callable, optional
A map-like callable, such as `multiprocessing.Pool.map` for evaluating
any numerical differentiation in parallel.
This evaluation is carried out as ``workers(fun, iterable)``.
.. versionadded:: 1.16.0
Notes
-----
Parameters `c1` and `c2` must satisfy ``0 < c1 < c2 < 1``.
powell
======
Minimization of scalar function of one or more variables using the
modified Powell algorithm.
Parameters
----------
fun : callable
The objective function to be minimized::
fun(x, *args) -> float
where ``x`` is a 1-D array with shape (n,) and ``args``
is a tuple of the fixed parameters needed to completely
specify the function.
x0 : ndarray, shape (n,)
Initial guess. Array of real elements of size (n,),
where ``n`` is the number of independent variables.
args : tuple, optional
Extra arguments passed to the objective function and its
derivatives (`fun`, `jac` and `hess` functions).
method : str or callable, optional
The present documentation is specific to ``method='powell'``, but other
options are available. See documentation for `scipy.optimize.minimize`.
bounds : sequence or `Bounds`, optional
Bounds on decision variables. There are two ways to specify the bounds:
1. Instance of `Bounds` class.
2. Sequence of ``(min, max)`` pairs for each element in `x`. None
is used to specify no bound.
If bounds are not provided, then an unbounded line search will be used.
If bounds are provided and the initial guess is within the bounds, then
every function evaluation throughout the minimization procedure will be
within the bounds. If bounds are provided, the initial guess is outside
the bounds, and `direc` is full rank (or left to default), then some
function evaluations during the first iteration may be outside the
bounds, but every function evaluation after the first iteration will be
within the bounds. If `direc` is not full rank, then some parameters
may not be optimized and the solution is not guaranteed to be within
the bounds.
options : dict, optional
A dictionary of solver options. All methods accept the following
generic options:
maxiter : int
Maximum number of iterations to perform. Depending on the
method each iteration may use several function evaluations.
disp : bool
Set to True to print convergence messages.
See method-specific options for ``method='powell'`` below.
callback : callable, optional
Called after each iteration. The signature is::
callback(xk)
where ``xk`` is the current parameter vector.
Returns
-------
res : OptimizeResult
The optimization result represented as a ``OptimizeResult`` object.
Important attributes are: ``x`` the solution array, ``success`` a
Boolean flag indicating if the optimizer exited successfully and
``message`` which describes the cause of the termination. See
`OptimizeResult` for a description of other attributes.
Options
-------
disp : bool
Set to True to print convergence messages.
xtol : float
Relative error in solution `xopt` acceptable for convergence.
ftol : float
Relative error in ``fun(xopt)`` acceptable for convergence.
maxiter, maxfev : int
Maximum allowed number of iterations and function evaluations.
Will default to ``N*1000``, where ``N`` is the number of
variables, if neither `maxiter` or `maxfev` is set. If both
`maxiter` and `maxfev` are set, minimization will stop at the
first reached.
direc : ndarray
Initial set of direction vectors for the Powell method.
return_all : bool, optional
Set to True to return a list of the best solution at each of the
iterations.
slsqp
=====
Minimize a scalar function of one or more variables using Sequential
Least Squares Programming (SLSQP).
Parameters
----------
ftol : float
Precision target for the value of f in the stopping criterion. This value
controls the final accuracy for checking various optimality conditions;
gradient of the lagrangian and absolute sum of the constraint violations
should be lower than ``ftol``. Similarly, computed step size and the
objective function changes are checked against this value. Default is 1e-6.
eps : float
Step size used for numerical approximation of the Jacobian.
disp : bool
Set to True to print convergence messages. If False,
`verbosity` is ignored and set to 0.
maxiter : int, optional
Maximum number of iterations. Default value is 100.
finite_diff_rel_step : None or array_like, optional
If ``jac in ['2-point', '3-point', 'cs']`` the relative step size to
use for numerical approximation of `jac`. The absolute step
size is computed as ``h = rel_step * sign(x) * max(1, abs(x))``,
possibly adjusted to fit into the bounds. For ``method='3-point'``
the sign of `h` is ignored. If None (default) then step is selected
automatically.
workers : int, map-like callable, optional
A map-like callable, such as `multiprocessing.Pool.map` for evaluating
any numerical differentiation in parallel.
This evaluation is carried out as ``workers(fun, iterable)``.
.. versionadded:: 1.16.0
Returns
-------
res : OptimizeResult
The optimization result represented as an `OptimizeResult` object.
In this dict-like object the following fields are of particular importance:
``x`` the solution array, ``success`` a Boolean flag indicating if the
optimizer exited successfully, ``message`` which describes the reason for
termination, and ``multipliers`` which contains the Karush-Kuhn-Tucker
(KKT) multipliers for the QP approximation used in solving the original
nonlinear problem. See ``Notes`` below. See also `OptimizeResult` for a
description of other attributes.
Notes
-----
The KKT multipliers are returned in the ``OptimizeResult.multipliers``
attribute as a NumPy array. Denoting the dimension of the equality constraints
with ``meq``, and of inequality constraints with ``mineq``, then the returned
array slice ``m[:meq]`` contains the multipliers for the equality constraints,
and the remaining ``m[meq:meq + mineq]`` contains the multipliers for the
inequality constraints. The multipliers corresponding to bound inequalities
are not returned. See [1]_ pp. 321 or [2]_ for an explanation of how to interpret
these multipliers. The internal QP problem is solved using the methods given
in [3]_ Chapter 25.
Note that if new-style `NonlinearConstraint` or `LinearConstraint` were
used, then ``minimize`` converts them first to old-style constraint dicts.
It is possible for a single new-style constraint to simultaneously contain
both inequality and equality constraints. This means that if there is mixing
within a single constraint, then the returned list of multipliers will have
a different length than the original new-style constraints.
References
----------
.. [1] Nocedal, J., and S J Wright, 2006, "Numerical Optimization", Springer,
New York.
.. [2] Kraft, D., "A software package for sequential quadratic programming",
1988, Tech. Rep. DFVLR-FB 88-28, DLR German Aerospace Center, Germany.
.. [3] Lawson, C. L., and R. J. Hanson, 1995, "Solving Least Squares Problems",
SIAM, Philadelphia, PA.
tnc
===
Minimize a scalar function of one or more variables using a truncated
Newton (TNC) algorithm.
Options
-------
eps : float or ndarray
If `jac is None` the absolute step size used for numerical
approximation of the jacobian via forward differences.
scale : list of floats
Scaling factors to apply to each variable. If None, the
factors are up-low for interval bounded variables and
1+|x] for the others. Defaults to None.
offset : float
Value to subtract from each variable. If None, the
offsets are (up+low)/2 for interval bounded variables
and x for the others.
disp : bool
Set to True to print convergence messages.
maxCGit : int
Maximum number of hessian*vector evaluations per main
iteration. If maxCGit == 0, the direction chosen is
-gradient if maxCGit < 0, maxCGit is set to
max(1,min(50,n/2)). Defaults to -1.
eta : float
Severity of the line search. If < 0 or > 1, set to 0.25.
Defaults to -1.
stepmx : float
Maximum step for the line search. May be increased during
call. If too small, it will be set to 10.0. Defaults to 0.
accuracy : float
Relative precision for finite difference calculations. If
<= machine_precision, set to sqrt(machine_precision).
Defaults to 0.
minfev : float
Minimum function value estimate. Defaults to 0.
ftol : float
Precision goal for the value of f in the stopping criterion.
If ftol < 0.0, ftol is set to 0.0 defaults to -1.
xtol : float
Precision goal for the value of x in the stopping
criterion (after applying x scaling factors). If xtol <
0.0, xtol is set to sqrt(machine_precision). Defaults to
-1.
gtol : float
Precision goal for the value of the projected gradient in
the stopping criterion (after applying x scaling factors).
If gtol < 0.0, gtol is set to 1e-2 * sqrt(accuracy).
Setting it to 0.0 is not recommended. Defaults to -1.
rescale : float
Scaling factor (in log10) used to trigger f value
rescaling. If 0, rescale at each iteration. If a large
value, never rescale. If < 0, rescale is set to 1.3.
finite_diff_rel_step : None or array_like, optional
If ``jac in ['2-point', '3-point', 'cs']`` the relative step size to
use for numerical approximation of the jacobian. The absolute step
size is computed as ``h = rel_step * sign(x) * max(1, abs(x))``,
possibly adjusted to fit into the bounds. For ``method='3-point'``
the sign of `h` is ignored. If None (default) then step is selected
automatically.
maxfun : int
Maximum number of function evaluations. If None, `maxfun` is
set to max(100, 10*len(x0)). Defaults to None.
workers : int, map-like callable, optional
A map-like callable, such as `multiprocessing.Pool.map` for evaluating
any numerical differentiation in parallel.
This evaluation is carried out as ``workers(fun, iterable)``.
.. versionadded:: 1.16.0
trust-ncg
=========
Minimization of scalar function of one or more variables using
the Newton conjugate gradient trust-region algorithm.
Options
-------
initial_trust_radius : float
Initial trust-region radius.
max_trust_radius : float
Maximum value of the trust-region radius. No steps that are longer
than this value will be proposed.
eta : float
Trust region related acceptance stringency for proposed steps.
gtol : float
Gradient norm must be less than `gtol` before successful
termination.
trust-constr
============
Minimize a scalar function subject to constraints.
Parameters
----------
gtol : float, optional
Tolerance for termination by the norm of the Lagrangian gradient.
The algorithm will terminate when both the infinity norm (i.e., max
abs value) of the Lagrangian gradient and the constraint violation
are smaller than ``gtol``. Default is 1e-8.
xtol : float, optional
Tolerance for termination by the change of the independent variable.
The algorithm will terminate when ``tr_radius < xtol``, where
``tr_radius`` is the radius of the trust region used in the algorithm.
Default is 1e-8.
barrier_tol : float, optional
Threshold on the barrier parameter for the algorithm termination.
When inequality constraints are present, the algorithm will terminate
only when the barrier parameter is less than `barrier_tol`.
Default is 1e-8.
sparse_jacobian : {bool, None}, optional
Determines how to represent Jacobians of the constraints. If bool,
then Jacobians of all the constraints will be converted to the
corresponding format. If None (default), then Jacobians won't be
converted, but the algorithm can proceed only if they all have the
same format.
initial_tr_radius: float, optional
Initial trust radius. The trust radius gives the maximum distance
between solution points in consecutive iterations. It reflects the
trust the algorithm puts in the local approximation of the optimization
problem. For an accurate local approximation the trust-region should be
large and for an approximation valid only close to the current point it
should be a small one. The trust radius is automatically updated throughout
the optimization process, with ``initial_tr_radius`` being its initial value.
Default is 1 (recommended in [1]_, p. 19).
initial_constr_penalty : float, optional
Initial constraints penalty parameter. The penalty parameter is used for
balancing the requirements of decreasing the objective function
and satisfying the constraints. It is used for defining the merit function:
``merit_function(x) = fun(x) + constr_penalty * constr_norm_l2(x)``,
where ``constr_norm_l2(x)`` is the l2 norm of a vector containing all
the constraints. The merit function is used for accepting or rejecting
trial points and ``constr_penalty`` weights the two conflicting goals
of reducing objective function and constraints. The penalty is automatically
updated throughout the optimization process, with
``initial_constr_penalty`` being its initial value. Default is 1
(recommended in [1]_, p 19).
initial_barrier_parameter, initial_barrier_tolerance: float, optional
Initial barrier parameter and initial tolerance for the barrier subproblem.
Both are used only when inequality constraints are present. For dealing with
optimization problems ``min_x f(x)`` subject to inequality constraints
``c(x) <= 0`` the algorithm introduces slack variables, solving the problem
``min_(x,s) f(x) + barrier_parameter*sum(ln(s))`` subject to the equality
constraints ``c(x) + s = 0`` instead of the original problem. This subproblem
is solved for decreasing values of ``barrier_parameter`` and with decreasing
tolerances for the termination, starting with ``initial_barrier_parameter``
for the barrier parameter and ``initial_barrier_tolerance`` for the
barrier tolerance. Default is 0.1 for both values (recommended in [1]_ p. 19).
Also note that ``barrier_parameter`` and ``barrier_tolerance`` are updated
with the same prefactor.
factorization_method : str or None, optional
Method to factorize the Jacobian of the constraints. Use None (default)
for the auto selection or one of:
- 'NormalEquation' (requires scikit-sparse)
- 'AugmentedSystem'
- 'QRFactorization'
- 'SVDFactorization'
The methods 'NormalEquation' and 'AugmentedSystem' can be used only
with sparse constraints. The projections required by the algorithm
will be computed using, respectively, the normal equation and the
augmented system approaches explained in [1]_. 'NormalEquation'
computes the Cholesky factorization of ``A A.T`` and 'AugmentedSystem'
performs the LU factorization of an augmented system. They usually
provide similar results. 'AugmentedSystem' is used by default for
sparse matrices.
The methods 'QRFactorization' and 'SVDFactorization' can be used
only with dense constraints. They compute the required projections
using, respectively, QR and SVD factorizations. The 'SVDFactorization'
method can cope with Jacobian matrices with deficient row rank and will
be used whenever other factorization methods fail (which may imply the
conversion of sparse matrices to a dense format when required).
By default, 'QRFactorization' is used for dense matrices.
finite_diff_rel_step : None or array_like, optional
Relative step size for the finite difference approximation.
maxiter : int, optional
Maximum number of algorithm iterations. Default is 1000.
verbose : {0, 1, 2, 3}, optional
Level of algorithm's verbosity:
* 0 (default) : work silently.
* 1 : display a termination report.
* 2 : display progress during iterations.
* 3 : display progress during iterations (more complete report).
disp : bool, optional
If True (default), then `verbose` will be set to 1 if it was 0.
workers : int, map-like callable, optional
A map-like callable, such as `multiprocessing.Pool.map` for evaluating
any numerical differentiation in parallel.
This evaluation is carried out as ``workers(fun, iterable)``.
.. versionadded:: 1.16.0
Returns
-------
`OptimizeResult` with the fields documented below. Note the following:
1. All values corresponding to the constraints are ordered as they
were passed to the solver. And values corresponding to `bounds`
constraints are put *after* other constraints.
2. All numbers of function, Jacobian or Hessian evaluations correspond
to numbers of actual Python function calls. It means, for example,
that if a Jacobian is estimated by finite differences, then the
number of Jacobian evaluations will be zero and the number of
function evaluations will be incremented by all calls during the
finite difference estimation.
x : ndarray, shape (n,)
Solution found.
optimality : float
Infinity norm of the Lagrangian gradient at the solution.
constr_violation : float
Maximum constraint violation at the solution.
fun : float
Objective function at the solution.
grad : ndarray, shape (n,)
Gradient of the objective function at the solution.
lagrangian_grad : ndarray, shape (n,)
Gradient of the Lagrangian function at the solution.
nit : int
Total number of iterations.
nfev : int
Number of the objective function evaluations.
njev : int
Number of the objective function gradient evaluations.
nhev : int
Number of the objective function Hessian evaluations.
cg_niter : int
Total number of the conjugate gradient method iterations.
method : {'equality_constrained_sqp', 'tr_interior_point'}
Optimization method used.
constr : list of ndarray
List of constraint values at the solution.
jac : list of {ndarray, sparse array}
List of the Jacobian matrices of the constraints at the solution.
v : list of ndarray
List of the Lagrange multipliers for the constraints at the solution.
For an inequality constraint a positive multiplier means that the upper
bound is active, a negative multiplier means that the lower bound is
active and if a multiplier is zero it means the constraint is not
active.
constr_nfev : list of int
Number of constraint evaluations for each of the constraints.
constr_njev : list of int
Number of Jacobian matrix evaluations for each of the constraints.
constr_nhev : list of int
Number of Hessian evaluations for each of the constraints.
tr_radius : float
Radius of the trust region at the last iteration.
constr_penalty : float
Penalty parameter at the last iteration, see `initial_constr_penalty`.
barrier_tolerance : float
Tolerance for the barrier subproblem at the last iteration.
Only for problems with inequality constraints.
barrier_parameter : float
Barrier parameter at the last iteration. Only for problems
with inequality constraints.
execution_time : float
Total execution time.
message : str
Termination message.
status : {0, 1, 2, 3, 4}
Termination status:
* 0 : The maximum number of function evaluations is exceeded.
* 1 : `gtol` termination condition is satisfied.
* 2 : `xtol` termination condition is satisfied.
* 3 : `callback` raised `StopIteration`.
* 4 : Constraint violation exceeds 'gtol'.
.. versionchanged:: 1.15.0
If the constraint violation exceeds `gtol`, then ``result.success``
will now be False.
cg_stop_cond : int
Reason for CG subproblem termination at the last iteration:
* 0 : CG subproblem not evaluated.
* 1 : Iteration limit was reached.
* 2 : Reached the trust-region boundary.
* 3 : Negative curvature detected.
* 4 : Tolerance was satisfied.
References
----------
.. [1] Conn, A. R., Gould, N. I., & Toint, P. L.
Trust region methods. 2000. Siam. pp. 19.
trust-exact
===========
Minimization of scalar function of one or more variables using
a nearly exact trust-region algorithm.
Options
-------
initial_trust_radius : float
Initial trust-region radius.
max_trust_radius : float
Maximum value of the trust-region radius. No steps that are longer
than this value will be proposed.
eta : float
Trust region related acceptance stringency for proposed steps.
gtol : float
Gradient norm must be less than ``gtol`` before successful
termination.
subproblem_maxiter : int, optional
Maximum number of iterations to perform per subproblem. Only affects
trust-exact. Default is 25.
.. versionadded:: 1.17.0
trust-krylov
============
Minimization of a scalar function of one or more variables using
a nearly exact trust-region algorithm that only requires matrix
vector products with the hessian matrix.
.. versionadded:: 1.0.0
Options
-------
inexact : bool, optional
Accuracy to solve subproblems. If True requires less nonlinear
iterations, but more vector products.
Specifying a method is possible:
show_options(solver="minimize", method="Nelder-Mead")
✗Minimization of scalar function of one or more variables using the
Nelder-Mead algorithm.
Options
-------
disp : bool
Set to True to print convergence messages.
maxiter, maxfev : int
Maximum allowed number of iterations and function evaluations.
Will default to ``N*200``, where ``N`` is the number of
variables, if neither `maxiter` or `maxfev` is set. If both
`maxiter` and `maxfev` are set, minimization will stop at the
first reached.
return_all : bool, optional
Set to True to return a list of the best solution at each of the
iterations.
initial_simplex : array_like of shape (N + 1, N)
Initial simplex. If given, overrides `x0`.
``initial_simplex[j,:]`` should contain the coordinates of
the jth vertex of the ``N+1`` vertices in the simplex, where
``N`` is the dimension.
xatol : float, optional
Absolute error in xopt between iterations that is acceptable for
convergence.
fatol : number, optional
Absolute error in func(xopt) between iterations that is acceptable for
convergence.
adaptive : bool, optional
Adapt algorithm parameters to dimensionality of problem. Useful for
high-dimensional minimization [1]_.
bounds : sequence or `Bounds`, optional
Bounds on variables. There are two ways to specify the bounds:
1. Instance of `Bounds` class.
2. Sequence of ``(min, max)`` pairs for each element in `x`. None
is used to specify no bound.
Note that this just clips all vertices in simplex based on
the bounds.
References
----------
.. [1] Gao, F. and Han, L.
Implementing the Nelder-Mead simplex algorithm with adaptive
parameters. 2012. Computational Optimization and Applications.
51:1, pp. 259-277
We can also get the documentations as a string:
show_options(solver="minimize", method="Nelder-Mead", disp=False)
✗'Minimization of scalar function of one or more variables using the\nNelder-Mead algorithm.\n\nOptions\n-------\ndisp : bool\n Set to True to print convergence messages.\nmaxiter, maxfev : int\n Maximum allowed number of iterations and function evaluations.\n Will default to ``N*200``, where ``N`` is the number of\n variables, if neither `maxiter` or `maxfev` is set. If both\n `maxiter` and `maxfev` are set, minimization will stop at the\n first reached.\nreturn_all : bool, optional\n Set to True to return a list of the best solution at each of the\n iterations.\ninitial_simplex : array_like of shape (N + 1, N)\n Initial simplex. If given, overrides `x0`.\n ``initial_simplex[j,:]`` should contain the coordinates of\n the jth vertex of the ``N+1`` vertices in the simplex, where\n ``N`` is the dimension.\nxatol : float, optional\n Absolute error in xopt between iterations that is acceptable for\n convergence.\nfatol : number, optional\n Absolute error in func(xopt) between iterations that is acceptable for\n convergence.\nadaptive : bool, optional\n Adapt algorithm parameters to dimensionality of problem. Useful for\n high-dimensional minimization [1]_.\nbounds : sequence or `Bounds`, optional\n Bounds on variables. There are two ways to specify the bounds:\n\n 1. Instance of `Bounds` class.\n 2. Sequence of ``(min, max)`` pairs for each element in `x`. None\n is used to specify no bound.\n\n Note that this just clips all vertices in simplex based on\n the bounds.\n\nReferences\n----------\n.. [1] Gao, F. and Han, L.\n Implementing the Nelder-Mead simplex algorithm with adaptive\n parameters. 2012. Computational Optimization and Applications.\n 51:1, pp. 259-277'
Aliases
scipy.optimize.show_options