optimization.optimizer.scipy.least_squares#

SciPy least-squares optimizer wrapper.

Classes

LeastSquares(problem)

Optimizer using SciPy's least-squares solver.

class LeastSquares(problem: OptimizationProblem)[source]#

Optimizer using SciPy’s least-squares solver.

optimize(maxiter: int | None = None, disp: bool = False, plot: bool = False, tol: float = 0.001, callback: Any = None, method_choice: str = 'lm', x_scale: ArrayLike | float | Literal['jac'] | None = None) optimize.OptimizeResult[source]#

Optimize the problem using a SciPy least squares method.

Parameters:
  • maxiter (int, optional) – Maximum number of function evaluations. SciPy’s least_squares uses max_nfev.

  • disp (bool, optional) – Whether to display optimization progress.

  • plot (bool, optional) – If True, update live plots during optimization.

  • tol (float, optional) – Tolerance for termination (ftol - tolerance for the change in the sum of squares). Defaults to 1e-3.

  • callback (callable, optional) – Called after each optimization iteration.

  • method_choice (str, optional) – Method for scipy.optimize.least_squares. ‘lm’: Levenberg-Marquardt (DLS, does not support bounds). ‘trf’: Trust Region Reflective (supports bounds). ‘dogbox’: Dogleg algorithm (supports bounds). Defaults to ‘lm’.

  • x_scale (array-like, float, "jac", or None, optional) – Characteristic scale of each optimizer-space variable, after any Optiland variable scaling. If set to “jac”, SciPy updates the scale using inverse Jacobian column norms. If None, the argument is omitted so the installed SciPy version uses its existing default.

Returns:

The SciPy optimization result.

Return type:

OptimizeResult

undo()#

Undo the last optimization step.