mirror of https://github.com/Qiskit/qiskit.git
34 lines
1.5 KiB
YAML
34 lines
1.5 KiB
YAML
---
|
|
features:
|
|
- |
|
|
A :class:`~qiskit.algorithms.minimum_eigensolvers.SamplingVQE` class is introduced, which is
|
|
optimized for diagonal hamiltonians and leverages a ``sampler`` primitive. A
|
|
:class:`~qiskit.algorithms.minimum_eigensolvers.QAOA` class is also added that subclasses
|
|
``SamplingVQE``.
|
|
|
|
To use the new ``SamplingVQE`` with a reference primitive, one can do, for example:
|
|
|
|
.. code-block:: python
|
|
|
|
from qiskit.algorithms.minimum_eigensolvers import SamplingVQE
|
|
from qiskit.algorithms.optimizers import SLSQP
|
|
from qiskit.circuit.library import TwoLocal
|
|
from qiskit.primitives import Sampler
|
|
from qiskit.opflow import PauliSumOp
|
|
from qiskit.quantum_info import SparsePauliOp
|
|
|
|
operator = PauliSumOp(SparsePauliOp(["ZZ", "IZ", "II"], coeffs=[1, -0.5, 0.12]))
|
|
|
|
sampler = Sampler()
|
|
ansatz = TwoLocal(rotation_blocks=["ry", "rz"], entanglement_blocks="cz")
|
|
optimizer = SLSQP()
|
|
|
|
sampling_vqe = SamplingVQE(sampler, ansatz, optimizer)
|
|
result = sampling_vqe.compute_minimum_eigenvalue(operator)
|
|
eigenvalue = result.eigenvalue
|
|
|
|
Note that the evaluated auxillary operators are now obtained via the
|
|
``aux_operators_evaluated`` field on the results. This will consist of a list or dict of
|
|
tuples containing the expectation values for these operators, as we well as the metadata from
|
|
primitive run. ``aux_operator_eigenvalues`` is no longer a valid field.
|