microquantum.problems.search¶
Generic search problem abstraction.
A SearchProblem describes an unstructured database search: find one
(or more) of the 2^num_qubits computational basis states that satisfy a
predicate. The predicate can be supplied three different ways (at most one):
target— an integer index (or list of indices) of the sought state(s);oracle— a callableoracle(num_qubits) -> QuantumCircuitmarking the solution subspace;predicate— a callablepredicate(index) -> boolover the integer index of a computational basis state; used to classically expand the marked set.
The problem stays decoupled from the algorithm (e.g. Grover).
Module Contents¶
- class microquantum.problems.search.SearchProblem[source]¶
Bases:
microquantum.problems.base.ProblemSearch the
2^num_qubits-element database for marked state(s).Exactly one of
target/oracle/predicateshould be given.- Variables:
num_qubits – Size of the search register.
target – Integer, list of integers, or MSB-first bitstring (e.g.
"101") identifying the solution basis state(s). Bitstrings are normalized to integers on construction.oracle – Callable returning a circuit that marks the solutions.
predicate – Callable
predicate(bitstring) -> bool.num_targets – Number of marked states (only used for the optimal iteration estimate when
num_qubitsis set without a target).