qrunch.quantum.algorithms.second_quantization.orbital_optimizers.gradient_calculator
Module dedicated to general (full-domain) orbital optimization gradient and Hessian computations.
This interface is intended for scenarios where gradients and Hessians can be computed for any parameter set, not just around a single reference point.
Classes
Class to construct the gradient and hessian for orbital optimization using finite differences. |
- class FiniteDifferencesGradientCalculator
Bases:
GradientCalculatorClass to construct the gradient and hessian for orbital optimization using finite differences.
- __init__(estimator: Estimator, mapper: Mapper | None = None, *, epsilon: float = 1e-05, restricted: bool = False) None
Initialize the gradient calculator using finite differences.
- Parameters:
- Return type:
None
- clear_cache() None
Clear the cache of the estimator.
- Return type:
None
- compute_energy(operator: FermionHermitianSumProtocol | PairedHardcoreBosonHermitianSumProtocol, circuit: Circuit, shots: int | None = None) float
Compute the energy.
- Parameters:
operator (FermionHermitianSumProtocol | PairedHardcoreBosonHermitianSumProtocol) – Operator to estimate the energy of.
circuit (Circuit) – The circuit ansatz with minimized parameters set.
shots (int | None) – The number of shots to use in the estimator.
- Return type:
float
- compute_gradient(operator: FermionHermitianSumProtocol | PairedHardcoreBosonHermitianSumProtocol, circuit: Circuit, shots: int | None = None) ndarray[Any, dtype[float64]]
Compute the gradient.
- Parameters:
operator (FermionHermitianSumProtocol | PairedHardcoreBosonHermitianSumProtocol) – Operator to estimate the gradient from.
circuit (Circuit) – The circuit ansatz with minimized parameters set.
shots (int | None) – The number of shots to use in the estimator.
- Return type:
ndarray[Any, dtype[float64]]
- compute_hessian(operator: FermionHermitianSumProtocol | PairedHardcoreBosonHermitianSumProtocol, circuit: Circuit, shots: int | None = None) ndarray[Any, dtype[float64]]
Compute the Hessian.
- Parameters:
operator (FermionHermitianSumProtocol | PairedHardcoreBosonHermitianSumProtocol) – Operator to estimate the Hessian from.
circuit (Circuit) – The circuit ansatz with minimized parameters set.
shots (int | None) – The number of shots to use in the estimator.
- Return type:
ndarray[Any, dtype[float64]]
- get_estimator_shots() int
Get the total amount of shots made by the estimator.
- Return type:
int
- is_restricted() bool
Return True if the calculation is restricted.
- Return type:
bool