optimize#

ScipyOptimizer.optimize(objective_func: Callable[[ndarray], float], gradient_func: Callable[[ndarray], ndarray], initial_params: ndarray, callback: Callable[[ndarray], None] | None = None) Tuple[ndarray, float]#

Run the optimization.

Parameters:
objective_funcCallable[[np.ndarray], float]

Function that computes the objective (FOM) value given parameters. Should return a scalar value to be maximized.

gradient_funcCallable[[np.ndarray], np.ndarray]

Function that computes the gradient of the objective with respect to parameters. Should return an array of the same shape as the input parameters.

initial_paramsnp.ndarray

Initial parameter values to start optimization.

callbackCallable[[np.ndarray], None], optional

Optional callback function called after each iteration with the current parameter values (default: None).

Returns:
np.ndarray

Optimized parameter values.

float

Final FOM value at the optimized parameters.

Raises:
ValueError

If initial_params shape doesn’t match bounds (if provided).

RuntimeError

If optimization fails to converge or encounters an error.

Notes

The optimization history is stored in self.history and can be accessed after optimization completes. The full scipy result object is available in self.result.

When bounds are provided, parameters are internally scaled to [-1, 1] for better numerical stability. The objective function and gradients are automatically transformed to work in this scaled space.

For L-BFGS-B, the objective is negated internally since scipy minimizes but we want to maximize the FOM.