qrunch.quantum.algorithms.pauli.vqes.brute_force_gate_selector
Module for implementing a brute force gate selector.
Classes
Implementation of a gate selector that try all gates and then select the one that returns the lowest energy. |
|
Builder of a brute force gate selector. |
- class BruteForceGateSelector
Bases:
GateSelectorImplementation of a gate selector that try all gates and then select the one that returns the lowest energy.
- __init__(estimator: Estimator, minimizer: Minimizer, shots: int | ShotsPerGroup | None) None
Initialize the BruteForceGateSelector.
- Parameters:
estimator (Estimator) – Estimator to use for estimating the observable.
minimizer (Minimizer) – The minimizer to use in the algorithm.
shots (int | ShotsPerGroup | None) – Number of shots to use.
- Return type:
None
- clear_cache() None
Clear the cache of the estimator used in the Gate selector.
- Return type:
None
- register_gate_pool(gate_pool: GatePool) None
Register the gate pool.
- Parameters:
gate_pool (GatePool) – the gate pool to register in the GateSelector. The GateSelector can only choose gates from this.
- Return type:
None
- select_gates(observable: int | float | complex | Expression[PauliOperators] | HermitianPauliSum, circuit: Circuit, initial_guess: dict[Parameter, float] | None = None, *, number_of_gates: int = 1) list[GatePoolOperator]
Select random gates from the gate pool.
- Parameters:
observable (int | float | complex | Expression[PauliOperators] | HermitianPauliSum) – The observable whose expectation value should be minimized.
circuit (Circuit) – The circuit to extend with a gate form the gate pool.
initial_guess (dict[Parameter, float] | None) – Dict specifying the initial value of each Parameter. If None is given initial guess is 0.0.
number_of_gates (int) – Number of gates to select. Only implemented for number_of_gates = 1.
- Returns:
List of gate pool operators.
- Return type:
list[GatePoolOperator]
- class BruteForceGateSelectorCreator
Bases:
objectBuilder of a brute force gate selector.
- __init__() None
Initialize builder for the brute force gate selector.
- Return type:
None
- create() BruteForceGateSelector
Create an instance of
BruteForceGateSelector.- Return type:
- with_estimator(estimator: Estimator) Self
Set the estimator to use for the brute force gate selector.
- Parameters:
estimator (Estimator) – The estimator to use. Can be created using the
estimator_creator().- Return type:
Self
- with_minimizer(minimizer: Minimizer) Self
Set the minimizer to use for the brute force gate selector.
The minimizer is used to optimize the parameter of each candidate gate when evaluating its energy contribution.
- Parameters:
minimizer (Minimizer) – The minimizer to use. Can be created using the
minimizer_creator().- Return type:
Self
- with_total_estimator_shots(shots: int | None) Self
Set the total number of shots to use in the brute force gate selector.
The total number of shots are then distributed across the different groups in the estimator according to the shots per group strategy of the estimator. This ensures better use of the shot budget, and therefore, better use of the quantum resources.
- Parameters:
shots (int | None) – Total number of shots to use. If None is given, the estimator is assumed to be exact (e.g. the excitation gate simulator).
- Return type:
Self