qrunch.quantum.algorithms.callbacks.callbacks
Module with callbacks.
Functions
|
Merge a list of parameter-value dicts, keeping values from later dicts. |
Classes
Convenience callback function that tracks sampler calls, adaptive iterations and objective function history. |
- class ObjectiveHistoryTracker
Bases:
AdaptiveIterationCallbackConvenience callback function that tracks sampler calls, adaptive iterations and objective function history.
- __init__() None
Initialize the history.
- Return type:
None
- record_adaptive_iteration(adaptive_iteration: int, unoptimized_circuit: Circuit, minimized_parameters: dict[Parameter, float], expectation_value: ExpectationValue, n_estimator_shots: int, operator: FermionHermitianSumProtocol | PairedHardcoreBosonHermitianSumProtocol | None = None) None
Call the callback function with the indicated parameters from the finished adaptive iteration.
Record the objective value at each adaptive iteration.
Note that the adaptive_iteration integer starts at 0 and is incremented with 1 each iteration, except for when reminimizing, then a special value of -1 is given.
- Parameters:
adaptive_iteration (int) – The iteration counter.
unoptimized_circuit (Circuit) – The unspecified Circuit.
minimized_parameters (dict[Parameter, float]) – The circuit parameters that minimize the operator expectation value.
expectation_value (ExpectationValue) – The expectation value.
n_estimator_shots (int) – The number of estimator shots.
operator (FermionHermitianSumProtocol | PairedHardcoreBosonHermitianSumProtocol | None) – The operator
- Return type:
None