Path optimization method and device based on hybrid quantum algorithm, computer equipment and storage medium
By optimizing the path of travel dealer problem in quantum circuits, the problem of finding the optimal solution in the prior art requires exponential time, and efficient path planning is achieved.
Patent Information
- Application Number
- CN202411268070.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-10
- Publication Date
- 2025-02-07
AI Technical Summary
The prior art requires exponential time when finding the optimal solution to the traveler problem, resulting in inefficiency in path planning.
The path optimization method based on hybrid quantum algorithm is adopted, and the weight adjacency matrix of the undirected fully weighted graph is obtained by obtaining the weight adjacency matrix of the undirected fully weighted graph and inputting it into a preset quantum circuit for optimization, so as to obtain the candidate solution and weight. During the encoding and pruning process of quantum circuits, the candidate solution is divided into multiple steps, encoding the traveler's selection and performing pruning to form a uniform superposition state, and finally updating the candidate solution according to the weight and threshold to obtain the target path.
The quantum resources required to encode candidate solutions are effectively reduced, the efficiency of path planning is improved, and the efficiency of path planning is improved while accurately planning the path.
Smart Images

Figure CN119398289A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the intersecting technical field of combinatorial optimization problems and quantum computing, and in particular to a path optimization method, apparatus, computer device and storage medium based on a hybrid quantum algorithm. Background Art
[0002] The hybrid quantum algorithm refers to a quantum-classical hybrid algorithm that finds the optimal solution to the Traveling Salesman Problem (TSP) in an undirected fully weighted graph. The Traveling Salesman Problem (TSP) is one of the classic combinatorial optimization problems. The problem describes a traveling salesman who needs to visit a series of cities and requires that each city must be visited only once. The task of the traveling salesman is to find a path that allows him to visit all cities and eventually return to the starting point, and the sum of the total weights of this path is the smallest. In graph theory, such a circuit is called a Hamiltonian circuit. It plays an important role in the practical application of path planning in logistics and transportation.
[0003] Currently, path specifications use classical algorithms to find the optimal solution to the traveling salesman problem; however, the NP-hard nature of the traveling salesman problem poses a huge challenge to the classical algorithm. This means that in the classical algorithm, although it is possible to complete the verification of whether a path is a Hamiltonian circuit (the solution to the traveling salesman problem) in polynomial time, it usually takes exponential time to find the optimal solution, which makes path planning inefficient.
[0004] There is a problem in related technologies that it takes exponential time to find the optimal solution, resulting in low efficiency of path planning. No effective solution has been proposed so far. Summary of the invention
[0005] In this embodiment, a path optimization method, apparatus, computer device and storage medium based on a hybrid quantum algorithm are provided to solve the problem in the related art that exponential time is required to find the optimal solution, resulting in low efficiency of path planning.
[0006] In the first aspect, a path optimization method based on a hybrid quantum algorithm is provided in this embodiment, including:
[0007] Obtain the weighted adjacency matrix of the undirected fully weighted graph of the path to be optimized;
[0008] The weighted adjacency matrix is input into a preset quantum circuit for optimization to obtain a first candidate solution and a corresponding first weight; wherein, in the optimization process of encoding and pruning the quantum circuit, all the candidate solutions are divided into multiple steps; the choice of the traveling salesman in each step is encoded into the quantum circuit, and corresponding pruning is performed to form a uniform superposition state containing all candidate solutions; the first candidate solution is the candidate solution with the highest probability; the candidate solution is the Hamiltonian circuit corresponding to the path in the undirected completely weighted graph that passes through each node once and returns to the starting point;
[0009] The first candidate solution is updated according to the first weight and a preset first threshold to obtain a target path.
[0010] In some embodiments, the method further comprises:
[0011] After obtaining the weighted adjacency matrix of the undirected fully weighted graph of the path to be optimized, the sum of the top N weights in the weighted adjacency matrix is selected as the maximum weighted sum, and the maximum weighted sum is normalized to a maximum binary fraction less than 1; and the remaining weights are proportionally scaled to binary fractions in the range [0,1).
[0012] In some embodiments, the weight adjacency matrix is input into a preset quantum circuit for optimization to obtain a first candidate solution and a corresponding first weight, including:
[0013] Step A, setting default parameters of the quantum circuit; the quantum circuit includes a quantum register and a quantum operator;
[0014] Step B, initializing the quantum circuit, inputting the weight adjacency matrix into the quantum circuit for encoding and pruning optimization, and forming a uniform superposition state containing all candidate solutions;
[0015] Step C, executing the quantum operator Q in the quantum operator 1 , mark the candidate solutions that meet the Hamiltonian circuit;
[0016] Step D, executing the quantum operator Q in the quantum operator 2 , calculating the sum of weights of all the candidate solutions, and marking the candidate solutions whose sum of weights is less than the first threshold;
[0017] Step E, executing the quantum operator Q 1 and the quantum operator Q 2 The inverse process of restoring the quantum bits in the quantum register to an initial state;
[0018] Step F, executing the quantum operator D to amplify the probability amplitude of the quantum state corresponding to the candidate solution marked at the same time;
[0019] Step G: When steps C to F are repeatedly executed to meet the number of iterations in the default parameters, a first candidate solution and a corresponding first weight are obtained.
[0020] In some of the embodiments, in constructing the quantum operator Q 1 When , the first theorem and the first corollary are satisfied;
[0021] The first theorem is: when o i Represents the traveling salesman at step s i When the options are determined, N-1 options o i (0≤i≤N-2) can uniquely determine a candidate solution sol k ;
[0022] If the candidate solution sol k is a Hamiltonian circuit if and only if:
[0023] (1) Make o i =v j ;
[0024] (2)
[0025] Among them, j represents a variable, belonging to [1, N-1];
[0026] The first inference is: in the quantum circuit, a quantum register |IR> containing N-1 quantum bits is used to record the node v 0 The other N-2 nodes v i (1≤i≤N-1) is visited times; when step s j Option o in (0≤j≤N-2) j Points to node v i When the corresponding quantum bit |IR i-1 >The state is flipped;
[0027] If the candidate solution sol k is a Hamiltonian circuit if and only if: |IR i >=|1>.
[0028] In some of the embodiments, in constructing the quantum operator O 2 When the node v i and node v j The weight between them is denoted as a ij , calculate the weight and Cost(sol) of the candidate solution according to three parts, and get the corresponding phase value;
[0029] The phase value is converted to the amplitude of the qubit using a quantum phase estimation algorithm.
[0030] In some of the embodiments, the number of iterations is between an upper bound on the number of iterations and a lower bound on the number of iterations;
[0031] The upper bound of the number of generations is determined by an iterative formula; the lower bound of the number of generations is determined by a second iterative formula.
[0032] In some embodiments, updating the first candidate solution according to the first weight and a preset first threshold to obtain a target path includes:
[0033] updating the first candidate solution according to the first weight and a preset first threshold;
[0034] The updated first candidate solution is input into the quantum circuit for execution until a cutoff condition is met to obtain a target path.
[0035] In a second aspect, a path optimization device based on a hybrid quantum algorithm is provided in this embodiment, characterized in that it includes: an acquisition module, an optimization module, and an update module;
[0036] The acquisition module is used to acquire the weight adjacency matrix of the undirected fully weighted graph of the path to be optimized;
[0037] The optimization module is used to input the weight adjacency matrix into a preset quantum circuit for optimization to obtain a first candidate solution and a corresponding first weight; wherein, in the optimization process of encoding and pruning the quantum circuit, all the candidate solutions are divided into multiple steps; the choice of the traveling salesman in each step is encoded into the quantum circuit, and corresponding pruning is performed to form a uniform superposition state containing all candidate solutions; the first candidate solution is the candidate solution with the highest probability; the candidate solution is the Hamiltonian circuit corresponding to the path in the undirected completely weighted graph that passes through each node once and returns to the starting point;
[0038] The updating module is used to update the first candidate solution according to the first weight and a preset first threshold to obtain a target path.
[0039] In a third aspect, a computer device is provided in this embodiment, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the path optimization method based on the hybrid quantum algorithm described in the first aspect is implemented.
[0040] In a fourth aspect, in this embodiment, a storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the path optimization method based on the hybrid quantum algorithm described in the first aspect is implemented.
[0041] Compared with the related art, the path optimization method, device, computer equipment and storage medium based on the hybrid quantum algorithm provided in this embodiment obtain the weight adjacency matrix of the undirected completely weighted graph of the path to be optimized; input the weight adjacency matrix into a preset quantum circuit for optimization to obtain a first candidate solution and a corresponding first weight; wherein, in the optimization process of encoding and pruning of the quantum circuit, all candidate solutions are divided into multiple steps; the choice of the traveling salesman in each step is encoded into the quantum circuit, and the corresponding pruning is performed to form a uniform superposition state containing all candidate solutions; the first candidate solution is the candidate solution with the highest probability; the candidate solution is the Hamiltonian circuit corresponding to the path in the undirected completely weighted graph that passes through each node once and returns to the starting point; according to the first weight and the preset first threshold, the first candidate solution is updated to obtain the target path; the problem that exponential time is required to find the optimal solution in the related art, resulting in low efficiency of path planning, is solved, and the optimization process of encoding and pruning in the quantum circuit is utilized to effectively reduce the quantum resources (number of quantum bits) required for encoding the candidate solution, so as to achieve accurate path planning while improving the path planning efficiency.
[0042] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0044] Figure 1 This is a hardware structure block diagram of a terminal device of a path optimization method based on a hybrid quantum algorithm provided in an embodiment of the present application;
[0045] Figure 2 is a flow chart of a path optimization method based on a hybrid quantum algorithm provided in one embodiment of the present application;
[0046] Figure 3 is a schematic diagram of an undirected fully weighted graph of 4 nodes provided in an embodiment of the present application;
[0047] Figure 4 is a schematic diagram of a quantum circuit provided by an embodiment of the present application;
[0048] Figure 5 The quantum operator O is provided in one embodiment of the present application.1 A flowchart marking candidate solutions that conform to the Hamiltonian circuit;
[0049] Figure 6 The quantum operator O is provided in one embodiment of the present application. 2 A flowchart for marking candidate solutions whose weights are less than a first threshold;
[0050] Figure 7 It is a flow chart of a path optimization method based on a hybrid quantum algorithm provided in a preferred embodiment of the present application;
[0051] Figure 8 It is a structural block diagram of a path optimization device based on a hybrid quantum algorithm provided in one embodiment of the present application.
[0052] In the figure: 102, processor; 104, memory; 106, transmission device; 108, input and output device; 210, acquisition module; 220, optimization module; 230, update module. DETAILED DESCRIPTION
[0053] In order to more clearly understand the purpose, technical solutions and advantages of the present application, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments.
[0054] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the", "these" and the like in this application do not represent quantitative restrictions, and they can be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether directly or indirectly. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. Usually, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0055] The method embodiment provided in this embodiment can be executed in a terminal, a computer or a similar computing device. For example, running on a terminal, Figure 1 is a hardware structure block diagram of a terminal of the path optimization method based on a hybrid quantum algorithm in this embodiment. Figure 1 As shown, the terminal may include one or more ( Figure 1 Only one is shown in the figure) processor 102 and memory 104 for storing data, wherein processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA. The above terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is for illustration only and does not limit the structure of the above terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0056] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the path optimization method based on the hybrid quantum algorithm in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0057] The transmission device 106 is used to receive or send data via a network. The above network includes a wireless network provided by the communication provider of the terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.
[0058] It should be noted that quantum computing is a revolutionary paradigm in computing technology, with the potential to significantly surpass traditional computing speeds in specific computing tasks. It provides a new approach to solving complex optimization problems, especially NP-hard problems. At present, quantum algorithms used to solve combinatorial optimization problems, including the traveling salesman problem, are mainly divided into two categories: the first category is quantum approximation algorithms, such as quantum annealing, variational quantum algorithms (VQA), and quantum approximate optimization algorithms (QAOA). However, as the scale of the traveling salesman problem increases, the solution space grows exponentially, which makes it easy for quantum approximation algorithms to fall into local optimal solutions and thus fail to accurately find the optimal solution to the problem. The second category of quantum algorithms aims to accurately solve the TSP and find its optimal solution. The challenge of this type of algorithm is how to screen out solutions that meet the Hamiltonian circuit from the huge solution space. This screening process often consumes a lot of quantum resources. In addition, since the input weight adjacency matrix has not been normalized, this type of algorithm may produce probabilistic errors when calculating path weights, thereby reducing the success rate of finding the optimal solution.
[0059] What you need to know about quantum computing is that the qubit is the basic unit of quantum computing. Similar to the classical bit, the computational basis state of the qubit can be represented as |0> and |1> (in Dirac symbols), or as the state vector (1,0) in Hilbert space. T and (0,1) T The basic difference between the two is that quantum bits have superposition. That is, the state of a single quantum bit can be expressed mathematically as Among them, α and β are the complex probability amplitudes of state |0> and state |1>, respectively, and they have the following relationship: |α| 2 +|β| 2 =1;
[0060] After measurement, the qubit probabilistically collapses to |0> or |1> with probabilities |α| 2 and |β| 2 .
[0061] Similar to classical logic gates, quantum gate operations are also a basic computing unit that generates outputs based on inputs. However, unlike classical logic gates, quantum circuits require that each quantum gate has a corresponding inverse operation that can restore the system from the state after the operation to the state before the operation. This is because: 1. Information is guaranteed not to be lost. In quantum computing, information is stored and processed in the form of quantum states. Reversibility ensures that no information is lost during the calculation process, that is, it can be completely restored to the state before the calculation. 2. Maintain the normalization of probability amplitudes. The probability amplitude of quantum states needs to maintain normalization, which is one of the basic principles of quantum mechanics. Reversible operations maintain the normalization of probability amplitudes, so that the condition that the sum of probabilities in the system is 1 can be maintained. 3. Reverse execution of quantum algorithms. Reversibility allows the gate operations in the algorithm to be executed in reverse order in quantum computing, thereby realizing the inverse transformation of the algorithm. This is necessary in some quantum algorithms. 4. Initialization and clearing of quantum bits. Reversibility allows the state of quantum bits to be reset when necessary, that is, to restore them to their initial state without introducing additional irreversible changes.
[0062] In addition, in quantum computing, quantum gates are generally divided into two categories: single quantum gates and multi-quantum gates. A single quantum gate refers to a gate that affects only a single quantum bit, such as a quantum NOT gate, while a multi-quantum gate refers to a gate that affects multiple quantum bits at the same time, such as a controlled NOT gate. Quantum entanglement can be generated by applying multi-quantum gates. The following will first introduce two commonly used single quantum gates.
[0063] For the quantum NOT gate: its function is to swap the amplitudes of |0> and |1> of a single quantum bit, that is, to swap the probabilities of 0 and 1.
[0064] For the Hadamard gate: its function is to convert a single quantum pure state (only the probability of the 0 state is 1 or the probability of the 1 state is 1) to a quantum superposition state, or to convert a quantum superposition state to a quantum pure state. Its formula is as follows:
[0065]
[0066] A common multi-quantum gate is a control gate, in which one or more quantum bits are used as control bits and the remaining quantum bits are target bits. When the quantum bits of the control bits are all displayed as 1, the state of the target bit is converted according to the function of the gate.
[0067] For a quantum circuit, it is a sequence of quantum gates arranged in a specific order, which is a specific implementation of a quantum algorithm. A quantum circuit exists in a quantum computer and is a circuit that uses quantum bits instead of classical bits. Its purpose is to perform specific computing tasks in quantum computing. A quantum circuit is a multi-quantum system in which there must be information exchange between quantum bits. However, once a quantum bit is observed, its state collapses and cannot be used any further, which results in the inability of quantum information interaction to be transmitted through classical media. In this case, quantum entangled states and entanglement theory provide a way to communicate information.
[0068] Quantum entanglement describes the strong correlation between two or more quantum systems, so that their states cannot be described independently; when two or more quantum bits are entangled, there is a special relationship between their states, that is, the measurement of one bit will immediately affect the state of other entangled bits. This definition of quantum entanglement is very mysterious, but specifically, when quantum entanglement occurs, each quantum bit in the entangled state shares the information of all other entangled bits, which is why the entangled state can only be described as a whole. When the state of one of the entangled quantum bits is changed, since it stores the state information of other bits, the state of other entangled quantum bits will also be affected in the process of modifying the state. In quantum circuits, multi-quantum gate operations can achieve the purpose of quantum entanglement, and information exchange between quantum bits is achieved through this information sharing.
[0069] In addition to the difference between this information transmission method and classical circuits, quantum circuits also have some characteristics that are different from classical circuits: 1. Quantum circuits use quantum gate operations to implement instructions. Unlike the classical circuits in which the control unit issues instructions to the arithmetic logic unit, there are no highly modularized and clearly divided functional modules in quantum circuits. The instructions received by the quantum computer are complex gate instructions, which can be applied to the quantum bits by simply decomposing the complex gates written by the user or programmer into a series of basic gate operations. 2. Quantum circuits are dynamically constructed during the algorithm implementation process, while the various functional unit structures in classical circuits are fixed, and the gate circuits are also fixed. This is because information transmission in quantum circuits is more difficult, and information replication is even more impossible due to the limitations of the non-cloning theorem. Therefore, dynamically constructed quantum circuits can better fit quantum characteristics without wasting the performance of quantum computers on state replication of quantum bits. This characteristic of quantum circuits makes it highly customized and can be highly matched with algorithms. 3. Quantum circuits guarantee its parallelism at the physical level. As mentioned earlier, this parallelism is not achieved by increasing the number of physical processors like GPU acceleration, but is based on quantum superposition states to achieve exponential parallel acceleration. 4. The current quantum circuits are noisy. The existing quantum computers are called noisy intermediate-scale quantum computers (NISQ), which means that the current quantum computers cannot handle large-scale computing tasks that run for a long time, which limits the depth of quantum circuits; and due to the interaction between quantum bits, each quantum gate operation will introduce some calculation errors and noise, making the calculation results less reliable. Therefore, a large number of operations are usually required for quantum error correction or noise suppression.
[0070] In this embodiment, a path optimization method based on a hybrid quantum algorithm is provided. Figure 2 is a flow chart of the path optimization method based on the hybrid quantum algorithm of this embodiment, such as Figure 2 As shown, the process includes the following steps:
[0071] Step S210, obtaining a weighted adjacency matrix of an undirected fully weighted graph of a path to be optimized;
[0072] Step S220, inputting the weight adjacency matrix into a preset quantum circuit for optimization to obtain a first candidate solution and a corresponding first weight; wherein, in the optimization process of encoding and pruning the quantum circuit, all candidate solutions are divided into multiple steps; the choice of the traveling salesman in each step is encoded into the quantum circuit, and corresponding pruning is performed to form a uniform superposition state containing all candidate solutions; the first candidate solution is the candidate solution with the highest probability; the candidate solution is the Hamiltonian circuit corresponding to the path in the undirected completely weighted graph that passes through each node once and returns to the starting point;
[0073] Step S230: updating the first candidate solution according to the first weight and a preset first threshold to obtain a target path.
[0074] In this embodiment, the optimization of the path to be optimized is solved by the traveling salesman problem. Figure 3 As shown, it is an undirected completely weighted graph formed by 4 nodes (cities); the starting point and the end point are v 0 , starting from the starting point, passing through each node once and returning to the starting point, such a circuit is considered to be a Hamiltonian circuit; each Hamiltonian circuit corresponds to a candidate solution; the one with the smallest sum of total weights among these candidate solutions is considered to be the target path.
[0075] Specifically, the weights in the undirected fully weighted graph are constructed as a weighted adjacency matrix. The weight is a numerical value that represents the "cost" of the path (edge) formed from one node to another. In the weighted adjacency matrix, a two-dimensional array is used to represent the connection relationship between nodes, and each element in the matrix represents the weight of each path.
[0076] For example, the weighted adjacency matrix can be expressed as:
[0077]
[0078] Among them, element a 01 Indicates the weight of the path from node 0 to node 1. The meanings of other elements are similar and will not be repeated here.
[0079] The quantum circuit is pre-set in a classical computer, and the quantum circuit is executed by the classical computer, so as to input the weight adjacency matrix into the preset quantum circuit for optimization, and obtain the first candidate solution and the corresponding first weight. The first candidate solution is the candidate solution with the highest probability among all candidate solutions; the first weight corresponds to the first candidate solution, which can be considered as the sum of the total weights of the Hamiltonian circuit corresponding to the candidate solution. Finally, according to the first weight and the preset first threshold, the first candidate solution is updated to obtain the target path.
[0080] Among them, the quantum circuit is a sequence of quantum gates arranged in a specific order. It is a specific implementation of the quantum algorithm, which performs specific computing tasks in classical quantum computing. For example: a quantum circuit includes a quantum register and a quantum operator. Then the implementation process can be: encode the weight adjacency matrix into the quantum circuit, and perform a pruning process to obtain the encoding result shown in Table 1. In the quantum register |M>, a total of 4 groups of quantum bits are required, representing the traveling salesman’s choice of the target city (node) in steps 0, 1, 2, and 3 respectively. In each group of quantum bits, two quantum bits are required, representing the three choices of the traveling salesman in this step, pointing to cities 1, 2, and 3 respectively. After the encoding is completed, due to the existence of a meaningless quantum state |11>, the number of candidate solutions is 256, but there are only 6 valid solutions as shown in Table 2. Afterwards, in the quantum operator O 1 In Oracle, mark these six valid solutions and add them in the quantum operator O 2 The weighted sum of the effective solutions is calculated in the Oracle in the manner of the third column of Table 2. Finally, the weighted sum of the effective solutions with smaller weights is continuously updated in multiple iterations according to the first weight and the preset first threshold until the optimal solution is found.
[0081] Table 1
[0082] |00> |01> |10> |11> <![CDATA[s 0 ]]> <![CDATA[v 1 ]]> <![CDATA[v 2 ]]> <![CDATA[v 3 ]]> - <![CDATA[s 1 ]]> <![CDATA[v 1 ]]> <![CDATA[v 2 ]]> <![CDATA[v 3 ]]> - <![CDATA[s 2 ]]> <![CDATA[v 1 ]]> <![CDATA[v 2 ]]> <![CDATA[v 3 ]]> - <![CDATA[s 3 ]]> <![CDATA[v 1 ]]> <![CDATA[v 2 ]]> <![CDATA[v 3 ]]> -
[0083] Table 2
[0084] Quantum coding with efficient solutions Effective solution Weight and |00>|01>|10> <![CDATA[v 0 →v 1 →v 2 →v 3 →v 0 ]]> <![CDATA[a 01 +a 12 +a 23 +a 03 <!-- 7 -->]]> |00>|10>|01> <![CDATA[v 0 →v 1 →v 3 →v 2 →v 0 ]]> <![CDATA[a 01 +a 13 +a 23 +a 02 ]]> |01>|00>|10> <![CDATA[v 0 →v 2 →v 1 →v 3 →v 0 ]]> <![CDATA[a 02 +a 12 +a 13 +a 03 ]]> |01>|10>|00> <![CDATA[v 0 →v 2 →v 3 →v 1 →v 0 ]]> <![CDATA[a 02 +a 23 +a 13 +a 01 ]]> |10>|00>|01> <![CDATA[v 0 →v 3 →v 1 →v 2 →v 0 ]]> <![CDATA[a 03 +a 13 +a 12 +a 02 ]]> |10>|01>|00> <![CDATA[v 0 →v 3 →v 2 →v 1 →v 0 ]]> <![CDATA[a 03 +a 23 +a 12 +a 01 ]]>
[0085] Through the above steps, the weight adjacency matrix of the undirected completely weighted graph of the path to be optimized is obtained; the weight adjacency matrix is input into a preset quantum circuit for optimization to obtain a first candidate solution and a corresponding first weight; wherein, in the optimization process of encoding and pruning of the quantum circuit, all candidate solutions are divided into multiple steps; the choice of the traveling salesman in each step is encoded into the quantum circuit, and corresponding pruning is performed to form a uniform superposition state containing all candidate solutions; the first candidate solution is the candidate solution with the highest probability; the candidate solution is the Hamiltonian circuit corresponding to the path in the undirected completely weighted graph that passes through each node once and returns to the starting point; according to the first weight and the preset first threshold, the first candidate solution is updated to obtain the target path; the problem that exponential time is required to find the optimal solution in the related technology, resulting in low efficiency of path planning, is solved, and the optimization process of encoding and pruning in the quantum circuit is utilized to effectively reduce the quantum resources (number of quantum bits) required for encoding the candidate solution, so as to achieve accurate path planning while improving the path planning efficiency.
[0086] The above steps are described in detail below:
[0087] In some of the embodiments, the path optimization method based on the hybrid quantum algorithm further includes the following steps:
[0088] After obtaining the weighted adjacency matrix of the undirected fully weighted graph of the path to be optimized, the sum of the top N weights in the weighted adjacency matrix is selected as the maximum weighted sum, and the maximum weighted sum is normalized to a maximum binary fraction less than 1; and the remaining weights are proportionally scaled to binary fractions in the range [0,1).
[0089] Specifically, since the quantum algorithm selects the optimal solution that meets the Hamiltonian circuit from the huge solution space, this screening process often requires a large amount of quantum resources. In addition, since the input weight adjacency matrix has not been normalized, this type of algorithm may produce probabilistic errors when calculating path weights, thereby reducing the success rate of finding the optimal solution. Therefore, in this embodiment, the weight adjacency matrix will be normalized, and all weight values in the matrix will be normalized to binary values in the range of [0,1), without losing calculation accuracy, avoiding the probabilistic errors generated by the algorithm when calculating path weights.
[0090] In this embodiment, the specific process of normalization is as follows: before the normalization, first determine the range (within [0,1)) in which all elements in the weight adjacency matrix are normalized. For a Hamiltonian circuit containing N nodes, it is composed of N edges connecting adjacent nodes. The calculation of the weights of the candidate solutions is implemented on the phase of the quantum bit, that is, the addition calculation of the weights of these N edges, and then the result obtained on the phase is converted to amplitude through the quantum phase estimation (QPE) algorithm. As an important attribute of the quantum bit, the phase is a periodic continuous variable. In the quantum phase estimation algorithm, the period of the phase is 1. Although the continuity of the phase helps to quickly implement the addition calculation, its periodicity means that in order to ensure the reliability of the operation process and avoid result overflow, the maximum sum of the addition operation needs to be limited to the range [0,1).
[0091] In addition, the experimental results of the quantum phase estimation algorithm show that when the calculation result is not a binary fraction (such as 0.5, 0.25), the measurement result will not stably output the calculation result, but will probabilistically output the binary fraction, and the probability of output decreases as the difference between the binary fraction and the result increases. Therefore, when the result obtained on the phase is converted to the amplitude through the quantum phase estimation algorithm, a probabilistic error will occur, resulting in the value on the amplitude being different from the calculated value on the phase, or even completely different.
[0092] Then, after obtaining the above two constraints, select the sum of the top N weights in the weight adjacency matrix as the maximum weight sum, normalize the maximum weight sum to the maximum binary fraction less than 1; and scale the remaining weights proportionally to binary fractions in the range [0,1).
[0093] Through this embodiment, a normalization processing method for the input weight adjacency matrix is proposed, which normalizes all weight values in the matrix to binary values in the range of [0,1), avoiding the probabilistic error generated by the algorithm when calculating the path weight without losing the calculation accuracy.
[0094] In some embodiments, the step S220 of inputting the weight adjacency matrix into a preset quantum circuit for optimization to obtain a first candidate solution and a corresponding first weight includes the following steps:
[0095] Step A, setting default parameters of the quantum circuit; the quantum circuit includes a quantum register and a quantum operator;
[0096] Step B, initializing the quantum circuit, inputting the weight adjacency matrix into the quantum circuit for encoding and pruning optimization, and forming a uniform superposition state containing all candidate solutions;
[0097] Step C, execute the quantum operator Q in the quantum operator 1 , mark the candidate solutions that meet the Hamiltonian circuit;
[0098] Step D, execute the quantum operator Q in the quantum operator 2 , calculate the weights and sums of all candidate solutions, and mark the candidate solutions whose weights and sums are less than the first threshold;
[0099] Step E, execute the quantum operator Q 1 and the quantum operator Q 2 The reverse process restores the quantum bits in the quantum register to their initial state;
[0100] Step F, executing the quantum operator D to amplify the probability amplitude of the quantum state corresponding to the candidate solution marked at the same time;
[0101] Step G: When steps C to F are repeatedly executed for the number of iterations in the default parameters, a first candidate solution and a corresponding first weight are obtained.
[0102] Specifically, the quantum circuit is pre-set, e.g. Figure 4 As shown, it includes quantum registers and quantum operators; wherein the quantum registers include quantum registers |M>, |IR>, |Anc>, |R>; the quantum register |R> includes the quantum register |RO 1 >,|RO 2 >,|R final>. Quantum operators include the quantum operator Q 1 and the quantum operator Q 2 . Among them, X and H are both quantum gates, similar to gate circuit operations in classical circuits (AND gates, NOT gates, etc.). Each quantum gate has a specific function. For example, the X gate - quantum NOT gate (NOT gate) - is the probability of exchanging measurements to obtain 0 and 1. For example, the original measurement result should be 0, but after the X gate, the measurement result becomes 1 (the 0 and 1 here are measurement results, so they have collapsed and become classical states, so they are not |0> and |1>. The function of the H gate is the same as that of the X gate. Oracle is a quantum operator, which is a quantum component composed of multiple quantum gates that can realize more complex functions. Including Diffusion operator, F operator, U operator, etc. belong to this type.
[0103] Then, the specific process of the above optimization is:
[0104] Step A, set the default parameters of the quantum circuit. In the weight adjacency matrix of the input undirected fully weighted graph, randomly construct a Hamiltonian circuit as the optimal solution sol under the initial conditions opt , and set its weight and value as the first threshold t under the initial condition. At the same time, set the number of iterations num in the default parameters iter is the number of repeated executions of the quantum operator in the quantum circuit.
[0105] Step B, initialize the quantum circuit, input the weight adjacency matrix into the quantum circuit for encoding and pruning optimization, and form a uniform superposition state containing all candidate solutions. The encoding and pruning optimization process is:
[0106] In the process of encoding all candidate solutions into the quantum register |M>, for an undirected fully weighted graph G with N nodes, each candidate solution should consist of N end-to-end edges. Similarly, the traveling salesman needs N steps to achieve each candidate solution. i (0≤i≤N-1), there will be N options for the traveling salesman to choose from. When the traveling salesman chooses the jth option o in step i ij (0≤j≤N-1), the traveling salesman will make the next step s i+1 Arrival node v j A Hamiltonian circuit can be viewed as a special Hamiltonian path with the same starting point and end point. Therefore, in order to encode all candidate solutions, any node can be specified as the starting point and end point of the circuit, and the starting point and end point are defaulted to v. 0 Afterwards, the N options of the traveling salesman in N steps are encoded into the quantum register |M> in sequence, thus forming a uniform superposition state containing all candidate solutions.
[0107] Then, by selectively considering only the valid o in the solution ij To perform the pruning operation:
[0108] efficient
[0109] The above formula reveals two effective pruning operations. First, for the last step of the traveling salesman, he can only return to the end point v 0 , that is, the traveling salesman is at s N-1 There is only one confirmation option. N-1,0 Furthermore, it is found that, for such a certain option, even if it is not encoded into the quantum circuit, it will not interfere with the superposition state of the candidate solution. N-1 All the N options in |M> do not need to be encoded in |M>. Second, since the starting point and the end point are predetermined, the traveling salesman will not make any choices other than s N-1 In any step other than 0 Therefore, for 0 to N-2 These first N-1 steps, reaching node v 0 Options i,0 Then, in the encoding phase, only the N-1 options in the first N-1 steps need to be encoded into the quantum register |M>.
[0110] The same is true for other quantum registers, which will not be described again.
[0111] Step C, execute the quantum operator Q in the quantum operator 1 , mark the candidate solutions that meet the Hamiltonian circuit;
[0112] Specifically, when executing the quantum operator O 1 When a candidate solution meets the Hamiltonian circuit, the quantum operator O 1 Corresponding Flip, that is, mark the candidate solution.
[0113] Step D, execute the quantum operator Q in the quantum operator 2 , calculate the weighted sum of all candidate solutions, compare it with the first threshold, and mark the candidate solutions whose weighted sum is less than the first threshold;
[0114] Specifically, when executing the quantum operator O 2 When the weight sum of a candidate solution is less than the first threshold, the quantum operator O is 2 Corresponding Flip, that is, mark the candidate solution.
[0115] When a candidate solution satisfies the quantum operator O 1 and the quantum operator O2 When and The quantum states of |1> are all |R final The state of > is flipped to |1>.
[0116] Step E, execute the quantum operator Q 1 and the quantum operator Q 2 The inverse process of , restores the quantum bits in the quantum register |IR>, |Anc> to the initial state; where the initial state is restored to the original initial state |0>.
[0117] Step F, executing quantum operator D to amplify the probability amplitude of the quantum state corresponding to the candidate solution marked by both (step C and step D);
[0118] Step G, repeating steps C to F to meet the number of iterations num in the default parameter iter When the candidate solution with the highest probability is sol curr As the first candidate solution, and obtain the corresponding first weight.
[0119] Specifically, all operators in the dotted box can be repeatedly executed several times to greatly increase the probability of the marked candidate solutions, and then a measurement operation is performed to obtain the candidate solution with the highest probability in the quantum register |M> as the first candidate solution, and the corresponding first weight is obtained.
[0120] Through this embodiment, it is possible to The time complexity of finding the target item in an unsorted database with N items is greatly improved, and the solution efficiency is achieved in the precise planning of the path.
[0121] In some embodiments, the step S230 of updating the first candidate solution according to the first weight and the preset first threshold to obtain the target path includes the following steps:
[0122] Step H, updating the first candidate solution according to the first weight and a preset first threshold;
[0123] Step I: input the updated first candidate solution into the quantum circuit for execution until the cutoff condition is met and the target path is obtained.
[0124] Specifically, based on step S220, the first candidate solution sol curr The corresponding first weight is compared with the first threshold t. If the first weight is less than the first threshold t, the optimal solution sol is updated opt The first candidate solution sol curr , update the first threshold t to the first weight; otherwise, increase the number of iterations num iterRepeat steps B to G until the cutoff condition is met and the target path is obtained (the solution to the traveling salesman problem). opt ).
[0125] Among them, the cut-off condition is: until the optimal solution sol is obtained opt The first candidate solution sol with a smaller first threshold t curr Or the upper limit of the number of repetitions is reached. The upper limit of the number of repetitions can also be set in the default parameters.
[0126] Through this embodiment, the Hamiltonian circuit with the minimum weight is dynamically found through multiple iterations, so as to obtain the optimal solution to obtain the target path, and further obtain the calculation accuracy.
[0127] In some of these embodiments, in constructing the quantum operator Q 1 When , the first theorem and the first corollary are satisfied;
[0128] The first theorem is: when o i Represents the traveling salesman at step s i When the options are determined, N-1 options o i (0≤i≤N-2) can uniquely determine a candidate solution sol k ;
[0129] If the candidate solution sol k is a Hamiltonian circuit if and only if:
[0130] (1) Make o i =v j ;
[0131] (2)
[0132] Among them, j represents a variable, belonging to [1, N-1]; Indicates existence.
[0133] The first inference is: In the quantum circuit, a quantum register |IR> containing N-1 quantum bits is used to record the node v 0 The other N-2 nodes v i (1≤i≤N-1) is visited times; when step s j Option o in (0≤j≤N-2) j Points to node v i When the corresponding quantum bit |IR i-1 >The state is flipped;
[0134] If the candidate solution sol k is a Hamiltonian circuit if and only if: |IRi >=|1>.
[0135] Specifically, we use the above Theorem 1 to help realize the quantum operator O 1 The necessity of Theorem 1 is self-evident. Here we mainly prove the sufficiency of Theorem 1. The two rules in Theorem 1 emphasize that the options of the traveling salesman at each step lead to a node that has not been visited before, ensuring that in the first N-1 steps s i (0≤i≤N-2) covers all the non-repeated parts except the starting point v 0 Any city other than j (1≤j≤N-1). For the starting point v of the path 0 , since it is predetermined and will not be stored in the quantum register |M>, so v 0 It does not affect the correctness of the theorem.
[0136] Therefore, the candidate solution that meets Theorem 1 can traverse all nodes without repetition, which meets the basic properties of the Hamiltonian circuit.
[0137] Furthermore, the judgment process of candidate solutions in Theorem 1 is simplified, and the above Corollary 1 is proposed based on the characteristics of quantum circuits. The necessity of Corollary 1 is self-evident, and the sufficiency of Corollary 1 is mainly proved here.
[0138] First, we use proof by contradiction to prove that Corollary 1 satisfies the first rule of Theorem 1.
[0139] If the first rule of Theorem 1 is not satisfied, the candidate solution sol k Option o exists in j , so that: o j ≠v i ; then option o j will not cause any quantum bit flip in the quantum register |IR>, resulting in |IR x >=|0>, which contradicts Corollary 1, thus proving that Corollary 1 is a sufficient condition for the first rule of Theorem 1.
[0140] Next, we use proof by contradiction to prove that Corollary 1 satisfies the second rule of Theorem 1.
[0141] If the second rule of Theorem 1 is not satisfied, that is, the candidate solution sol k There are m options:
[0142]
[0143] When m is an even number, the quantum bit |IR i-1 > is flipped an even number of times, and still maintains |0>, which contradicts Corollary 1; when m is an odd number, the quantum bit |IRi-1 > is flipped an odd number of times and becomes |1>. However, since the quantum bits in the quantum register |IR> are connected to the node v i There is a one-to-one correspondence between |IR> and the number of nodes, and the number of steps taken by the traveling salesman is consistent. This means that the number of quantum bits in the quantum register |IR> is consistent with the number of flips. i-1 >When it is flipped more than 1 times, there must be a quantum bit |IR x > is not flipped and still maintains |0>, which contradicts Corollary 1, thus proving that Corollary 1 is a sufficient condition for the second rule of Theorem 1.
[0144] Therefore, it can be proved that Corollary 1 is a sufficient condition for Theorem 1.
[0145] In this embodiment, according to Corollary 1, the quantum operator O can be constructed 1 : Prepare N-1 quantum bits with an initial state of |0> in the quantum register |IR>, check the options of each step in the quantum register |M> respectively, and flip the quantum bit |IR corresponding to the node pointed to by the option i >. Finally, check whether the states of all quantum bits in the quantum register |IR> are |11…1>. If so, it means that the candidate solution conforms to the Hamiltonian circuit and the candidate solution is marked.
[0146] Through this embodiment, a quantum operator O for screening effective solutions (Hamiltonian circuits) is proposed. 1 The construction method more efficiently marks the candidate solutions that meet the Hamiltonian circuit criteria while using less circuit depth.
[0147] Example: Figure 5 As shown, it is the quantum operator O 1 implementation process.
[0148] Among them, the quantum register Representative steps i All options in i The uniform superposition state, quantum operator F j -NOT is used to judge the quantum register Is the state in |j> equal to |j>? If so, flip the corresponding quantum bit |IR in the quantum register |IR> j >; otherwise, it has no effect. 1 In the process, we traverse all quantum registers And traverse all nodes to determine option o i Whether it is related to F j-NOT is equal to |j>, that is, to determine whether the option in step i points to the jth node. After the traversal is completed, determine whether all quantum bits in the quantum register |IR> are |1>. If so, flip the quantum operator O 1 The corresponding quantum register Finally, execute all quantum operators F j -The reverse process of NOT, restoring all quantum bits in the quantum register |IR>.
[0149] In some of these embodiments, in constructing the quantum operator O 2 When the node v i and node v j The weight between them is denoted as a ij , calculate the weight and Cost(sol) of the candidate solution according to three parts, and get the corresponding phase value;
[0150] The phase value is converted to the amplitude of the qubit using a quantum phase estimation algorithm.
[0151] Specifically, step D executes the quantum operator Q in the quantum operator 2 , calculate the weights and sums of all candidate solutions, and mark the candidate solutions whose weights and sums are less than the first threshold. The specific process is:
[0152] In the weighted adjacency matrix, the node v i and node v j The weight between them is denoted as a ij , then the weight and Cost(sol) of the candidate solution can be calculated as:
[0153]
[0154] Through the above formula, the weight and Cost(sol) of the candidate solution can be decomposed into three parts; these three parts are the weights of the traveling salesman in the first step, the middle N-2 steps, and the last step. In order to calculate their sum, the following operator is used to accumulate on the phase of the quantum bit:
[0155]
[0156] When performing the zero-fill operation, U i After expanding to a matrix of appropriate size, the weights of the candidate solutions and the three parts of Cost(sol) can be accumulated to the phase separately. For the first part, only CU 0 (Control U 0 For the second part, we need to determine which node is the starting point of each step in these N-2 steps. i Operator (Multi-way Control U i Gate), step si (1≤i≤N-2) starting point (step s i-1 Options i-1 ) and the original CU i The control bits in the gates are combined to form an MCU with multiple control bits. i operator, thereby accumulating the weight of the second part. For the third part, it is equivalent to the mirror image of the first part. It only needs to replace U i The operator is constructed as:
[0157]
[0158] The accumulation of the weight of the third part can be achieved.
[0159] After calculating the weight and Cost(sol) of the candidate solution, the phase value is converted to the amplitude of the quantum bit using the quantum phase estimation (QPE) algorithm. After that, the quantum comparator is used to compare the weight and the first threshold t of the candidate solution. If the weight and the sum of the candidate solution are less than the first threshold t, it means that the candidate solution is a better solution and the candidate solution is marked.
[0160] Through this embodiment, it is possible to implement the execution of the quantum operator Q 2 , accurately calculate the weights and sums of all candidate solutions, and quickly mark candidate solutions whose weight sums are less than the first threshold.
[0161] Example: Figure 6 As shown, it is the quantum operator O 2 implementation process.
[0162] For the weight of the candidate solution and the first part of Cost(sol), the quantum circuit performs a quantum register Implementing the quantum operator CU 0 ; For the weight of the candidate solution and the second part of Cost(sol), the quantum circuit first traverses all nodes and uses the quantum operator F j Determine whether the starting point of step i is quantum register |j>, if so, cooperate with CU i The original control bits of the gate are combined into a quantum register Implementing the quantum operator U i ; For the weight of the candidate solution and the third part of Cost(sol), the quantum circuit executes the quantum operator CU N-1 The calculation of the weight sum is completed. Secondly, the quantum circuit executes the last step of the quantum phase estimation (QPE) algorithm (the inverse process of QFT) to map the value on the phase to the amplitude. After that, the quantum comparator is used to judge the calculated weight sum. If the weight sum is less than the first threshold, the quantum operator O is flipped. 2 The corresponding quantum register Finally, the inverse process of the quantum phase estimation algorithm (i.e., all operators in the dotted box) is executed to restore all quantum bits in the quantum register |IR>.
[0163] In some of the embodiments, the number of iterations is between an upper bound on the number of iterations and a lower bound on the number of iterations; the upper bound on the number of iterations is determined by a first iteration formula; and the lower bound on the number of iterations is determined by a second iteration formula.
[0164] It should be noted that the number of candidate solutions is Among them, the symbol It means to take the smallest integer greater than it. For example, if the result is 2.7, then According to the pruning operation, there are N-1 steps in total, and each step has N-1 options, so all the numbers in this formula are N-1. Then the lower bound of the number of iterations is determined by the second iteration formula and expressed as: In the square root, the numerator is the number of candidate solutions, and the denominator is the number of valid solutions. This means that among all candidate solutions, the goal is to find (N-1)! valid solutions. The lower bound is usually greater than 1. It should be noted that not all valid solutions are the goal: when the default parameters are set, the first threshold t obtained randomly may be the optimal solution. At this time, there are no other solutions with a lower threshold than it. The goal at this time is to find this 1 valid solution. When the default parameters are set, the randomly obtained solution may also be the solution with the largest weight, so what we are looking for is these (N-1)! valid solutions.
[0165] The upper bound of the number of iterations is determined by the first iteration formula and expressed as: The number of iterations is between the upper bound and the lower bound of the number of iterations, and no matter how it changes, it will not exceed the upper bound and the lower bound of the number of iterations.
[0166] Here is how the number of iterations changes:
[0167] First, set a number of iterations num iter The left and right values of (which have different meanings from the upper and lower bounds), the left value can be equal to the lower bound. After that, the number of iterations num iter Randomly select a value between the left value and the right value to start iteration; if the result is not a valid optimization (the result is worse than the previous one), there are two possibilities. The first possibility is that the number of iterations is insufficient, and the second possibility is that the optimal solution has been found. For the second case, exit after step I reaches the upper limit of the number of repetitions; for the first case, increase the right value until the right value is equal to the upper limit. Then randomly select the number of iterations num iter Start iteration.
[0168] Through this embodiment, the lower bound that is greater than 1 is used to accelerate the convergence of the algorithm.
[0169] The present embodiment is described and illustrated below through preferred embodiments.
[0170] like Figure 7 As shown in , for solving the traveling salesman problem related to path optimization; first, the weights in the undirected fully weighted graph of the path to be optimized are constructed as follows Figure 7 The weighted adjacency matrix shown in the figure is input into the quantum circuit of the classical computer, and the classical computer performs the preparation of the algorithm. The preparation includes normalization of the input matrix and presetting of the default parameters of the algorithm. Secondly, the classical computer initializes the quantum circuit according to the node information in the problem and encodes all candidate solutions into the quantum circuit to complete the initialization of the quantum circuit. After that, the quantum circuit executes the quantum operator O 1 , quantum operator O 2 , quantum operator D, and measure to obtain a better solution (the quantum circuit execution process refers to the specific implementation of step S220). After obtaining a better solution, the optimal solution record and the threshold record are updated by the classical computer, and the updated threshold is again handed over to the quantum circuit for finding a better solution. When no solution with a smaller weight than the optimal solution of the current record can be found, the current record is regarded as the optimal solution to the traveling salesman problem, and the target path (Hamiltonian circuit) is output immediately, that is, the final solution to the traveling salesman problem is obtained.
[0171] It should be noted that the steps shown in the above process or the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0172] In this embodiment, a path optimization device based on a hybrid quantum algorithm is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and will not be repeated hereafter. The terms "module", "unit", "subunit", etc. used below can implement a combination of software and / or hardware of predetermined functions. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0173] Figure 8 is a structural block diagram of the path optimization device based on the hybrid quantum algorithm of this embodiment, such as Figure 8 As shown, the device includes: an acquisition module 210, an optimization module 220 and an update module 230;
[0174] An acquisition module 210 is used to acquire a weighted adjacency matrix of an undirected fully weighted graph of a path to be optimized;
[0175] The optimization module 220 is used to input the weight adjacency matrix into a preset quantum circuit for optimization to obtain a first candidate solution and a corresponding first weight; wherein, in the optimization process of encoding and pruning the quantum circuit, all candidate solutions are divided into multiple steps; the choice of the traveling salesman in each step is encoded into the quantum circuit, and corresponding pruning is performed to form a uniform superposition state containing all candidate solutions; the first candidate solution is the candidate solution with the highest probability; the candidate solution is the Hamiltonian circuit corresponding to the path in the undirected completely weighted graph that passes through each node once and returns to the starting point;
[0176] The updating module 230 is used to update the first candidate solution according to the first weight and a preset first threshold to obtain a target path.
[0177] The above device solves the problem in related technologies that it takes exponential time to find the optimal solution, resulting in inefficient path planning. By utilizing the optimization process of encoding and pruning in quantum circuits, the quantum resources (number of quantum bits) required to encode candidate solutions are effectively reduced, thereby achieving improved path planning efficiency while accurately planning the path.
[0178] In some of the embodiments, the path optimization device based on the hybrid quantum algorithm further includes a normalization module;
[0179] The normalization module is used to select the sum of the top N weights in the weight adjacency matrix as the maximum weight sum after obtaining the weight adjacency matrix of the undirected fully weighted graph of the path to be optimized, and normalize the maximum weight sum to a maximum binary score less than 1; and scale the remaining weights proportionally to binary scores in the range of [0,1).
[0180] In some of the embodiments, the optimization module 220 is further used for: step A, setting default parameters of the quantum circuit; the quantum circuit includes a quantum register and a quantum operator;
[0181] Step B, initializing the quantum circuit, inputting the weight adjacency matrix into the quantum circuit for encoding and pruning optimization, and forming a uniform superposition state containing all candidate solutions;
[0182] Step C, execute the quantum operator Q in the quantum operator 1 , mark the candidate solutions that meet the Hamiltonian circuit;
[0183] Step D, execute the quantum operator Q in the quantum operator 2 , calculate the weights and sums of all candidate solutions, and mark the candidate solutions whose weights and sums are less than the first threshold;
[0184] Step E, execute the quantum operator Q 1 and the quantum operator Q 2 The reverse process restores the quantum bits in the quantum register to their initial state;
[0185] Step F, executing the quantum operator D to amplify the probability amplitude of the quantum state corresponding to the candidate solution marked at the same time;
[0186] Step G: When steps C to F are repeatedly executed for the number of iterations in the default parameters, a first candidate solution and a corresponding first weight are obtained.
[0187] In some embodiments, the optimization module 220 is further configured to: 1 When , the first theorem and the first corollary are satisfied;
[0188] The first theorem is: when o i Represents the traveling salesman at step s i When the options are determined, N-1 options o i (0≤i≤N-2) can uniquely determine a candidate solution sol k ;
[0189] If the candidate solution sol k is a Hamiltonian circuit if and only if:
[0190] (1) Make o i =v j ;
[0191] (2)
[0192] Among them, j represents a variable, belonging to [1, N-1];
[0193] The first inference is: In the quantum circuit, a quantum register |IR> containing N-1 quantum bits is used to record the node v 0 The other N-2 nodes v i (1≤i≤N-1) is visited times; when step s j Option o in (0≤j≤N-2) j Points to node v i When the corresponding quantum bit |IR i-1 >The state is flipped;
[0194] If the candidate solution sol k is a Hamiltonian circuit if and only if: |IR i >=|1>.
[0195] In some of the embodiments, the optimization module 220 is further configured to: 2 When the node v i and node v j The weight between them is denoted as aij , calculate the weight and Cost(sol) of the candidate solution according to three parts, and get the corresponding phase value;
[0196] The phase value is converted to the amplitude of the qubit using a quantum phase estimation algorithm.
[0197] In some of these embodiments, the number of iterations is between an upper bound on the number of iterations and a lower bound on the number of iterations;
[0198] The upper bound of the number of generations is determined by the iteration formula; the lower bound of the number of generations is determined by the second iteration formula.
[0199] In some of the embodiments, the updating module 230 is further used to: update the first candidate solution according to the first weight and a preset first threshold;
[0200] The updated first candidate solution is input into the quantum circuit for execution until the cutoff condition is met and the target path is obtained.
[0201] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.
[0202] In this embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0203] Optionally, the computer device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0204] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0205] S1, obtain the weighted adjacency matrix of the undirected fully weighted graph of the path to be optimized;
[0206] S2, inputting the weight adjacency matrix into a preset quantum circuit for optimization to obtain a first candidate solution and a corresponding first weight; wherein, in the optimization process of encoding and pruning the quantum circuit, all candidate solutions are divided into multiple steps; the choice of the traveling salesman in each step is encoded into the quantum circuit, and corresponding pruning is performed to form a uniform superposition state containing all candidate solutions; the first candidate solution is the candidate solution with the highest probability; the candidate solution is the Hamiltonian circuit corresponding to the path in the undirected completely weighted graph that passes through each node once and returns to the starting point;
[0207] S3: Update the first candidate solution according to the first weight and a preset first threshold to obtain a target path.
[0208] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and will not be repeated in this embodiment.
[0209] In addition, in combination with the path optimization method based on the hybrid quantum algorithm provided in the above embodiment, a storage medium can also be provided in this embodiment to implement. The storage medium stores a computer program; when the computer program is executed by the processor, any one of the path optimization methods based on the hybrid quantum algorithm in the above embodiment is implemented.
[0210] It should be noted that the information and data involved in this application are all authorized by the user or fully authorized by all parties and will be used legally.
[0211] It should be understood that the specific embodiments described herein are only used to explain the application, rather than to limit it. Based on the embodiments provided in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of this application.
[0212] Obviously, the drawings are only some examples or embodiments of the present application. For ordinary technicians in the field, the present application can also be applied to other similar situations based on these drawings without creative work. In addition, it is understandable that although the work done in this development process may be complicated and lengthy, for ordinary technicians in the field, certain changes in design, manufacturing or production based on the technical content disclosed in this application are only conventional technical means and should not be regarded as insufficient content disclosed in this application.
[0213] The term "embodiment" in this application refers to a specific feature, structure or characteristic described in conjunction with the embodiment that can be included in at least one embodiment of the present application. The appearance of this phrase in various locations in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. It is clearly or implicitly understood by those of ordinary skill in the art that the embodiments described in this application can be combined with other embodiments without conflict.
[0214] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of patent protection. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the scope of protection of the present application. Therefore, the scope of protection of the present application shall be subject to the attached claims.
Claims
1. A path optimization method based on a hybrid quantum algorithm, characterized in that: include: Obtain the weighted adjacency matrix of the undirected fully weighted graph of the path to be optimized; The weighted adjacency matrix is input into a preset quantum circuit for optimization to obtain a first candidate solution and a corresponding first weight; wherein, in the optimization process of encoding and pruning the quantum circuit, all the candidate solutions are divided into multiple steps; the choice of the traveling salesman in each step is encoded into the quantum circuit, and corresponding pruning is performed to form a uniform superposition state containing all candidate solutions; the first candidate solution is the candidate solution with the highest probability; the candidate solution is the Hamiltonian circuit corresponding to the path in the undirected completely weighted graph that passes through each node once and returns to the starting point; The first candidate solution is updated according to the first weight and a preset first threshold to obtain a target path.
2. The path optimization method based on hybrid quantum algorithm according to claim 1, characterized in that: The method further comprises: After obtaining the weighted adjacency matrix of the undirected fully weighted graph of the path to be optimized, the sum of the top N weights in the weighted adjacency matrix is selected as the maximum weighted sum, and the maximum weighted sum is normalized to a maximum binary fraction less than 1; and the remaining weights are proportionally scaled to binary fractions in the range [0,1).
3. The path optimization method based on hybrid quantum algorithm according to claim 1, characterized in that: Inputting the weight adjacency matrix into a preset quantum circuit for optimization to obtain a first candidate solution and a corresponding first weight, including: Step A, setting default parameters of the quantum circuit; the quantum circuit includes a quantum register and a quantum operator; Step B, initializing the quantum circuit, inputting the weight adjacency matrix into the quantum circuit for encoding and pruning optimization, and forming a uniform superposition state containing all candidate solutions; Step C, executing the quantum operator Q1 in the quantum operators, marking the candidate solutions that meet the Hamiltonian circuit; Step D, executing the quantum operator Q2 in the quantum operators, calculating the weight sum of all the candidate solutions, and marking the candidate solutions whose weight sum is less than the first threshold; Step E, executing the inverse process of the quantum operator Q1 and the quantum operator Q2 to restore the quantum bits in the quantum register to an initial state; Step F, executing the quantum operator D to amplify the probability amplitude of the quantum state corresponding to the candidate solution marked at the same time; Step G: When steps C to F are repeatedly executed to meet the number of iterations in the default parameters, a first candidate solution and a corresponding first weight are obtained.
4. The path optimization method based on hybrid quantum algorithm according to claim 3 is characterized in that: When constructing the quantum operator Q1, the first theorem and the first corollary are satisfied; The first theorem is: when o i Represents the traveling salesman at step s i When the options are determined, N-1 options o i (0≤i≤N-2) can uniquely determine a candidate solution sol k ; If the candidate solution sol k is a Hamiltonian circuit if and only if: (1) Make o i =v j ; (2) Among them, j represents a variable, belonging to [1, N-1]; The first inference is: in the quantum circuit, a quantum register |IR> containing N-1 quantum bits is used to record the N-2 nodes v except node v0. i (1≤i≤N-1) is visited times; when step s j Option o in (0≤j≤N-2) j Points to node v i When the corresponding quantum bit |IR i-1 >The state is flipped; If the candidate solution sol k is a Hamiltonian circuit if and only if:
5. The path optimization method based on hybrid quantum algorithm according to claim 3, characterized in that: When constructing the quantum operator O2, the node v i and node v j The weight between them is denoted as a ij , calculate the weight and Cost(sol) of the candidate solution according to three parts, and get the corresponding phase value; The phase value is converted to the amplitude of the qubit using a quantum phase estimation algorithm.
6. The path optimization method based on hybrid quantum algorithm according to claim 3, characterized in that: The number of iterations is between an upper bound on the number of iterations and a lower bound on the number of iterations; The upper bound of the number of generations is determined by an iterative formula; the lower bound of the number of generations is determined by a second iterative formula.
7. The path optimization method based on hybrid quantum algorithm according to claim 1, characterized in that: Updating the first candidate solution according to the first weight and a preset first threshold to obtain a target path includes: updating the first candidate solution according to the first weight and a preset first threshold; The updated first candidate solution is input into the quantum circuit for execution until a cutoff condition is met to obtain a target path.
8. A path optimization device based on a hybrid quantum algorithm, characterized in that: include: Get modules, optimize modules, and update modules; The acquisition module is used to acquire the weighted adjacency matrix of the undirected fully weighted graph of the path to be optimized; The optimization module is used to input the weight adjacency matrix into a preset quantum circuit for optimization to obtain a first candidate solution and a corresponding first weight; wherein, in the optimization process of encoding and pruning the quantum circuit, all the candidate solutions are divided into multiple steps; the choice of the traveling salesman in each step is encoded into the quantum circuit, and corresponding pruning is performed to form a uniform superposition state containing all candidate solutions; the first candidate solution is the candidate solution with the highest probability; the candidate solution is the Hamiltonian circuit corresponding to the path in the undirected completely weighted graph that passes through each node once and returns to the starting point; The updating module is used to update the first candidate solution according to the first weight and a preset first threshold to obtain a target path.
9. A computer device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps of the path optimization method based on the hybrid quantum algorithm according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the path optimization method based on a hybrid quantum algorithm according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Intelligent orchard carrying system and method thereof
CN119849727A
An intelligent orchard transport system and method thereof
CN119849727B
Intelligent analysis computer algorithm operating system
CN120070609A
Computer device
CN121330088A
Self-adaptive updating method, system and equipment for procedure sorting reference value
CN122549882A