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_func
Callable[[np.ndarray],float] Function that computes the objective (FOM) value given parameters. Should return a scalar value to be maximized.
- gradient_func
Callable[[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_params
np.ndarray Initial parameter values to start optimization.
- callback
Callable[[np.ndarray],None],optional Optional callback function called after each iteration with the current parameter values (default: None).
- objective_func
- Returns:
np.ndarrayOptimized parameter values.
floatFinal FOM value at the optimized parameters.
- Raises:
ValueErrorIf initial_params shape doesn’t match bounds (if provided).
RuntimeErrorIf 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.