Search method, device, storage medium and electronic device based on quantum genetic algorithm
Through the combination of quantum logic gates and circuits, the diversity and convergence of quantum genetic algorithms are realized, which solves the problem of group optimization algorithms falling into local optimality and improves search accuracy and computing efficiency.
Patent Information
- Application Number
- CN202310234167.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-07
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2043-03-07
AI Technical Summary
Existing group optimization algorithms are prone to falling into local optima during the search process, resulting in poor search accuracy and convergence, and difficulty in improving computational efficiency.
A quantum genetic algorithm based on quantum logic gates is used. Through a combination of quantum random search circuits, amplitude amplification circuits and logic gates, the diversity and convergence of the quantum genetic algorithm are achieved, and the parallelism of quantum computing is used to improve computing efficiency.
It significantly improves the search performance of the quantum genetic algorithm, enhances diversity and convergence, improves computing efficiency, and can more effectively jump out of the local optimal solution and find the global optimal solution.
Smart Images

Figure CN116523064B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a search method, device, storage medium and electronic device based on a quantum genetic algorithm. Background Art
[0002] Search problems exist widely in various business scenarios, such as path optimization, workshop scheduling, and asset allocation. The current mainstream solutions include genetic algorithms, particle swarm algorithms, and ant colony algorithms. Genetic algorithms, ant colony algorithms, and particle swarm algorithms are all swarm optimization algorithms, which means that we will set up many individuals in the solution space at the same time and then form a group to search for the optimal solution. For example, we now have a task, and there are many people around searching, not just one person. In genetic algorithms, multiple individuals form a population, ants in ant colony algorithms, and particles in particle swarm algorithms are all manifestations of swarm optimization algorithms.
[0003] The applicant found that in the process of optimizing the above algorithm, it is inevitable to fall into the local optimum, which will affect the final search accuracy of the algorithm. Although relevant technicians have adopted many improvement strategies, the convergence and diversity of the algorithm are still poor, and the computational efficiency is still difficult to improve. Summary of the invention
[0004] The embodiments of the present application provide a search method, device, storage medium and electronic device based on a quantum genetic algorithm, which can use quantum logic gates to achieve the diversity and convergence of the quantum genetic algorithm. At the same time, the parallelism of quantum computing can significantly improve the computational efficiency of the quantum genetic algorithm.
[0005] The present application embodiment provides a search method based on a quantum genetic algorithm, comprising:
[0006] During the iteration of the quantum genetic algorithm, the search is performed in the search space according to the quantum random search circuit, and the quantum state is output;
[0007] marking the quantum state by a first logic gate;
[0008] performing probability amplitude amplification processing on the quantum state of the mark according to the amplitude amplification circuit;
[0009] The quantum state obtained after processing is transcoded, and the accuracy of the output value obtained after transcoding is verified by a preset function;
[0010] If the accuracy is higher than the accuracy after the previous iteration, the solution corresponding to the current quantum state is taken as the optimal solution.
[0011] In one embodiment, marking the quantum state by a first logic gate comprises:
[0012] Transcoding the quantum state, and verifying the accuracy of the output value obtained after the transcoding by using a preset function;
[0013] During the first N iterations of the quantum genetic algorithm, the above steps are repeatedly performed, wherein the circuit is measured 100 times in each iteration to obtain 100*N quantum states and corresponding precisions;
[0014] The quantum state with the highest precision is selected as the target quantum state from the 100*N quantum states, and the target quantum state is marked through a first logic gate.
[0015] In one embodiment, after the amplitude amplification circuit performs probability amplitude amplification processing on the quantum state of the tag, the method further includes:
[0016] The quantum state after the amplification process is disturbed by randomly adding the second logic gate and the third logic gate, so as to realize the local fine search function of the quantum genetic algorithm.
[0017] In one embodiment, after taking the solution corresponding to the current quantum state as the optimal solution, the method further includes:
[0018] Marking the optimal solution through a first logic gate and continuing to perform subsequent iterations;
[0019] When the number of iterations reaches a preset number of iterations, the marked optimal solution is taken as the global optimal solution.
[0020] In one embodiment, the output of the random search circuit is expressed by the following formula:
[0021]
[0022] Wherein, the random search circuit comprises two quantum bits, Represents two Hadamard gates acting in parallel.
[0023] In one embodiment, the output of the amplitude amplification circuit is expressed by the following formula:
[0024]
[0025] Among them, the marked quantum state is "11", Represents two Pauli-Z gates acting in parallel.
[0026] In one embodiment, the quantum state is transcoded by the following formula:
[0027] x=x1×2 5 +x2×2 4 +x3×23 +x4×2 2 +x5×2 1 +x6×2 0
[0028] Among them, x1x2x3x4x5x6 is the output result of the quantum circuit, x is a decimal number, and then x is mapped to the search space:
[0029]
[0030] Among them, a and b represent the upper limit and lower limit of the search space respectively, and o represents the final result after mapping.
[0031] The embodiment of the present application also provides a search device based on a quantum genetic algorithm, comprising:
[0032] A search module, used to search in the to-be-searched space according to the quantum random search circuit during the iteration of the quantum genetic algorithm, and output the quantum state;
[0033] A marking module, used for marking the quantum state through a first logic gate;
[0034] an amplification module, used for performing probability amplitude amplification processing on the quantum state of the mark according to the amplitude amplification circuit;
[0035] A transcoding module is used to transcode the quantum state obtained after processing, and verify the accuracy of the output value obtained after transcoding through a preset function;
[0036] The output module is used to take the solution corresponding to the current quantum state as the optimal solution when the accuracy is higher than the accuracy after the previous iteration.
[0037] An embodiment of the present application further provides a storage medium, wherein the storage medium stores a computer program, and the computer program is suitable for being loaded by a processor to execute the steps in the search method based on a quantum genetic algorithm as described in any of the above embodiments.
[0038] An embodiment of the present application also provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor executes the steps in the search method based on the quantum genetic algorithm as described in any of the above embodiments by calling the computer program stored in the memory.
[0039] The search method, device, storage medium and electronic device based on quantum genetic algorithm provided by the embodiment of the present application can search in the space to be searched according to the quantum random search circuit during the iteration of the quantum genetic algorithm, and output the quantum state, mark the quantum state through the first logic gate, perform probability amplitude amplification processing on the marked quantum state according to the amplitude amplification circuit, transcode the quantum state obtained after the processing, and verify the accuracy of the output value obtained after transcoding through a preset function. If the accuracy is higher than the accuracy after the previous iteration, the solution corresponding to the current quantum state is used as the optimal solution. The embodiment of the present application can use quantum logic gates to realize the diversity and convergence of the quantum genetic algorithm, and the parallelism of quantum computing can significantly improve the computational efficiency of the quantum genetic algorithm. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0041] Figure 1 A schematic diagram of a flow chart of a search method based on a quantum genetic algorithm provided in an embodiment of the present application.
[0042] Figure 2 A schematic diagram of a quantum genetic algorithm random search circuit provided in an embodiment of the present application.
[0043] Figure 3 A schematic diagram of a quantum tag circuit provided in an embodiment of the present application.
[0044] Figure 4 Schematic diagram of quantum circuits corresponding to different quantum states provided in the embodiments of the present application.
[0045] Figure 5 A schematic diagram of an amplitude amplification circuit provided in an embodiment of the present application.
[0046] Figure 6 A schematic diagram of a convergence circuit provided in an embodiment of the present application.
[0047] Figure 7 A schematic diagram of the operating results of the amplitude amplification circuit provided in an embodiment of the present application.
[0048] Figure 8 Another flowchart of a search method based on a quantum genetic algorithm provided in an embodiment of the present application.
[0049] Fig. 9 A schematic diagram comparing the fitness of the quantum genetic algorithm and the traditional genetic algorithm provided in the embodiment of the present application.
[0050] Fig.10 A schematic diagram of the quantum computer measurement results provided in an embodiment of the present application.
[0051] Fig.11 A schematic diagram of the structure of a search device based on a quantum genetic algorithm provided in an embodiment of the present application.
[0052] Fig.12 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0053] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0054] The embodiments of the present application provide a search method, device, storage medium and electronic device based on quantum genetic algorithm. Specifically, the search method based on quantum genetic algorithm of the embodiments of the present application can be performed by an electronic device, wherein the electronic device can be a terminal. The terminal can be a terminal device such as a smart phone, a tablet computer, a laptop computer, a touch screen, a game console, a personal computer (PC, Personal Computer), a personal digital assistant (Personal Digital Assistant, PDA), etc. The terminal can also include a client, which can be a media playback client or an instant messaging client, etc.
[0055] See also Figure 1 , the specific process of this method can be as follows:
[0056] Step 101, during the iteration of the quantum genetic algorithm, a search is performed in the to-be-searched space according to a quantum random search circuit, and a quantum state is output.
[0057] In the embodiment of the present application, the quantum genetic algorithm iteration process needs to be continued for many times. In the early stage of the quantum genetic algorithm iteration, a quantum genetic algorithm random search circuit can be proposed to search in the search space. The schematic diagram of the quantum genetic algorithm random search circuit is as shown in FIG. Figure 2 As shown, two quantum bits are used in the random search circuit, and the output of the random search circuit is expressed by the following formula:
[0058]
[0059] in, Indicates two Hadamard gates acting in parallel. The Hadamard gate is a quantum logic gate that can transform the ground state into a superposition state, referred to as the H gate.
[0060] It should be noted that the probability amplitude of each quantum state output by the random search circuit of the quantum genetic algorithm is equal, indicating that after measurement, this quantum circuit will obtain one of the four states from "00" to "11" with the same random probability, without any bias. Therefore, the quantum random search circuit can make the chromosomes fully distributed in the search space in the early stage of iteration, thereby increasing the possibility of the quantum genetic algorithm searching for the global optimal solution.
[0061] Step 102: Mark the quantum state through a first logic gate.
[0062] In one embodiment, the first logic gate may be a Pauli-Z gate, or Z gate for short, whose matrix form is a Pauli matrix. In the later stage of the quantum genetic algorithm iteration, a controlled Z gate may be used to mark the optimal solution searched by the random search circuit of the quantum genetic algorithm. Taking the quantum state "11" as an example, its quantum marking circuit is as follows: Figure 3 shown.
[0063] In this embodiment, Figure 3 The third quantum bit is an auxiliary quantum bit and does not perform measurement operations. The mathematical expression of the quantum tag circuit is:
[0064]
[0065] Therefore, the output for the first two qubits is:
[0066]
[0067] If the solution needs to be marked in other forms, the corresponding quantum circuit is given in this invention. Figure 4 , which are quantum circuits of the “00” quantum state, the “01” quantum state, and the “10” quantum state respectively.
[0068] Step 103, performing probability amplitude amplification processing on the marked quantum state according to the amplitude amplification circuit.
[0069] In one embodiment, the present application also provides an amplitude amplification circuit. For a circuit diagram, please refer to Figure 5 , where if the marked quantum state is the "11" state, the output of the amplitude amplifier circuit is:
[0070]
[0071] in, It means that two Pauli-Z gates act in parallel. After the marked "11" quantum state passes through the amplitude amplification circuit, its corresponding probability amplitude is amplified, and the probability amplitudes of other quantum states are reduced, thereby achieving the convergence effect of the quantum genetic algorithm.
[0072] In one embodiment, taking 7 qubits as an example, the convergence circuit of the quantum genetic algorithm can be found in Figure 6 , specifically, Figure 6 The quantum state marked in is "011010", the 7th qubit is an auxiliary qubit, and only the lower six qubits are measured. After the "011010" quantum state passes through the amplitude amplification circuit, its probability amplitude is amplified, which can be verified by running this circuit. Shot can be set to 1024.
[0073] Furthermore, Figure 7 This is the operating result of the amplitude amplification circuit. As can be seen from the figure, the probability of the "011010" quantum state is the highest. Although the probability amplitude of the marked quantum state is the highest, it does not reach 100%, indicating that the measured quantum state will still have deviations. This deviation can ensure the population diversity to a considerable extent even in the later stage of iteration of the quantum genetic algorithm, thereby improving the ability of the quantum genetic algorithm to jump out of the local optimum, which has significant advantages over the traditional genetic algorithm.
[0074] Step 104, transcoding the quantum state obtained after the processing, and verifying the accuracy of the output value obtained after the transcoding by a preset function.
[0075] In one embodiment, the quantum states obtained by the random search circuit of the quantum genetic algorithm and the convergence circuit of the quantum genetic algorithm can be transcoded. The present application sets the shot value of the above two quantum circuits to 100, indicating that the population of the quantum genetic algorithm contains 100 chromosomes, and each chromosome needs to be transcoded. Specifically, the quantum state can be transcoded by the following formula:
[0076] x=x1×2 5 +x2×2 4 +x3×2 3 +x4×2 2 +x5×2 1 +x6×2 0
[0077] Among them, x1x2x3x4x5x6 is the output result of the quantum circuit, x is a decimal number, and then x is mapped to the search space:
[0078]
[0079] Among them, a and b represent the upper limit and lower limit of the search space respectively, and o represents the final result after mapping.
[0080] Step 105: If the accuracy is higher than the accuracy after the previous iteration, the solution corresponding to the current quantum state is taken as the optimal solution.
[0081] After the transcoding is completed, the accuracy of the output value obtained after transcoding can be calculated through a preset function. If the accuracy is higher than the accuracy after the previous iteration, the optimal solution can be updated, that is, the solution corresponding to the current quantum state is used as the optimal solution. If the accuracy is not higher than the accuracy after the previous iteration, the quantum state obtained after the previous iteration can continue to be used as the optimal solution.
[0082] The quantum genetic algorithm provided by the present application has significant advantages in population diversity compared to traditional genetic algorithms and other optimization algorithms, while also taking into account convergence, indicating that the quantum genetic algorithm has a better performance in search performance. In addition, the quantum genetic algorithm proposed in the present application has a shallow circuit depth and uses fewer quantum bits, which is suitable for current quantum computers with medium quantum bit scales with noise. At the same time, the noise generated by current quantum computers during calculations is interference for other algorithms, but for the quantum genetic algorithm proposed in the present invention, it further improves population diversity, indicating that the algorithm proposed in the present invention has a higher practical application value.
[0083] As can be seen from the above, the search method based on the quantum genetic algorithm provided by the embodiment of the present application can search in the space to be searched according to the quantum random search circuit during the iteration of the quantum genetic algorithm, and output the quantum state, mark the quantum state through the first logic gate, and perform probability amplitude amplification processing on the marked quantum state according to the amplitude amplification circuit, transcode the quantum state obtained after the processing, and verify the accuracy of the output value obtained after transcoding through a preset function. If the accuracy is higher than the accuracy after the previous iteration, the solution corresponding to the current quantum state is used as the optimal solution. The embodiment of the present application can use quantum logic gates to realize the diversity and convergence of the quantum genetic algorithm, and the parallelism of quantum computing can significantly improve the computational efficiency of the quantum genetic algorithm.
[0084] See also Figure 8 , is another flow chart of a search method based on a quantum genetic algorithm provided in an embodiment of the present application. The specific flow of the method may be as follows:
[0085] Step 201, during the iteration of the quantum genetic algorithm, a search is performed in the to-be-searched space according to a quantum random search circuit, and a quantum state is output.
[0086] In one embodiment, the present application can use a quantum genetic algorithm random search circuit to search in the search space in the early stage of quantum genetic algorithm iteration. For example, the first 20 iterations can be set as the early stage to obtain the quantum state outputted in each of the 20 iterations.
[0087] Step 202, transcode the quantum state, and verify the accuracy of the output value obtained after transcoding through a preset function.
[0088] Step 203: During the first N iterations of the quantum genetic algorithm, the above steps are repeatedly performed to obtain 100*N quantum states and corresponding accuracies.
[0089] Step 204 , selecting the quantum state with the highest accuracy from the 100*N quantum states as the target quantum state, and marking the target quantum state through a first logic gate.
[0090] Specifically, in the above iterative process, the circuit measures 100 times in each iteration, so 100*N quantum states and corresponding accuracies can be obtained, and then the quantum state with the highest accuracy is selected from the 100*N quantum states as the target quantum state, and the target quantum state is marked through the first logic gate.
[0091] In one embodiment, a transcoding operation can be performed on the quantum state obtained after each iteration, and the transcoded results are input into the function in turn to verify their accuracy, and then the solution with the highest accuracy in the first N iterations is selected and marked using a quantum marking circuit, wherein this preferred embodiment can be set to N=20.
[0092] Step 205, performing probability amplitude amplification processing on the marked quantum state according to the amplitude amplification circuit.
[0093] Furthermore, in the later stage of the quantum genetic algorithm iteration, an amplitude amplification circuit may be used to amplify the amplitude of the quantum state marked in step 204, wherein the present application may set the number of iterations greater than 20 as the later stage.
[0094] In one embodiment, the present application can also realize the local fine search function by randomly adding Pauli-X gates and randomly adding SWAP gates, such as perturbing the "011010" quantum state by randomly acting on the Pauli-X gate and the SWAP gate, thereby realizing the local fine search function of the quantum genetic algorithm. That is, after the marked quantum state is subjected to probabilistic amplitude amplification processing according to the amplitude amplification circuit, the method can also include: perturbing the amplified quantum state by randomly adding the second logic gate and the third logic gate to realize the local fine search function of the quantum genetic algorithm.
[0095] Step 206, transcoding the quantum state obtained after the processing, and verifying the accuracy of the output value obtained after the transcoding by a preset function.
[0096] Step 207: If the accuracy is higher than the accuracy after the last iteration, the solution corresponding to the current quantum state is taken as the optimal solution.
[0097] In one embodiment, a transcoding operation is performed on the quantum state obtained after each iteration, and the transcoded results are sequentially input into the function for verification. If the accuracy is improved, the current optimal solution is updated, and the solution is marked using a quantum marking circuit.
[0098] Step 208, marking the optimal solution through the first logic gate, and continuing to perform subsequent iterations. When the number of iterations reaches a preset number of iterations, the marked optimal solution is used as the global optimal solution.
[0099] The above steps are repeated in a cycle until a preset maximum number of iterations is reached, and the optimal solution finally marked is used as the global optimal solution. In this application, the maximum number of iterations can be set to 200.
[0100] In order to better illustrate the algorithm proposed in the present invention, the optimization of the test function Bukin Function N.6 is taken as an example. The Bukin Function N.6 function has multiple local minima and a global minimum. The traditional optimization algorithm is very easy to fall into a "deceptive" local optimum during the optimization process and cannot find the global optimal solution. This application uses a traditional genetic algorithm and a quantum genetic algorithm for comparison. To ensure fairness, the maximum number of iterations for both algorithms can be set to 200, the number of chromosomes in the population is 100, the search space is the same, and the chromosome length is the same. In order to help the traditional genetic algorithm increase the possibility of jumping out of the local optimum, the present invention adds a roulette strategy to the traditional genetic algorithm. The traditional genetic algorithm is set as follows:
[0101] (1) The number of chromosomes is set to 100, the chromosome length is set to 6, and then 0 or 1 is randomly generated and filled into the chromosome;
[0102] (2) Convert the binary number in the chromosome into decimal and then substitute it into the Bukin Function N.6 function to calculate the fitness;
[0103] (3) A new generation of population is generated through crossover, mutation and roulette strategy. The roulette strategy allows chromosomes with greater fitness to be selected into the next generation with a certain probability, thereby increasing the algorithm's ability to escape from the local optimum.
[0104] The quantum genetic algorithm uses a random search circuit in the first 20 iterations and a convergence circuit thereafter. Fig. 9 As shown. Fig. 9 It is observed that the fitness of the quantum genetic algorithm is smaller, indicating that the quantum genetic algorithm has searched for a better solution. In order to eliminate the influence of randomness, the present invention uses the traditional genetic algorithm and the quantum genetic algorithm in Bukin Function N.6, The table and Cross-in-Tray test functions were run 20 times respectively, and the results are shown in the following table:
[0105]
[0106] As can be seen from the table above, the quantum genetic algorithm can achieve the global minimum in each of the 20 tests, indicating that the excellent population diversity of the quantum genetic algorithm can significantly improve its ability to jump out of the local optimum and then find the global optimal solution. The comparison results also show that the quantum genetic algorithm has a significant advantage over the traditional genetic algorithm in search performance.
[0107] The quantum genetic algorithm proposed in this application can also run on real quantum hardware because the circuit is shallow and the number of quantum bits is small. This application can be tested using an ibm_oslo quantum computer, which has an average read and write error of 1.990*10-2, a CNOT gate error of 8.148*10-3, and 7 quantum bits. Use a quantum marking circuit to mark the quantum state "101001", and then use an amplitude amplification circuit to amplify the probability amplitude, set shot = 100 times, and the computer measurement results are as follows Fig.10 As shown, from Fig.10 It can be observed that the marked quantum state can be well distinguished from other quantum states, indicating that the quantum genetic algorithm proposed in the present invention can also achieve good results on the current quantum computer with medium quantum bit scale and noise.
[0108] All of the above technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described in detail here.
[0109] It can be seen from the above that the search method based on the quantum genetic algorithm provided in the embodiment of the present application can search in the space to be searched according to the quantum random search circuit during the iteration of the quantum genetic algorithm, and output the quantum state, transcode the quantum state, and verify the accuracy of the output value obtained after transcoding through a preset function. In the first N iterations of the quantum genetic algorithm, the above steps are repeated to obtain 100*N quantum states and the corresponding accuracy, and the quantum state with the highest accuracy is selected from the 100*N quantum states as the target quantum state, and the target quantum state is marked through the first logic gate, and the marked quantum state is subjected to probability amplitude amplification processing according to the amplitude amplification circuit, and the quantum state obtained after the processing is transcoded, and the accuracy of the output value obtained after transcoding is verified through a preset function. If the accuracy is higher than the accuracy after the previous iteration, the solution corresponding to the current quantum state is taken as the optimal solution, and the optimal solution is marked through the first logic gate, and the subsequent iterations are continued. When the number of iterations reaches the preset number of iterations, the marked optimal solution is taken as the global optimal solution. The embodiments of the present application can utilize quantum logic gates to realize the diversity and convergence of the quantum genetic algorithm. At the same time, the parallelism of quantum computing can significantly improve the computational efficiency of the quantum genetic algorithm.
[0110] In order to better implement the search method based on quantum genetic algorithm in the embodiment of the present application, the embodiment of the present application also provides a search device based on quantum genetic algorithm. Fig.11 , Fig.11 A schematic diagram of a structure of a search device based on a quantum genetic algorithm provided in an embodiment of the present application. The search device based on a quantum genetic algorithm may include:
[0111] A search module 301 is used to search in the to-be-searched space according to a quantum random search circuit during the iteration of the quantum genetic algorithm, and output a quantum state;
[0112] A marking module 302, configured to mark the quantum state through a first logic gate;
[0113] an amplification module 303, configured to perform probability amplitude amplification processing on the quantum state of the marker according to an amplitude amplification circuit;
[0114] A transcoding module 304 is used to transcode the quantum state obtained after processing, and verify the accuracy of the output value obtained after transcoding through a preset function;
[0115] The output module 305 is used to take the solution corresponding to the current quantum state as the optimal solution when the accuracy is higher than the accuracy after the previous iteration.
[0116] All of the above technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described in detail here.
[0117] As can be seen from the above, the search device based on the quantum genetic algorithm provided by the embodiment of the present application searches in the space to be searched according to the quantum random search circuit during the iteration of the quantum genetic algorithm, and outputs the quantum state, marks the quantum state through the first logic gate, performs probability amplitude amplification processing on the marked quantum state according to the amplitude amplification circuit, transcodes the quantum state obtained after the processing, verifies the accuracy of the output value obtained after the transcoding through a preset function, and if the accuracy is higher than the accuracy after the previous iteration, the solution corresponding to the current quantum state is used as the optimal solution. The embodiment of the present application can use quantum logic gates to realize the diversity and convergence of the quantum genetic algorithm, and the parallelism of quantum computing can also significantly improve the computational efficiency of the quantum genetic algorithm.
[0118] Accordingly, the embodiment of the present application also provides an electronic device, which may be a terminal or a server, and the terminal may be a smart phone, a tablet computer, a laptop computer, a touch screen, a game console, a personal computer (PC), a personal digital assistant (PDA), or other terminal devices. Fig.10 As shown, Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 400 includes a processor 401 having one or more processing cores, a memory 402 having one or more storage media, and a computer program stored in the memory 402 and executable on the processor. The processor 401 is electrically connected to the memory 402. Those skilled in the art will appreciate that the electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown, or combine certain components, or arrange components differently.
[0119] The processor 401 is the control center of the electronic device 400. It uses various interfaces and lines to connect various parts of the entire electronic device 400, executes various functions of the electronic device 400 and processes data by running or loading software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, thereby monitoring the electronic device 400 as a whole.
[0120] In the embodiment of the present application, the processor 401 in the electronic device 400 will load instructions corresponding to the processes of one or more application programs into the memory 402 according to the following steps, and the processor 401 will run the application programs stored in the memory 402 to implement various functions:
[0121] During the iteration of the quantum genetic algorithm, the search is performed in the search space according to the quantum random search circuit, and the quantum state is output;
[0122] marking the quantum state by a first logic gate;
[0123] Performing probability amplitude amplification processing on the quantum state of the mark according to the amplitude amplification circuit;
[0124] The processed quantum state is transcoded, and the accuracy of the output value obtained after transcoding is verified by a preset function;
[0125] If the accuracy is higher than the accuracy after the previous iteration, the solution corresponding to the current quantum state is taken as the optimal solution.
[0126] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0127] Optional, such as Fig.10 As shown, the electronic device 400 further includes: a touch screen 403, a radio frequency circuit 404, an audio circuit 405, an input unit 406, and a power supply 407. The processor 401 is electrically connected to the touch screen 403, the radio frequency circuit 404, the audio circuit 405, the input unit 406, and the power supply 407, respectively. Those skilled in the art can understand that Fig.10 The electronic device structure shown in the figure does not constitute a limitation of the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0128] The touch display screen 403 can be used to display a graphical user interface and receive operation instructions generated by the user acting on the graphical user interface. The touch display screen 403 may include a display panel and a touch panel. Among them, the display panel may be used to display information input by the user or information provided to the user and various graphical user interfaces of the electronic device, and these graphical user interfaces may be composed of graphics, text, icons, videos and any combination thereof. Optionally, the display panel may be configured in the form of a liquid crystal display (LCD, Liquid Crystal Display), an organic light-emitting diode (OLED, Organic Light-Emitting Diode) and the like. The touch panel may be used to collect the user's touch operation on or near it (such as the user using any suitable object or attachment such as a finger, a stylus, etc. on the touch panel or near the touch panel), and generate corresponding operation instructions, and the operation instructions execute corresponding programs. Optionally, the touch panel may include two parts, a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 401, and can receive the command sent by the processor 401 and execute it. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it is transmitted to the processor 401 to determine the type of touch event, and then the processor 401 provides a corresponding visual output on the display panel according to the type of touch event. In an embodiment of the present application, the touch panel and the display panel can be integrated into the touch display screen 403 to realize the input and output functions. However, in some embodiments, the touch panel and the touch panel can be used as two independent components to realize the input and output functions. That is, the touch display screen 403 can also be used as a part of the input unit 406 to realize the input function.
[0129] In the embodiment of the present application, the processor 401 executes the application program to generate a graphical user interface on the touch screen 403. The touch screen 403 is used to present the graphical user interface and receive operation instructions generated by the user acting on the graphical user interface.
[0130] The radio frequency circuit 404 may be used to send and receive radio frequency signals, so as to establish wireless communication with a network device or other electronic devices through wireless communication, and to send and receive signals with the network device or other electronic devices.
[0131] The audio circuit 405 can be used to provide an audio interface between the user and the electronic device through a speaker and a microphone. The audio circuit 405 can transmit the electrical signal converted from the received audio data to the speaker, which is converted into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 405 and converted into audio data, and then the audio data is output to the processor 401 for processing, and then sent to another electronic device through the radio frequency circuit 404, or the audio data is output to the memory 402 for further processing. The audio circuit 405 may also include an earplug jack to provide communication between an external headset and an electronic device.
[0132] The input unit 406 may be used to receive input numbers, character information or user feature information (such as fingerprint, iris, facial information, etc.), and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0133] The power supply 407 is used to supply power to various components of the electronic device 400. Optionally, the power supply 407 can be logically connected to the processor 401 through a power management system, so that the power management system can manage charging, discharging, and power consumption. The power supply 407 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0134] although Fig.10 Not shown, the electronic device 400 may also include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc., which will not be described in detail here.
[0135] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0136] As can be seen from the above, the electronic device provided in this embodiment can search in the search space according to the quantum random search circuit during the iteration of the quantum genetic algorithm, and output the quantum state, mark the quantum state through the first logic gate, perform probability amplitude amplification processing on the marked quantum state according to the amplitude amplification circuit, transcode the quantum state obtained after the processing, and verify the accuracy of the output value obtained after transcoding through a preset function. If the accuracy is higher than the accuracy after the previous iteration, the solution corresponding to the current quantum state is used as the optimal solution. The embodiment of the present application can use quantum logic gates to realize the diversity and convergence of the quantum genetic algorithm, and the parallelism of quantum computing can significantly improve the computational efficiency of the quantum genetic algorithm.
[0137] A person skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a storage medium and loaded and executed by a processor.
[0138] To this end, an embodiment of the present application provides a storage medium in which multiple computer programs are stored, and the computer program can be loaded by a processor to execute the steps in any one of the search methods based on quantum genetic algorithms provided in the embodiments of the present application. For example, the computer program can execute the following steps:
[0139] During the iteration of the quantum genetic algorithm, the search is performed in the search space according to the quantum random search circuit, and the quantum state is output;
[0140] marking the quantum state by a first logic gate;
[0141] Performing probability amplitude amplification processing on the quantum state of the mark according to the amplitude amplification circuit;
[0142] The processed quantum state is transcoded, and the accuracy of the output value obtained after transcoding is verified by a preset function;
[0143] If the accuracy is higher than the accuracy after the previous iteration, the solution corresponding to the current quantum state is taken as the optimal solution.
[0144] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0145] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0146] Since the computer program stored in the storage medium can execute the steps in any one of the search methods based on quantum genetic algorithms provided in the embodiments of the present application, the beneficial effects that can be achieved by any one of the search methods based on quantum genetic algorithms provided in the embodiments of the present application can be achieved. For details, please refer to the previous embodiments and will not be repeated here.
[0147] The above is a detailed introduction to a search method, device, storage medium and electronic device based on a quantum genetic algorithm provided in an embodiment of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A search method based on quantum genetic algorithm, characterized in that: include: During the iteration of the quantum genetic algorithm, the search is performed in the search space according to the quantum random search circuit, and the quantum state is output; marking the quantum state by a first logic gate; Performing probability amplitude amplification processing on the quantum state of the mark according to the amplitude amplification circuit; The processed quantum state is transcoded, and the accuracy of the output value obtained after transcoding is verified by a preset function; If the accuracy is higher than the accuracy after the previous iteration, the solution corresponding to the current quantum state is taken as the optimal solution.
2. The search method based on quantum genetic algorithm according to claim 1, characterized in that: The step of marking the quantum state by using a first logic gate comprises: Transcoding the quantum state, and verifying the accuracy of the output value obtained after the transcoding by using a preset function; During the first N iterations of the quantum genetic algorithm, the above steps are repeatedly performed, wherein the circuit is measured 100 times in each iteration to obtain 100*N quantum states and corresponding precisions; The quantum state with the highest precision is selected from the 100*N quantum states as the target quantum state, and the target quantum state is marked through a first logic gate.
3. The search method based on quantum genetic algorithm as claimed in claim 1, characterized in that: After the amplitude amplification circuit performs probability amplitude amplification processing on the quantum state of the mark, the method further includes: The quantum state after the amplification process is disturbed by randomly adding the second logic gate and the third logic gate, so as to realize the local fine search function of the quantum genetic algorithm.
4. The search method based on quantum genetic algorithm according to claim 1, characterized in that: After taking the solution corresponding to the current quantum state as the optimal solution, the method further includes: Marking the optimal solution through a first logic gate and continuing to perform subsequent iterations; When the number of iterations reaches a preset number of iterations, the marked optimal solution is taken as the global optimal solution.
5. The search method based on quantum genetic algorithm according to claim 1, characterized in that: The output of the random search circuit is expressed by the following formula: Wherein, the random search circuit comprises two quantum bits, Represents two Hadamard gates acting in parallel.
6. The search method based on quantum genetic algorithm according to claim 1, characterized in that: The output of the amplitude amplifier circuit is expressed by the following formula: Among them, the marked quantum state is "11", Represents two Pauli-Z gates acting in parallel.
7. The search method based on quantum genetic algorithm according to claim 1, characterized in that: The quantum state is transcoded by the following formula: x=x1×2 5 +x2×2 4 +x3×2 3 +x4×2 2 +x5×2 1 +x6×2 0 Among them, x1x2x3x4x5x6 is the output result of the quantum circuit, x is a decimal number, and then x is mapped to the search space: Among them, a and b represent the upper limit and lower limit of the search space respectively, and o represents the final result after mapping.
8. A search device based on quantum genetic algorithm, characterized in that: include: A search module, used to search in the to-be-searched space according to the quantum random search circuit during the iteration of the quantum genetic algorithm, and output the quantum state; A marking module, used for marking the quantum state through a first logic gate; an amplification module, used for performing probability amplitude amplification processing on the quantum state of the mark according to the amplitude amplification circuit; A transcoding module is used to transcode the quantum state obtained after processing, and verify the accuracy of the output value obtained after transcoding through a preset function; The output module is used to take the solution corresponding to the current quantum state as the optimal solution when the accuracy is higher than the accuracy after the previous iteration.
9. A storage medium, characterized in that: The storage medium stores a computer program, and the computer program is suitable for being loaded by a processor to execute the steps in the search method based on a quantum genetic algorithm as described in any one of claims 1 to 7.
10. An electronic device, characterized in that: The electronic device includes a memory and a processor, wherein a computer program is stored in the memory, and the processor executes the steps in the search method based on a quantum genetic algorithm as described in any one of claims 1 to 7 by calling the computer program stored in the memory.
