forked from Qiskit/qiskit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PhaseOracle and BooleanExpression allow setting the expression variab…
…le order (Qiskit#6658) * Make tweedledum a hard requirement This commit switches the tweedledum requirement from being optional to a hard requirement for installing qiskit-terra. We rely on tweedledum to synthesize phase oracles which is commonly used functionality and several issues have been opened. This use of tweedledum will likely continue to grow so we should just list it as a requirement moving forward. We originally made it optional because the functionality depending on tweedledum was isolated to just the classical function compiler which wasn't widely used. There were also packaging issues in the past where the available precompiled binaries for tweedledum didn't support all of our supported environments, but those have been resolved. There is still an issue for arm64 macOS binaries but Qiskit doesn't have wide support for that yet (although there is a job for terra). At the same time this commit cleans up the optional requirements list so that aer is no longer listed there and we add an 'all' extra so that people can have a simple entypoint to install all the optional extras at once. Fixes Qiskit#6333 Fixes Qiskit#1253 * Remove unused imports * Cleanup docstrings * black setup * Update requirements.txt Co-authored-by: Bruno Schmitt <[email protected]> * User defined variable order for oracle expressions * Fix lint problems * Update qiskit/circuit/classicalfunction/boolean_expression.py Co-authored-by: Luciano Bello <[email protected]> * Tests and bug-fix * black * Add reno * black * Consider order in the parameters * black --------- Co-authored-by: Matthew Treinish <[email protected]> Co-authored-by: Luciano Bello <[email protected]>
- Loading branch information
1 parent
21b875d
commit ecc0289
Showing
4 changed files
with
56 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
releasenotes/notes/expression-var-order-d87e9b04fb5d545c.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
features: | ||
- | | ||
Add the parameter `var_order` when defining a `PhaseOracle`. This allows for defining the order in which the variables in the logical expression are being considered. | ||
.. code-block::python | ||
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)', var_order=['A', 'B', '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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters