Finding All Solutions with Grover’s Algorithm by Integrating Estimation and Discovery
Abstract
:1. Introduction
- We propose an integrated process that combines estimating M and finding all M solutions, optimizing these steps together. The initial step of estimating M can also be used independently (e.g., for finding one or a subset of solutions).
- We implemented the proposed methods and demonstrated their effectiveness across various search space sizes, from N = 23 to 210. Our results show that the first step estimates M more quickly than an existing method while maintaining the same level of accuracy. Additionally, we demonstrated that the combined steps take oracle calls proportional to × log(M) in the worst case, but typically find nearly all solutions with oracle calls proportional to .
- We have made our implementation publicly available, enabling researchers to reuse and extend our work (https://github.com/sihyunglee26/Find-All-Solutions-24 (accessed on 1 November 2024)).
2. Background and Related Work
2.1. Fundamentals of Grover’s Algorithm
2.2. Estimating the Number of Solutions
2.3. Applications of Grover’s Algorithm for Multiple Solutions
3. Proposed Methods for Finding All Solutions
3.1. Overview of Proposed Methods
3.2. Step 1: Estimation of Solution Count, M
Algorithm 1. Algorithm for estimating solution count M |
01 # Amber: Keyword, Green: Variable, Blue: Function 02 # 03 # N: Number of items to search for 04 # n: Number of qubits used to represent N items, ⎡log2(N)⎤ 05 # We assume that n > 1 (i.e., N > 2). 06 # M: Number of solutions among N items 07 # We assume that M . 08 # oracle: Oracle function of target application 09 # G: Grover’s iterator for target application 10 # R: Set of measurements collected by executing Grover’s circuit 11 # S: Set of solutions that have been found so far (i.e., S ⊆ R) 12 # success_count: Number of measurements where solutions are found 13 # k: Constant that determines the number of measurements (i.e., k) 14 # We used k = 10 in our experiments. 15 16 # Estimate M with Grover’s iterator 17 function estimate_solution_count (N, n, oracle) 18 # Initialize circuits and variables 19 create a Grover’s iterator, G, based on n and oracle 20 R = {}, S = {}, success_count = 0 21 22 # Collect k measurements with Grover’s iterator 23 repeat k times: 24 initialize n qubits into an equal superposition 25 apply one iteration of G on n qubits 26 measure n qubits and store the result in R 27 28 for each measurement m in R: 29 if oracle (m) == True: # If m belongs to the solutions 30 S = S {m} 31 success_count += 1 32 33 # Estimate the number of solutions with the measurements 34 = success_count/k # Estimated value of P(1) 35 = N/9 (sin−1())2 # Estimated value of M 36 = max(, |S|) # must be ≥the number of found solutions 37 38 # Return the estimated value of M and found solutions 39 return , S |
3.3. Step 2: Search for All M Solutions
Algorithm 2. Algorithm for finding all M solutions |
01 # Amber: Keyword, Green: Variable, Blue: Function 02 # 03 # N: Number of items to search for 04 # n: Number of qubits used to represent N items, ⎡log2(N)⎤ 05 # We assume that n > 1 (i.e., N > 2). 06 # : Number of solutions estimated in Step 1 07 # S: Set of solutions that have been found so far. This set begins with 08 # solutions found in Step 1 09 # oracle: Oracle function of target application 10 # G: Grover’s iterator for target application 11 # fail_count: Number of consecutive measurements where no new 12 # solutions are measured 13 # max_fail_count: Threshold for fail_count. If fail_count exceeds 14 # max_fail_count, we conclude that no new solution remains and 15 # thus halt the algorithm. 16 17 # Find all M solutions with Grover’s iterator 18 function find_all_solutions (N, n, , S, oracle) 19 # If Step 1 estimated that M = 0, there is no need to find solutions 20 if == 0: return S 21 22 # Initialize circuits and variables 23 = ⎣ + 0.5⎦ # Round to the nearest integer 24 create a Grover’s iterator, G, based on n and oracle 25 fail_count = 0 26 max_fail_count = determine_max_fail_count (S, ) 27 28 # Collect measurements with Grover’s iterator 29 # until no new solution remains 30 while fail_count < max_fail_count: 31 initialize n qubits into an equal superposition 32 apply ⎣π/4 × ⎦ iteration of G on n qubits 33 measure n qubits and store results in m 34 if oracle (m) == True and m ∉ S: # If m is a new solution 35 S = S {m} 36 fail_count = 0 37 max_fail_count = determine_max_fail_count (S, ) 38 else: fail_count += 1 39 40 # Return the found solutions 41 return S 42 43 function determine_max_fail_count (S, ) 44 if |S| == 0: return 10 45 else: 46 if |S|/ == 1: return ⎡ln(0.1)/ln(/( + 1))⎤ 47 else: return ⎡ln(0.1)/ln(|S|/)⎤ |
4. Evaluation
4.1. Evaluation of Step 1: Accuracy and Efficiency in Estimating Solution Count
4.2. Evaluation of Step 2: Comprehensive Discovery and Efficiency of Search Process
4.3. Summary of Evaluation Results for Steps 1 and 2 of Our Proposed Methods
5. Conclusions
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
Appendix A. Expected Proportion of Solutions Found in Step 1
References
- Grover, L.K. A fast quantum mechanical algorithm for database search. In Proceedings of the Twenty-Eighth Annual ACM Symposium on Theory of Computing, Philadelphia, PA, USA, 22–24 May 1996; pp. 212–219. [Google Scholar] [CrossRef]
- Boyer, M.; Brassard, G.; Hoyer, P.; Tapp, A. Tight bounds on quantum searching. Fortschritte der Physik 2005, 46, 187–199. [Google Scholar] [CrossRef]
- Suzuki, Y.; Uno, S.; Raymond, R.; Tanaka, T.; Onodera, T.; Yamamoto, N. Amplitude estimation without phase estimation. Quantum Inf. Process 2020, 19, 75. [Google Scholar] [CrossRef]
- Aaronson, S.; Rall, P. Quantum approximate counting, simplified. In Proceedings of the 2020 Symposium on Simplicity in Algorithms (SOSA), Salt Lake City, UT, USA, 6–7 January 2020; pp. 24–32. [Google Scholar] [CrossRef]
- Balewski, J.; Camps, D.; Klymko, K.; Tritt, A. Efficient quantum counting and quantum content-addressable memory for DNA similarity. In Proceedings of the IEEE International Conference on Quantum Computing and Engineering, Bellevue, WA, USA, 17–22 September 2023; pp. 378–384. [Google Scholar] [CrossRef]
- Widdows, D.; Bhattacharyya, A. Quantum financial modeling on noisy intermediate-scale quantum hardware: Random walks using approximate quantum counting. Quantum Econ. Finance 2024, 1, 5–20. [Google Scholar] [CrossRef]
- Brassard, G.; Hoyer, P.; Tapp, A. Quantum counting. Lect. Notes Comput. Sci. 2006, 1443, 820–831. [Google Scholar] [CrossRef]
- Fernandes, D.; Dutra, I. Using Grover’s search quantum algorithm to solve Boolean satisfiability problems: Part I. ACM Mag. Students 2019, 26, 64–66. [Google Scholar] [CrossRef]
- Saravanan, P.; Jenitha, J.; Sanjana, S.; Haghparast, M. Compact quantum circuit design of PUFFIN and PRINT lightweight ciphers for quantum key recovery attack. IEEE Access 2023, 11, 66767–66776. [Google Scholar] [CrossRef]
- Schwabe, P.; Westerbaan, B. Solving binary MQ with Grover’s algorithm. In Proceedings of the 6th International Conference, SPACE 2016, Hyderabad, India, 14–18 December 2016; pp. 303–322. [Google Scholar] [CrossRef]
- Haverly, A.; Lopez, S. Implementation of Grover’s algorithm to solve the maximum clique problem. In Proceedings of the 2021 IEEE Computer Society Annual Symposium on VLSI (ISVLSI), Tampa, FL, USA, 7–9 July 2021; pp. 441–446. [Google Scholar] [CrossRef]
- Iqbal, B.; Singh, H. Identification of desired pixels in an image using Grover’s quantum search algorithm. arXiv 2021, arXiv:2107.03053. [Google Scholar]
- Borujeni, S.E.; Harikrishnakumar, R.; Nannapaneni, S. Quantum Grover search-based optimization for innovative material discovery. In Proceedings of the IEEE International Conference on Big Data, Los Angeles, CA, USA, 9–12 December 2019; pp. 4486–4489. [Google Scholar] [CrossRef]
- Jiang, J.; Kao, T. Solving Hamiltonian cycle problem with Grover’s algorithm using novel quantum circuit designs. In Proceedings of the IEEE 5th Eurasia Conference on IOT, Communication and Engineering (ECICE), Yunlin, Taiwan, 27–29 October 2023; pp. 796–801. [Google Scholar] [CrossRef]
- Saha, A.; Saha, D.; Chakrabarti, A. Circuit design for k-coloring problem and its Implementation in any dimensional quantum system. SN Comput. Sci. 2021, 2, 427. [Google Scholar] [CrossRef]
- Mukherjee, S. A Grover search-based algorithm for the list coloring problem. IEEE Trans. Quantum Eng. 2022, 3, 3101008. [Google Scholar] [CrossRef]
- Lutze, D. Solving Chromatic Number with Quantum Search and Quantum Counting. Master’s Thesis, Department of Computer Science, California Polytechnic State University, San Luis Obispo, CA, USA, 2021. [Google Scholar] [CrossRef]
- Jiang, J.; Yan, W. Novel quantum circuit designs for the oracle of Grover’s algorithm to solve the vertex cover problem. In Proceedings of the IEEE 5th Eurasia Conference on IOT, Communication and Engineering, Yunlin, Taiwan, 27–29 October 2023; pp. 652–657. [Google Scholar] [CrossRef]
- Jiang, J.; Wang, Y. Quantum circuit based on Grover’s algorithm to solve exact cover problem. In Proceedings of the VTS Asia Pacific Wireless Communications Symposium (APWCS), Tainan city, Taiwan, 23–25 August 2023; pp. 1–5. [Google Scholar] [CrossRef]
- Jiang, J.; Lin, Q. Utilizing novel quantum counters for Grover’s algorithm to solve the dominating set problem. arXiv 2023, arXiv:2312.09388. [Google Scholar]
- Roch, C.; Castillo, S.L.; Linnhoff-Popien, C. A Grover based quantum algorithm for finding pure Nash equilibria in graphical games. In Proceedings of the IEEE 19th International Conference on Software Architecture Companion (ICSA-C), Honolulu, HI, USA, 12–15 March 2022; pp. 147–151. [Google Scholar] [CrossRef]
- Grover, L.K.; Radhakrishnan, J. Quantum search for multiple items using parallel queries. arXiv 2004, arXiv:quant-ph/0407217. [Google Scholar]
- Apeldoorn, J.; Gribling, S.; Nieuwboer, H. Basic quantum subroutines: Finding multiple marked elements and summing numbers. Quantum 2024, 8, 1284–1312. [Google Scholar] [CrossRef]
- Seidel, R.; Becker, C.K.; Bock, S.; Tcholtchev, N.; Gheorghe-Pop, I.; Hauswirth, M. Automatic generation of Grover quantum oracles for arbitrary data structures. Quantum Sci. Technol. 2023, 8, 025003. [Google Scholar] [CrossRef]
- Mandviwalla, A.; Ohshiro, K.; Ji, B. Implementing Grover’s algorithm on the IBM Quantum computers. In Proceedings of the IEEE International Conference on Big Data, Seattle, WA, USA, 10–13 December 2018; pp. 2531–2537. [Google Scholar] [CrossRef]
- Wu, X.; Li, Q.; Li, Z.; Yang, D.; Yang, H.; Pan, W.; Perkowski, M.; Song, X. Circuit optimization of Grover quantum search algorithm. Quantum Inf. Process 2023, 22, 69. [Google Scholar] [CrossRef]
- Lee, S.; Nam, S. Implementation of Grover’s iterator for quantum search with an arbitrary number of qubits. IEEE Access 2024, 12, 43027–43038. [Google Scholar] [CrossRef]
- Park, G.; Zhang, K.; Yu, K.; Korepin, V. Quantum multi-programming for Grover’s search. Quantum Inf. Process. 2023, 22, 54. [Google Scholar] [CrossRef]
- Nielsen, M.A.; Chuang, I.L. Quantum Computation and Quantum Information; Cambridge University Press: Cambridge, UK, 2011. [Google Scholar]
- Qiu, D.; Luo, L.; Xiao, L. Distributed Grover’s algorithm. Theor. Comput. Sci. 2024, 993, 114461. [Google Scholar] [CrossRef]
- Grover, L. Fixed-point quantum search. Phys. Rev. Lett. 2005, 95, 150501–150504. [Google Scholar] [CrossRef]
- Byrnes, T.; Forster, G.; Tessler, L. Generalized Grover’s algorithm for multiple phase inversion states. Phys. Rev. Lett. 2018, 120, 060501–060505. [Google Scholar] [CrossRef]
- Yan, B.; Wei, S.; Jiang, H.; Wang, H.; Duan, Q.; Ma, Z.; Long, G. Fixed-point oblivious quantum amplitude-amplification algorithm. Sci. Rep. 2022, 12, 14339. [Google Scholar] [CrossRef]
- Motwani, R.; Raghavan, P. The coupon collector’s problem. Randomized Algorithms; Cambridge University Press: Cambridge, UK, 1995; pp. 57–63. [Google Scholar]
- Implementation of Quantum Counting Based on Qiskit Library. Available online: https://github.com/Qiskit/textbook/blob/main/notebooks/ch-algorithms/quantum-counting.ipynb (accessed on 20 October 2024).
- Chung, N.; Nepomechie, R.I. Quantum counting, and a relevant sign. arXiv 2023, arXiv:2310.07428. [Google Scholar]
- Qiskit: Open-Source Toolkit for Quantum Development. Available online: https://qiskit.org (accessed on 20 October 2024).
- AerSimulator. Available online: https://qiskit.org/ecosystem/aer/stubs/qiskit_aer.AerSimulator.html (accessed on 20 October 2024).
- Gubernatis, J.; Kawashima, N.; Werner, P. Quantum Montel Carlo Methods; Cambridge University Press: Cambridge, UK, 2016. [Google Scholar]
ID | Application Domain | Use Case |
---|---|---|
1 | Database Search | In a database, find all records that meet a given condition (e.g., “select * from table_name where condition is true”). |
2 | Security | In computer applications, identify as many vulnerabilities as possible and patch them promptly to reduce the risk of compromise and potential loss. |
3 | Image Processing | In a network of surveillance cameras, find all video snapshots that show characteristics of a suspect following a crime to help the police track the suspect’s whereabouts. |
4 | Astronomy | In an astronomical catalog, identify all planets where life may exist to understand the distribution of such planets in space. |
5 | Biology | In a collection of genetic information, find all genetic markers associated with a particular symptom to develop a medicine that cures the symptom. |
ID | Objective | How We Fulfill the Objective and Results |
---|---|---|
1 | (Step 1) Quickly and accurately estimate the number of solutions M |
|
2 | (Step 2) Discover as many solutions as possible without missing any |
|
3 | Optimize Steps 1 and 2 together |
|
Term | Description |
---|---|
G | Grover’s Iterator—A combination of the oracle and amplification processes used to increase the probability of target items in Grover’s search algorithm. Gi indicates that G is applied i times. |
H | Hadamard Operator—A fundamental quantum operator used to create superposition. H⊗n means n Hadamard operators applied in parallel on n qubits, one operator per qubit. |
M | Solution Count—The number of solutions in the search space, assumed to be , as explained in Section 3.1. |
Estimated M—The value of M is estimated by an algorithm. This can match or differ from the actual M. | |
N | Search Space Size—The total number of elements in the search space. |
n | Qubit Count—The number of qubits used to represent the search space, equal to ⎡log2(N)⎤ |
QFT | Quantum Fourier Transform—A quantum version of Fourier Transform used in many quantum algorithms. QFT† refers to its inverse. |
max_fail_count | Termination Threshold—A threshold in the proposed search algorithm. If no solution is found after max_fail_count consecutive attempts, the algorithm terminates, assuming that no more solutions exist. |
Search Space Size N | Solution Count ] | Quantum Counting | Proposed Method | |
---|---|---|---|---|
# of Counting Qubits t | Average Error | Average Error | ||
23 = 8 | [0, 2] | 2 | 1.1667 | 0.1138 |
24 = 16 | [0, 4] | 3 | 0.8063 | 0.1942 |
25 = 32 | [0, 5] | 3 | 1.1064 | 0.2373 |
26 = 64 | [0, 8] | 4 | 1.5952 | 0.3094 |
27 = 128 | [0, 11] | 4 | 2.6244 | 0.3460 |
28 = 256 | [0, 16] | 5 | 2.3095 | 0.5409 |
29 = 512 | [0, 22] | 5 | 3.0526 | 0.8868 |
Search Space Size 2n = N | Quantum Counting | Proposed Method | |||
---|---|---|---|---|---|
# of Counting Qubits t | # of Grover’s Iterations (=10 (2t − 1)) | Average Error | # of Grover’s Iterations (=10) | Average Error | |
23 = 8 | 2 | 30 | 1.1667 | 28 | 0.1138 |
3 | 70 | 0.3333 | |||
4 | 150 | 0.2196 | |||
5 | 310 | 0.1462 | |||
24 = 16 | 3 | 70 | 0.8063 | 40 | 0.1942 |
4 | 150 | 0.4803 | |||
5 | 310 | 0.3614 | |||
6 | 630 | 0.1162 | |||
25 = 32 | 3 | 70 | 1.1064 | 56 | 0.2373 |
4 | 150 | 0.6184 | |||
5 | 310 | 0.3725 | |||
6 | 630 | 0.2259 | |||
26 = 64 | 4 | 150 | 1.5952 | 80 | 0.3094 |
5 | 310 | 0.7906 | |||
6 | 630 | 0.4205 | |||
7 | 1270 | 0.1967 | |||
27 = 128 | 4 | 150 | 2.6244 | 113 | 0.3460 |
5 | 310 | 1.0868 | |||
6 | 630 | 0.6013 | |||
7 | 1270 | 0.3934 | |||
28 = 256 | 5 | 310 | 2.3095 | 160 | 0.5409 |
6 | 630 | 0.9626 | |||
7 | 1270 | 0.5384 | |||
29 = 512 | 5 | 310 | 3.0526 | 226 | 0.8868 |
6 | 630 | 1.6082 | |||
7 | 1270 | 0.9045 |
Search Space Size N | Solution Count ] | Previous Method | Proposed Method |
---|---|---|---|
23 = 8 | [1, 2] | 98.67% | 100.00% |
24 = 16 | [1, 4] | 97.50% | 100.00% |
25 = 32 | [1, 5] | 95.27% | 100.00% |
26 = 64 | [1, 8] | 92.53% | 100.00% |
27 = 128 | [1, 11] | 91.45% | 99.98% |
28 = 256 | [1, 16] | 86.53% | 99.95% |
29 = 512 | [1, 22] | 79.45% | 99.42% |
210 = 1024 | [1, 32] | 71.32% | 99.13% |
Search Space Size N | Previous Method | Proposed Method | ||
---|---|---|---|---|
Average # of Grover’s Iterations | Discovery Percentage | Average # of Grover’s Iterations | Discovery Percentage | |
23 = 8 | 2.64 | 98.67% | 6.95 | 100.00% |
24 = 16 | 6.86 | 98.50% | 10.86 | 100.00% |
25 = 32 | 12.66 | 97.93% | 16.41 | 100.00% |
26 = 64 | 29.65 | 98.67% | 28.47 | 100.00% |
27 = 128 | 52.82 | 98.89% | 42.66 | 99.98% |
28 = 256 | 106.41 | 98.88% | 70.67 | 99.95% |
29 = 512 | 186.84 | 98.20% | 102.20 | 99.42% |
210 = 1024 | 306.77 | 97.89% | 137.15 | 99.13% |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2024 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Lee, S.; Nam, S.Y. Finding All Solutions with Grover’s Algorithm by Integrating Estimation and Discovery. Electronics 2024, 13, 4830. https://doi.org/10.3390/electronics13234830
Lee S, Nam SY. Finding All Solutions with Grover’s Algorithm by Integrating Estimation and Discovery. Electronics. 2024; 13(23):4830. https://doi.org/10.3390/electronics13234830
Chicago/Turabian StyleLee, Sihyung, and Seung Yeob Nam. 2024. "Finding All Solutions with Grover’s Algorithm by Integrating Estimation and Discovery" Electronics 13, no. 23: 4830. https://doi.org/10.3390/electronics13234830
APA StyleLee, S., & Nam, S. Y. (2024). Finding All Solutions with Grover’s Algorithm by Integrating Estimation and Discovery. Electronics, 13(23), 4830. https://doi.org/10.3390/electronics13234830