desc.optimize.Optimizer.optimize

Optimizer.optimize(eq, objective, constraints=(), ftol=None, xtol=None, gtol=None, x_scale='auto', verbose=1, maxiter=None, options=None)[source]

Optimize an objective function.

Parameters:
  • eq (Equilibrium) – Initial equilibrium.

  • objective (ObjectiveFunction) – Objective function to optimize.

  • constraints (tuple of Objective, optional) – List of objectives to be used as constraints during optimization.

  • ftol (float or None, optional) – Tolerance for termination by the change of the cost function. The optimization process is stopped when dF < ftol * F, and there was an adequate agreement between a local quadratic model and the true model in the last step. If None, defaults to 1e-2 (or 1e-6 for stochastic).

  • xtol (float or None, optional) – Tolerance for termination by the change of the independent variables. Optimization is stopped when norm(dx) < xtol * (xtol + norm(x)). If None, defaults to 1e-6.

  • gtol (float or None, optional) – Absolute tolerance for termination by the norm of the gradient. Optimizer terminates when norm(g) < gtol, where If None, defaults to 1e-8.

  • x_scale (array_like or 'auto', optional) – Characteristic scale of each variable. Setting x_scale is equivalent to reformulating the problem in scaled variables xs = x / x_scale. An alternative view is that the size of a trust region along jth dimension is proportional to x_scale[j]. Improved convergence may be achieved by setting x_scale such that a step of a given size along any of the scaled variables has a similar effect on the cost function. If set to 'auto', the scale is iteratively updated using the inverse norms of the columns of the Jacobian or Hessian matrix.

  • verbose (integer, optional) –

    • 0 : work silently.

    • 1 : display a termination report.

    • 2 : display progress during iterations

  • maxiter (int, optional) – Maximum number of iterations. Defaults to 100.

  • options (dict, optional) – Dictionary of optional keyword arguments to override default solver settings. See the code for more details.

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.