minimize

pmrf.optimize.minimize(objective: Callable[[PyTree], Array] | tuple[Callable, Frequency] | Sequence[Callable[[PyTree], Array] | tuple[Callable, Frequency]], model: PyTreeT | None = None, frequency: Frequency | None = None, solver: AbstractUnconstrainedMinimizer | AbstractBoundedMinimizer = ScipyMinimize(options={}), max_iter: int | None = 1024, **kwargs) → OptimizeResult[PyTreeT]

Minimizes a given objective function for a model over a frequency range.

The objective function can have its own hyper-parameters, and is returned in result.objective.

Parameters:
  • objective (TermLike | Sequence[TermLike] | pmrf.AbstractProblem) –

    An already-built problem, or the objective function to minimize. Can be a function or a callable PyTree with optional parameters. If a sequence of objectives is provided, they are automatically summed. See pmrf.objectives.evaluators.Goal() for an easy way to define goal-based objectives.

    Each objective may instead be an (objective, frequency) pair, or a pmrf.Term, binding it to its own frequency sweep rather than the shared one. This allows a single parameter set to be optimized against several bands at once.

  • model (PyTree | None, default=None) – The PyTree containing the parameters to be optimized. Omitted when an already-built problem is passed. A solver that honours bounds searches the box of the free parameters’ bounds; any other moves through their raw values, where each parameter’s bijector enforces its bounds. See pmrf.optimize.base.run_minimizer().

  • frequency (Frequency | None, default=None) – The frequency sweep over which the objective should be evaluated. May be omitted only if every objective already carries its own frequency.

  • solver (pmrf.optimize.AbstractMinimizer, default=ScipyMinimize()) – The optimizer to use. See pmrf.optimize for available solvers.

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

  • **kwargs – Additional arguments to forward to parax.optimize.minimize.

Returns:

A structured result containing the fitted model and solver statistics.

Return type:

OptimizeResult

Raises:

FloatingPointError – If SciPy evaluates a nonfinite objective, requested gradient or attempted optimizer vector. The diagnostic identifies the method and evaluation number.