qrunch.quantum.algorithms.second_quantization.vqes.basic_vqe

Module containing basic VQE.

Classes

SecondQuantizationBasicVqe

Basic VQE that takes a VQE as the underlying algorithm.

SecondQuantizationBasicVqeCreator

Builder for the basic VQE algorithm.

class SecondQuantizationBasicVqe

Bases: SecondQuantizationVqeAlgorithm

Basic VQE that takes a VQE as the underlying algorithm.

__init__(vqe: BasicVqe, mapper: Mapper | None = None) None

Initialize basic VQE.

Parameters:
  • vqe (BasicVqe) – VQE to use.

  • mapper (Mapper | None) – Mapper to use for creating qubit Hamiltonian.

Return type:

None

clear_cache() None

Clear the cache of the underlying VQE.

Return type:

None

run(second_quantized_operator: T, circuit: Circuit, initial_parameter_guess: dict[Parameter, float] | None = None) SecondQuantizationVqeResult[T]

Run the VQE and find the eigenvalue.

Parameters:
  • second_quantized_operator (T) – The operator whose expectation value should be minimized.

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

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

  • 0.0 (guess is)

Return type:

SecondQuantizationVqeResult[T]

class SecondQuantizationBasicVqeCreator

Bases: VqeCreatorEstimatorMixin[BasicVqeCreator], VqeCreatorMinimizerMixin[BasicVqeCreator]

Builder for the basic VQE algorithm.

__init__() None

Initialize builder for the basic VQE.

Return type:

None

choose_minimizer() MinimizerSubCreator[Self]

Choose minimizer to use for the VQE.

Return type:

MinimizerSubCreator[Self]

create() SecondQuantizationBasicVqe

Create an instance of SecondQuantizationBasicVqe.

Return type:

SecondQuantizationBasicVqe

with_estimator(estimator: Estimator) Self

Set the estimator to use for the VQE.

Parameters:

estimator (Estimator) – Estimator to use. Can be created using the estimator_creator() builder.

Return type:

Self

with_estimator_shots(shots: int | None) Self

Set the number of shots to use in the estimator.

Parameters:
  • shots (int | None) – Number of shots to use in the estimator. If None is given, the estimator is assumed to be exact

  • simulator). ((e.g. the excitation gate)

Return type:

Self