ScipyMinimize

class pmrf.optimize.ScipyMinimize(method: str | None = None, tol: float | None = None, options: dict = <factory>, show_progress: bool = True, use_grad: bool | None = None)

Bases: AbstractBoundedMinimizer

A wrapper around SciPy’s scipy.optimize.minimize().

Whether it honours bounds depends on method: L-BFGS-B, TNC, SLSQP, trust-constr, Powell, Nelder-Mead, COBYLA and COBYQA do, and search box space; any other method, such as BFGS or CG, moves through raw space. The default, None, is L-BFGS-B, which SciPy picks when it is given bounds. When bounds are supplied to trust-constr, SciPy searches fixed affine coordinates centered at the box start and receives feasible bounds; metrics.box_origin and metrics.box_scale map its coordinates back to box space.

Nonfinite objectives, requested gradients or attempted coordinates raise FloatingPointError with the method and evaluation number before SciPy can return a failed start point. Finite nonconvergence keeps SciPy’s usual result.

run(fn: Callable[[PyTree, Any], Any], y0: PyTree, args: Any = None, bounds: tuple[PyTree, PyTree] | None = None, max_iter: int = 1024, **kwargs) → MinimizeResult

Execute the minimization algorithm.

Parameters:
  • fn (callable) – The objective function to minimize.

  • y0 (PyTree) – The initial parameter guess.

  • args (Any) – Args to pass to fn.

  • bounds (tuple[PyTree, PyTree], optional) – The lower and upper edges of the box to search, shaped like y0, or None if the minimiser does not honour bounds. Edges may be infinite.

  • max_iter (int = 1024) – The maximum number of iterations to take.

  • **kwargs – Runtime arguments forward to the solver backend.

Returns:

An instance of pmrf.optimize.MinimizeResult.

Return type:

results

property honours_bounds: bool

Whether method keeps its iterates inside bounds. None is L-BFGS-B.

method: str | None = None
options: dict
show_progress: bool = True
tol: float | None = None
use_grad: bool | None = None