finite_difference_gradient#
- lumopt2.utils.fd_grad.finite_difference_gradient(project: Project, params: List[float] | ndarray, indices: List[int], perturbation: float = 0.01) ndarray#
Compute the gradient of the figure of merit using finite difference.
All perturbed simulations are independent and are queued together then run concurrently, rather than executed one at a time.
- Parameters:
- project
lumopt2.Project Project instance for which the gradient is computed.
- params
Union[List,np.ndarray] Optimization parameters to update geometry with before computing FOM.
- indices
List[int] List of parameter indices to compute the finite difference gradient for.
- perturbation
float,optional Small perturbation value (default: 1e-2).
- project
- Returns:
np.ndarrayArray of computed finite difference gradient values corresponding to the provided indices.
- Raises:
ValueErrorIf input types are invalid or project is not a lumopt2.Project instance.