Skip to content

Grover's Migration from Aqua to Qiskit Terra #6499

@atilsamancioglu

Description

@atilsamancioglu

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions