qiskit/releasenotes/notes/0.22/add-grover-primitives-10f81...

25 lines
864 B
YAML

---
features:
- |
The :class:`~.Grover` class has a new keyword argument, ``sampler`` which is
used to run the algorithm using an instance of the :class:`~.BaseSampler`
interface to calculate the results. This new argument supersedes the
the ``quantum_instance`` argument and accordingly, ``quantum_instance``
is pending deprecation and will be deprecated and subsequently removed in
future releases.
Example:
.. code-block:: python
from qiskit import QuantumCircuit
from qiskit.primitives import Sampler
from qiskit.algorithms import Grover, AmplificationProblem
sampler = Sampler()
oracle = QuantumCircuit(2)
oracle.cz(0, 1)
problem = AmplificationProblem(oracle, is_good_state=["11"])
grover = Grover(sampler=sampler)
result = grover.amplify(problem)