Skip to content

Make a GroverRunner to execute the entire workflow #4

Description

@neriAle

Make a GroverRunner class that takes as input an instance of subset sum (a list of positive numbers numbers, and a positive number target) and it should:

  1. Create an oracle through an instance of SubsetSumOracle, by passing numbers and target as arguments
  2. Define a verifier method, which takes as input a list of numbers subset (of 0's and 1's) and returns true if the sum of numbers multiplied by the 0 or 1 at the same index of subset is equal to target, defined as:
def verifier(subset):
        return sum(w * s for w, s in zip(numbers, subset)) == target
  1. Estimate the number of solutions through phase estimation using SolutionEstimator (still TODO see Make a SolutionEstimator using phase estimation #5 )
  2. Create a quantum circuit through an instance GroverSolver, passing as arguments the oracle, the length of numbers, the verifier method and the backend that we want to use to run it (AerSimulator() for tests and quantum-inspire or IBM for the official run).
  3. Run the generated quantum circuit with the computed number of solution, using run_known_solutions(), using the estimated number of solutions
  4. Plot an histogram with the results of the simulations and return the top 1 most frequent solution (or the top k where k is the number of estimated solutions)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions