qrunch.quantum.estimators.estimator_call_counter

Module for implementing Estimator that counts objective function evaluations.

Classes

EstimatorCallCounter

Estimator class for counting number of expectation value calculations.

class EstimatorCallCounter

Bases: Estimator

Estimator class for counting number of expectation value calculations.

For each call to estimator.run(..), it tracks the accumulated number of expectation values that are calculated. Notice that this does not simply equal the number of calls to the estimator.run(…) as each call may correspond to multiple expectation values being calculated.

__init__(estimator: Estimator) None

Initialize the estimator shot counter.

Parameters:

estimator (Estimator) – Underlying estimator to use for estimating.

Return type:

None

clear_cache() None

Clear the measurement cache.

Return type:

None

has_spin_particle_conservation() bool

Return True, if the estimator is set to use spin particle conservation.

Return type:

bool

has_total_particle_conservation() bool

Return True, if the estimator is set to use total particle conservation.

Return type:

bool

run(observables: Sequence[int | float | complex | Expression[PauliOperators]] | int | float | complex | Expression[PauliOperators] | Sequence[HermitianPauliSum] | HermitianPauliSum, circuits: Circuit | Sequence[Circuit], shots: int | None) ExpectationValue | list[ExpectationValue] | EstimatorResults

Estimate the value of the observables using the circuit state.

For each observable the following will be calculated: <circuit|observable|circuit>.

Parameters:
Return type:

ExpectationValue | list[ExpectationValue] | EstimatorResults

supports_shots_equals_none() bool

Return whether the estimator supports shots = None.

The EstimatorCallCounter estimator support shots=None if the underlying estimator supports it.

Return type:

bool