qrunch.quantum.algorithms.second_quantization.vqes.orbital_optimization_vqe

Module containing orbital optimization VQE.

Classes

SecondQuantizationOrbitalOptimizationVqe

VQE that uses an orbital optimization VQE as the underlying algorithm.

SecondQuantizationOrbitalOptimizationVqeCreator

Builder for the adaptive VQE algorithm.

SecondQuantizationOrbitalOptimizationVqeResult

Result of the Orbital optimized VQE calculation.

class SecondQuantizationOrbitalOptimizationVqe

Bases: SecondQuantizationVqeAlgorithm

VQE that uses an orbital optimization VQE as the underlying algorithm.

__init__(vqe: PauliBasicVqeAlgorithm, orbital_optimizer: OrbitalOptimizerAlgorithm, mapper: Mapper | None = None) None

Initialize orbital optimization (OO) VQE.

Parameters:
  • vqe (PauliBasicVqeAlgorithm) – An instance of a VQE. The estimator from this is re-used in the orbital optimization step in order to avoid re-sampling of the circuit.

  • orbital_optimizer (OrbitalOptimizerAlgorithm) – The orbital optimizer 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 and orbital optimizer.

Return type:

None

get_basic_vqe() PauliBasicVqeAlgorithm

Return the instance of a VQE.

Return type:

PauliBasicVqeAlgorithm

property mapper: Mapper

Return the mapper.

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

Run the VQE and find the eigenvalue.

The OO-VQE algorithm optimizes the circuit parameters and rotates the observable integrals so that the expectation value of the observable is minimized.

Note that it only rotates the observable integrals, if the optimized parameter(s) are non-zero.

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 guess is 0.0.

  • iteration (int | None) – The adaptive iteration.

Return type:

SecondQuantizationOrbitalOptimizationVqeResult[T]

class SecondQuantizationOrbitalOptimizationVqeCreator

Bases: VqeCreatorEstimatorMixin[BasicVqeCreator], VqeCreatorMinimizerMixin[BasicVqeCreator]

Builder for the adaptive 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() SecondQuantizationOrbitalOptimizationVqe

Create an instance of SecondQuantizationOrbitalOptimizationVqe.

Return type:

SecondQuantizationOrbitalOptimizationVqe

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

with_orbital_optimizer(orbital_optimizer: OrbitalOptimizerAlgorithm) Self

Choose minimizer used to determine the optimal orbital rotation parameters in orbital optimization VQE.

Parameters:

orbital_optimizer (OrbitalOptimizerAlgorithm)

Return type:

Self

class SecondQuantizationOrbitalOptimizationVqeResult

Bases: SecondQuantizationVqeResult[T]

Result of the Orbital optimized VQE calculation.

All fields are immutable (frozen=True) so an instance can be safely reused.

Parameters:

orbital_change – Change due to orbital optimization.

__init__(estimator_shots: int, parameters: dict[Parameter, float], estimated_value: ExpectationValue, operator: T_COV, unspecified_circuit: Circuit, orbital_change: float) None
Parameters:
  • estimator_shots (int)

  • parameters (dict[Parameter, float])

  • estimated_value (ExpectationValue)

  • operator (T_COV)

  • unspecified_circuit (Circuit)

  • orbital_change (float)

Return type:

None

estimated_value: ExpectationValue
estimator_shots: int
operator: T_COV
orbital_change: float
parameters: dict[Parameter, float]
property specified_circuit: Circuit | None

Circuit ansatz with the optimal parameters.

unspecified_circuit: Circuit