minimize(method=’Powell’)#
- scipy.optimize.minimize(fun, x0, args=(), method=None, jac=None, hess=None, hessp=None, bounds=None, constraints=(), tol=None, callback=None, options=None)
Minimization of scalar function of one or more variables using the modified Powell algorithm.
- Parameters:
- funcallable
The objective function to be minimized:
fun(x, *args) -> float
where
x
is a 1-D array with shape (n,) andargs
is a tuple of the fixed parameters needed to completely specify the function.- x0ndarray, shape (n,)
Initial guess. Array of real elements of size (n,), where
n
is the number of independent variables.- argstuple, optional
Extra arguments passed to the objective function and its derivatives (fun, jac and hess functions).
- methodstr or callable, optional
The present documentation is specific to
method='powell'
, but other options are available. See documentation forscipy.optimize.minimize
.- boundssequence or
Bounds
, optional Bounds on decision variables. There are two ways to specify the bounds:
Instance of
Bounds
class.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.
- optionsdict, optional
A dictionary of solver options. All methods accept the following generic options:
- maxiterint
Maximum number of iterations to perform. Depending on the method each iteration may use several function evaluations.
- dispbool
Set to True to print convergence messages.
See method-specific options for
method='powell'
below.- callbackcallable, optional
Called after each iteration. The signature is:
callback(xk)
where
xk
is the current parameter vector.
- Returns:
- resOptimizeResult
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 andmessage
which describes the cause of the termination. SeeOptimizeResult
for a description of other attributes.
See also
For documentation for the rest of the parameters, see
scipy.optimize.minimize
- Options:
- ——-
- dispbool
Set to True to print convergence messages.
- xtolfloat
Relative error in solution xopt acceptable for convergence.
- ftolfloat
Relative error in
fun(xopt)
acceptable for convergence.- maxiter, maxfevint
Maximum allowed number of iterations and function evaluations. Will default to
N*1000
, whereN
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.- direcndarray
Initial set of direction vectors for the Powell method.
- return_allbool, optional
Set to True to return a list of the best solution at each of the iterations.