Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grover's Migration from Aqua to Qiskit Terra #6499

Closed
atilsamancioglu opened this issue Jun 2, 2021 · 1 comment · Fixed by #6658
Closed

Grover's Migration from Aqua to Qiskit Terra #6499

atilsamancioglu opened this issue Jun 2, 2021 · 1 comment · Fixed by #6658

Comments

@atilsamancioglu
Copy link

atilsamancioglu commented Jun 2, 2021

Informations

  • Qiskit version: 0.26.0
  • Python version: 3.8
  • Operating system: MacOS

What is the current behavior?

Grover's algorithm does not behave as expected, at least does not take previously known as "Logical Expression" (now PhaseOracle) alphabetically. It runs fine in Aqua but not in Qiskit circuit library.

Steps to reproduce the problem

from qiskit import *
from qiskit.tools.visualization import plot_histogram
from qiskit.circuit.library import PhaseOracle
from qiskit.algorithms import Grover, AmplificationProblem

oracle = PhaseOracle('((A & C) | (B & D)) & ~(C & D)')
problem = AmplificationProblem(oracle=oracle, is_good_state=oracle.evaluate_bitstring)
backend = Aer.get_backend('qasm_simulator')
grover = Grover(quantum_instance=backend)
result = grover.amplify(problem)
print(result.circuit_results[0])

What is the expected behavior?

It shouldn't give 1100 as a suggestion, since we declare C&D as not expression in PhaseOracle.

However it gives:

{'1101': 255, '0011': 260, '1100': 260, '0111': 249}

In Aqua it gives (this is the expected behaviour):

{'0101': 261, '0111': 236, '1011': 262, '1010': 265}

Suggested solutions

There should be something wrong in PhaseOracle implementation, please consider LogicalExpression library when you try to solve this to make it alphabetically ordered correctly.

@mtreinish mtreinish transferred this issue from Qiskit/qiskit-metapackage Jun 2, 2021
@Cryoris
Copy link
Contributor

Cryoris commented Jun 3, 2021

Good catch! That change was not intended (at least no silently). Thanks for reporting this, we're looking into it 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants