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

FiniteDifferencesGradientCalculator

Class to construct the gradient and hessian for orbital optimization using finite differences.

class FiniteDifferencesGradientCalculator

Bases: GradientCalculator

Class 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:
  • estimator (Estimator) – Estimator to use for estimating.

  • mapper (Mapper | None) – Mapper to use when mapping RDM operators.

  • epsilon (float) – The finite difference. Defaults to 1e-5.

  • restricted (bool) – Whether the calculation should be performed restricted. Defaults to False.

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:
Return type:

float

compute_gradient(operator: FermionHermitianSumProtocol | PairedHardcoreBosonHermitianSumProtocol, circuit: Circuit, shots: int | None = None) ndarray[Any, dtype[float64]]

Compute the gradient.

Parameters:
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:
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