qrunch.quantum.algorithms.pauli.vqes.basic_vqe

Implementation of the basic VQE algorithm.

Classes

BasicVqe

Class for running a basic VQE.

BasicVqeCreator

Builder for the basic VQE algorithm.

class BasicVqe

Bases: object

Class for running a basic VQE.

__init__(estimator: Estimator, minimizer: Minimizer, shots: int | None) None

Initialize the VQE.

Parameters:
  • estimator (Estimator) – The estimator to use in the cost function.

  • minimizer (Minimizer) – The minimizer to use in the algorithm.

  • shots (int | None) – Number of shots to use for hte estimator.

Return type:

None

clear_cache() None

Clear the cache of the estimator.

Return type:

None

does_vqe_support_number_of_simultanously_parameters(number_of_parameters: int) bool

Check if the vqe supports the given number of parameters.

Parameters:

number_of_parameters (int) – The number of parameters to check.

Return type:

bool

run(observable: int | float | complex | Expression[PauliOperators], circuit: Circuit, iteration: int | None = None, initial_guess: dict[Parameter, float] | None = None) VqeResult
run(observable: HermitianPauliSum, circuit: Circuit, iteration: int | None = None, initial_guess: dict[Parameter, float] | None = None) VqeResult

Run the VQE algorithm.

The VQE algorithm finds optimal parameters for the circuit such that the expectation value of the observable is minimized.

Parameters:
  • observable (int | float | complex | Expression[PauliOperators] | HermitianPauliSum) – The observable whose expectation value should be minimized.

  • circuit (Circuit) – The parametrized circuit to find optimal parameters for. Should contain unspecified parameters.

  • iteration (int | None) – If applicable, the current adaptive iteration. If not applicable, set to None.

  • initial_guess (dict[Parameter, float] | None) – Dict specifying the initial value of each Parameter. If None is given initial guess is 0.0.

Return type:

VqeResult

class BasicVqeCreator

Bases: object

Builder for the basic VQE algorithm.

__init__() None

Initialize builder for the basic VQE.

Return type:

None

choose_minimizer() MinimizerSubCreator[Self]

Chose minimizer to use for the VQE.

Return type:

MinimizerSubCreator[Self]

create() BasicVqe

Create an instance of BasicVqe (fixed ansatz).

Return type:

BasicVqe

with_estimator(estimator: Estimator) Self

Choose estimator to use for the VQE.

Parameters:

estimator (Estimator)

Return type:

Self

with_estimator_shots(shots: int | None) Self

Choose the number of shots to use in the estimator.

Parameters:

shots (int | None)

Return type:

Self