Travel salesman problem solving method and device based on controllable probabilistic device
Through the method based on the controllable probability device, the calculation process of the traveling salesman problem is simplified, the hardware consumption is reduced and the accuracy is improved, and the problems of complex calculation and low accuracy in the existing technology are solved.
Patent Information
- Application Number
- CN202410830715.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-06-25
AI Technical Summary
In the existing technology, the traveling salesman problem has a complex solution process, high hardware consumption, and low accuracy. There are problems such as complex calculation process, high hardware consumption, and low accuracy.
Using a method based on controllable probability devices, a QUBO matrix is constructed by obtaining the city sequence and coordinates, and the spin state and level signal of the controllable probability unit are used to perform numerical calculation of the analog level, and the target controllable probability unit position is randomly selected. Input analog level signals, cache and judge spin energy changes, and obtain the city access sequence.
It simplifies the calculation process of the traveling salesman problem, reduces hardware consumption, improves calculation accuracy, avoids local optimal solution problems, and improves calculation efficiency and accuracy.
Smart Images

Figure CN118822006A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of traveling salesman problem solving, and in particular to a traveling salesman problem solving method and device based on a controllable probability device. Background Art
[0002] The Traveling Salesman Problem (TSP) is a classic combinatorial optimization problem. Given a series of cities and the distances between each pair of cities, find the shortest path that visits each city once and returns to the starting city. It is a non-deterministic polynomial (NP) hard problem in combinatorial optimization and is very important in operations research and theoretical computer science.
[0003] Classical computers usually have difficulty solving combinatorial optimization problems efficiently in a short period of time. Although quantum algorithms can solve combinatorial optimization problems in a short period of time, they have many limitations in hardware. For example, quantum annealing equipment based on low-temperature superconducting systems has been unable to maintain large-scale quantum coherence. Although quantum heuristic algorithms based on traditional circuits can cope with large-scale combinatorial optimization problems, they have problems such as high hardware costs and large device memory requirements. At the same time, combinatorial optimization problems have problems such as difficulty in convergence, long time consumption, and low precision when they are large in scale.
[0004] At present, the heuristic algorithms used to solve the traveling salesman problem mainly rely on the generation of random numbers for the search and optimization process, and parameter tuning is required. These methods have some problems, such as: since the search process is based on randomness, there is a probability of falling into the local optimal solution; choosing appropriate parameter values requires certain experience and experiments, and different problems may require different parameter settings; the choice of initial solution has a significant impact on the performance of the algorithm; due to the randomness of the algorithm, running the same algorithm multiple times may lead to different results, making the stability and reproducibility of the results difficult, which in turn affects the accuracy and stability of the algorithm.
[0005] It can be seen that the current process of solving the traveling salesman problem has problems such as complex calculation process, large hardware consumption and low accuracy. Summary of the invention
[0006] The present invention provides a method and device for solving the traveling salesman problem based on a controllable probability device, which are used to solve the defects of the traveling salesman problem in the prior art, such as complex calculation process, large hardware consumption and low accuracy, and achieve the purpose of simplifying the calculation process of the traveling salesman problem, reducing hardware consumption and improving accuracy.
[0007] The present invention provides a method for solving a traveling salesman problem based on a controllable probability device, wherein the controllable probability device comprises a plurality of controllable probability units arranged in an array, and each of the plurality of controllable probability units flips with a corresponding probability according to the size of the level signal when receiving a level signal; the method comprises the following steps.
[0008] Acquire multiple city sequences and multiple city coordinates of the traveling salesman problem; obtain a QUBO matrix according to the multiple city sequences and multiple city coordinates; obtain an analog level value according to the QUBO matrix and the spin state of each controllable probability unit in the controllable probability device within the last N set periods stored locally after starting to solve the traveling salesman problem; wherein the spin state includes: flipping or not flipping; N is a positive integer; randomly select the positions of a target number of target controllable probability units according to the positions of the multiple controllable probability units; wherein the target number of target controllable probability units are not adjacent to each other, and the target number is the number of multiple city coordinates; according to the position of the target controllable probability unit, input the analog level signal corresponding to the analog level value into the target controllable probability unit; cache the spin states of all controllable probability units in the controllable probability device every set period, and store the spin states of all controllable probability units in the cached controllable probability device locally after each N set period; According to the spin states of all controllable probability units in the controllable probability device in the current N setting cycles and the previous N setting cycles stored locally, it is judged whether the spin energy of all controllable probability units in the controllable probability device no longer changes; when it is determined that the spin energy has changed, the positions of the target number of controllable probability units are randomly selected according to the positions of multiple controllable probability units and its subsequent steps are re-executed; when it is determined that the spin energy no longer changes, in the M times N setting cycles stored locally, according to the spin states of the controllable probability units in the controllable probability device in the Kth N setting cycles, a spin state array is obtained; wherein, the spin energy of all controllable probability units in the controllable probability device in the Kth N setting cycles is less than the spin energy of all controllable probability units in the controllable probability device in the N setting cycles of other orders in M times; M and K are positive integers, M is greater than 1, and K is less than or equal to M; the city visit order is obtained according to the spin state array.
[0009] According to a method for solving a traveling salesman problem based on a controllable probability device provided by the present invention, the method determines whether the spin energy of all controllable probability units in the controllable probability device no longer changes based on the spin states of all controllable probability units in the controllable probability device within the current N set periods and the previous N set periods stored locally, including: calculating a first spin energy based on the spin states of each controllable probability unit within the current N set periods; calculating a second spin energy based on the spin states of each controllable probability unit in the previous N set periods; determining that the spin energy no longer changes when the first spin energy is equal to the second spin energy; and determining that the spin energy changes when the first spin energy is not equal to the second spin energy.
[0010] According to a method for solving the traveling salesman problem based on a controllable probability device provided by the present invention, N is greater than or equal to 16.
[0011] The present invention also provides a traveling salesman problem solving device based on a controllable probability device, wherein the controllable probability device comprises a plurality of controllable probability units arranged in an array, and each of the plurality of controllable probability units flips with a corresponding probability according to the magnitude of the level signal when receiving a level signal; the device comprises the following modules: An acquisition module is used to obtain multiple city sequences and multiple city coordinates of the traveling salesman problem; A QUBO matrix calculation module, used to obtain a QUBO matrix according to multiple city sequences and multiple city coordinates; The level value calculation module is used to obtain the analog level value according to the QUBO matrix and the spin state of each controllable probability unit in the controllable probability device within the last N set cycles stored locally after the start of solving the traveling salesman problem; wherein the spin state includes: flipping or not flipping; N is a positive integer; A selection module is used to randomly select the positions of a target number of target controllable probability units according to the positions of the multiple controllable probability units; wherein the target number of target controllable probability units are not adjacent to each other, and the target number is the number of multiple city coordinates; A level input module, used for inputting an analog level signal corresponding to an analog level value into a target controllable probability unit according to the position of the target controllable probability unit; A cache module, used for caching the spin states of all controllable probability units in the controllable probability device at every set period, and storing the cached spin states of all controllable probability units in the controllable probability device locally after caching N set periods; a storage module, used for storing the spin states of each controllable probability unit in the controllable probability device within N set periods from the cache module; A judgment module, used to judge whether the spin energy of all controllable probability units in the controllable probability device no longer changes according to the spin states of all controllable probability units in the controllable probability device within the current N set periods and the previous N set periods stored locally; and
[0012] A processing module, used for re-executing the processes in the selection module, the level input module, the buffer module and the judgment module when it is determined that the spin energy has changed; The processing module is further used to obtain a spin state array according to the spin states of the controllable probability units in the controllable probability device in the Kth N setting period in a total of M times N setting periods stored locally, when it is determined that the spin energy no longer changes; wherein the spin energy of all the controllable probability units in the controllable probability device in the Kth N setting period is less than the spin energy of all the controllable probability units in the controllable probability device in the M times N setting periods of other orders; M and K are positive integers, M is greater than 1, and K is less than or equal to M; A solving module is used to obtain the city visiting sequence according to the spin state array.
[0013] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, any of the above-mentioned methods for solving the traveling salesman problem based on a controllable probability device is implemented.
[0014] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, any of the above-mentioned methods for solving the traveling salesman problem based on a controllable probability device is implemented.
[0015] The present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements any of the above-mentioned methods for solving the traveling salesman problem based on a controllable probability device.
[0016] The method and device for solving the traveling salesman problem based on a controllable probability device provided by the present invention obtain multiple city sequences and multiple city coordinates of the traveling salesman problem, obtain a QUBO matrix according to the multiple city sequences and multiple city coordinates, obtain an analog level value according to the QUBO matrix and the spin state of each controllable probability unit in the controllable probability device within the last N set cycles, and randomly select the positions of the target controllable probability units of the target number according to the positions of the multiple controllable probability units, input the analog level signal corresponding to the analog level value into the target controllable probability unit according to the position of the target controllable probability unit, obtain a spin state array and obtain a city access sequence according to the spin state array when the spin energy of all controllable probability units no longer changes, so as to achieve the purpose of simplifying the calculation process of the traveling salesman problem, reducing hardware consumption and improving accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 It is a flow chart of a method for solving the traveling salesman problem based on a controllable probability device provided by the present invention.
[0019] Figure 2 It is a schematic diagram of the controllable probability device provided by the present invention.
[0020] Figure 3 It is a circuit structure diagram of any controllable probability unit in the controllable probability device provided by the present invention.
[0021] Figure 4 It is a diagram of the output characteristics of the controllable probability device provided by the present invention under different bias voltages.
[0022] Figure 5 It is a structural schematic diagram of a traveling salesman problem solving device based on a controllable probability device provided by the present invention.
[0023] Figure 6 This is one of the structural schematic diagrams of the traveling salesman problem solving device provided by the present invention.
[0024] Figure 7 This is the second structural schematic diagram of the traveling salesman problem solving device provided by the present invention.
[0025] Figure 8 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0027] The Ising model describes the random process of phase change of matter through a group of interconnected spins. Combinatorial optimization problems can be mapped to the Ising model, and the optimal solution to the combinatorial optimization problem can be obtained by solving the Ising model. Mapping the traveling salesman problem to the Ising model for solution can effectively avoid the problem of local optimal solutions.
[0028] In the related art, the magnetic tunnel junction (MTJ) is a sandwich structure device, which includes a reference layer, a tunneling barrier layer and a free layer from bottom to top. Among them, the free layer and the reference layer are two layers of magnetic films, forming a nanomagnet; the insulating layer (tunneling barrier layer) is an oxide film, which acts as a tunneling barrier to isolate the electron migration in the free layer and the reference layer. By applying an external electromagnetic field control, the magnetic moment direction of the free layer can be switched to be parallel or anti-parallel to the reference layer. If it is a parallel state, the resistance of the magnetic tunnel junction is low, and the resistance of the anti-parallel state is high, so the difference in resistance can be used as a logical state. When the tunneling barrier in the magnetic tunnel junction is low, the parallel state and the anti-parallel state experience random jumping due to thermal noise, resulting in random output characteristics.
[0029] Combine the following Figure 1-Figure 4 The present invention describes the method for solving the traveling salesman problem based on a controllable probability device.
[0030] Figure 1 This is one of the flow charts of the method for solving the traveling salesman problem based on a controllable probability device provided by the present invention, such as Figure 1 As shown, the method includes the following S110 to S190.
[0031] S110: Obtain multiple city sequences and multiple city coordinates for the traveling salesman problem.
[0032] S120: Obtain a QUBO matrix according to the multiple city sequences and the multiple city coordinates.
[0033] In order to solve the traveling salesman problem, a quadratic unconstrained binary optimization (QUBO) model is created according to multiple city sequences and multiple city coordinate transformations, and the QUBO matrix in the QUBO model is obtained.
[0034] S130: Obtain an analog level value according to the QUBO matrix and the spin state of each controllable probability unit in the controllable probability device within the last N set cycles stored locally after starting to solve the traveling salesman problem; wherein the spin state includes: flipping or not flipping; N is a positive integer.
[0035] Before introducing S130, the controllable probability device in the embodiment of the present invention is first introduced.
[0036] like Figure 2As shown, the controllable probability device 100 includes a plurality of controllable probability units 200 arranged in an array, and each of the plurality of controllable probability units 200 flips with a corresponding probability according to the magnitude of the level signal when receiving a level signal.
[0037] The flip probability of the controllable probability unit 200 follows the following formula: s (i,t+1) =s (i,t) sgn[rand(0,1)+tanh(V (i,t) )].
[0038] Among them, i represents the position of the controllable probability unit, t represents the setting period, and s (i,t) is the initial spin state, which takes the value of 1 or -1, where 1 indicates that flipping occurs and -1 indicates that flipping does not occur; s (i,t+1) is the spin state after a set period, and its value is 1 or -1; sgn is the sign function, V (i,t) is the analog level value at time t, and tanh is the hyperbolic tangent function. From the above formula, we can see that V (i,t) The larger the value is, the output probability of the controllable probability unit is biased towards 1, that is, the greater the probability of flipping. (i,t) The smaller it is, the output probability of the controllable probability unit tends to 0, and the probability of flipping is smaller.
[0039] The size of the set period can be set by those skilled in the art according to actual conditions, and the embodiment of the present invention does not limit this.
[0040] In some embodiments, Figure 2 As shown, the multiple controllable probability units 200 arranged in an array can be n×n controllable probability units, the number of controllable probability units in each row and the number of controllable probability units in each column are both n, n is a positive integer and n is greater than or equal to 2.
[0041] Of course, it is understandable that the plurality of controllable probability units 200 arranged in an array may also be n×m controllable probability units, where m is a positive integer and m is greater than or equal to 2, and m≠n.
[0042] m and n can be set by those skilled in the art according to actual conditions, and are not limited in this embodiment of the present invention.
[0043] For example, n can be 1024, and the multiple controllable probability units arranged in an array can be 1024×1024 controllable probability units, and the number of controllable probability units in each row and the number of controllable probability units in each column are both 1024.
[0044] Figure 2 The middle arrow indicates the orientation of the magnetization direction.
[0045] In some embodiments, Figure 3 As shown, the controllable probability unit 200 includes: a resistor 201, a transistor 202, a magnetic tunnel junction 203, a positive voltage supply terminal 204, a negative voltage supply terminal 205, a comparator 206 and a reference voltage terminal 207.
[0046] Please continue to see Figure 3 , one end of the resistor 201 is connected to the positive voltage supply terminal 204, and the other end of the resistor 201 is connected to the collector of the transistor 202. The top electrode of the magnetic tunnel junction 203 (the electrode connected to the reference layer of the magnetic tunnel junction 203) is connected to the emitter of the transistor 202, and the bottom electrode of the magnetic tunnel junction 203 is connected to the negative voltage supply terminal 204. The first input terminal 2061 of the comparator 206 is connected to the collector of the transistor 202, and the second input terminal 2062 of the comparator 206 is connected to the reference voltage terminal 207. The base of the transistor 202 is the input terminal of the controllable probability unit 200, and the output terminal of the comparator 206 is the output terminal of the controllable probability unit 200.
[0047] In some embodiments, transistor 202 may be an NMOS transistor.
[0048] Compared to the reference voltage on the external circuit input reference voltage terminal 207, the voltage provided by the positive voltage supply terminal 204 (corresponding to Figure 3 The negative voltage supply terminal 205 (corresponding to VDD1) is higher than the reference voltage on the reference voltage terminal 207. Figure 3 The voltage provided by the reference voltage terminal 207 is lower than the reference voltage provided by the reference voltage terminal 207.
[0049] See also Figure 3 When the input voltage at the input end of the controllable probability unit 200 has a larger negative deviation relative to the reference voltage, the output end of the controllable probability unit 200 is more likely to output a low level signal; when the input voltage at the input end of the controllable probability unit 200 has a larger positive deviation relative to the reference voltage, the output end of the controllable probability unit 200 is more likely to output a high level signal.
[0050] The circuit structure in the controllable probability unit 200 of the present invention can still achieve self-oscillation by relying on the magnetic tunnel junction 203 in the absence of external trigger conditions, and can completely solve the problem of data errors caused by mismatch of trigger signals.
[0051] According to the controllable probability unit 200 provided above, the output characteristics under different bias voltages are as follows: Figure 4 shown.
[0052] See also Figure 4 When the input voltage is small, the average value of the output probabilistic pulse is 0.22 (see Figure 4As the input voltage increases, the average value of the output probabilistic pulse increases from 0.22 to 0.49 (see Figure 4 As the input voltage increases further, the average value of the output probabilistic pulses rises to 0.75 (see Figure 4 (c) of the annex).
[0053] It should be noted that Figure 4 The values shown are the average values of the probabilistic pulses within a sampling time of 100 μs. Figure 4 The vertical axis is the normalized value.
[0054] S130 is described below. After the traveling salesman problem is solved, before the level signal is input into the controllable probability device 100, the spin state of each controllable probability unit 200 in the controllable probability device 100 is the initial spin state. In some embodiments, the initial spin state of the controllable probability unit 200 is assumed to be not flipped, that is, the initial spin state of 200 can be recorded as -1.
[0055] After starting to solve the traveling salesman problem, if a level signal has been input into the controllable probability device 100, the spin state of each controllable probability unit in the controllable probability device within the last N set periods is directly obtained.
[0056] For example, each controllable probability unit in the controllable probability device may or may not flip when receiving a level signal last time. When the controllable probability unit 200 flips, the spin state of the controllable probability unit 200 is recorded as 1, and when the controllable probability unit 200 does not flip, the spin state of the controllable probability unit 200 is recorded as -1.
[0057] In the embodiment of the present invention, when obtaining the analog level value according to the QUBO matrix and the spin state of each controllable probability unit in the controllable probability device within the last N set cycles stored locally after starting to solve the traveling salesman problem, the analog level value V can be obtained by the following formula: in .
[0058]
[0059] Among them, i and j represent the positions of the controllable probability units, t represents the above-mentioned setting period, and s (i,t) and (j,t) There are two spin states, J ij is the element in the i-th row and j-th column of the QUBO matrix, J ij Indicates (i,t) and (j,t) A is the level adaptation factor, and the value of A is adapted to the design and manufacturing process of the specific device.
[0060] S140: Randomly select the positions of a target number of controllable probability units according to the positions of the plurality of controllable probability units; wherein the target number of controllable probability units are not adjacent to each other, and the target number is the number of the plurality of city coordinates.
[0061] S150: Inputting an analog level signal corresponding to the analog level value into the target controllable probability unit according to the position of the target controllable probability unit.
[0062] S160: Cache the spin states of all controllable probability units in the controllable probability device at every set period, and store the cached spin states of all controllable probability units in the controllable probability device locally after caching N set periods.
[0063] In some embodiments, N is greater than or equal to 16 to ensure the rationality and adequacy of the statistical process.
[0064] The spin state of each controllable probability unit in the controllable probability device can be calculated by the following formula: Among them, s (i,t=0) is the initial spin state of the randomly selected controllable probability unit, with a value of ±1; s (i,t=N+1) The spin state output by the randomly selected controllable probability unit after accepting the judgment is taken as ±1.
[0065] S170: Determine whether the spin energy of all controllable probability units in the controllable probability device no longer changes based on the spin states of all controllable probability units in the controllable probability device in the current N setting periods and the previous N setting periods stored locally.
[0066] In some embodiments, the first spin energy can be calculated based on the spin state of each controllable probability unit in the current N set periods, and the second spin energy can be calculated based on the spin state of each controllable probability unit in the previous N set periods.
[0067] When the spin energy is calculated according to the spin state of each controllable probability unit within N set periods, the distance D between cities is obtained according to the spin state of each controllable probability unit within N set periods. i,j (i, j = 1, 2, ... G), G is the number of multiple city coordinates; for whether the city has been visited, 0 means not visited, and 1 means visited.
[0068] The spin energy can be obtained by the following formula: Among them, x i,t indicates that the i-th location is visited at time t, xj,t Indicates that the jth location was visited at time t.
[0069] In the case where the first spin energy is equal to the second spin energy, it is determined that the spin energy does not change any more; and in the case where the first spin energy is not equal to the second spin energy, it is determined that the spin energy changes.
[0070] Of course, it is understandable that a preset difference may be set, and when the absolute value of the difference between the first spin energy and the second spin energy is less than the preset difference, it is determined that the spin energy does not change any more, otherwise it is determined that the spin energy changes.
[0071] The preset difference value may be set by those skilled in the art according to actual conditions, and the embodiment of the present invention is not limited thereto.
[0072] When it is determined that the spin energy has changed, S140 and subsequent steps are re-executed.
[0073] When it is determined that the spin energy does not change any more, S180 is executed.
[0074] S180: obtaining a spin state array according to the spin states of the controllable probability units in the controllable probability device in the Kth N setting period in a total of M times N setting periods stored locally.
[0075] The spin energy of all controllable probability units in the controllable probability device within the Kth N set periods is less than the spin energy of all controllable probability units in the controllable probability device within the Mth N set periods in other orders; M and K are positive integers, M is greater than 1, and K is less than or equal to M.
[0076] When it is determined that the spin energy no longer changes, the spin energy corresponding to the spin state of the controllable probability unit in the controllable probability device within the N set periods stored M times in total, and the spin state array corresponding to the spin state of the controllable probability unit in the controllable probability device within the Kth N set periods with the smallest spin energy is output.
[0077] S190: Obtain a city access sequence according to the spin state array.
[0078] Convert the spin state array into a city visit sequence to complete the solution to the traveling salesman problem.
[0079] The method for solving the traveling salesman problem based on a controllable probability device provided by the present invention obtains multiple city sequences and multiple city coordinates of the traveling salesman problem, obtains a QUBO matrix according to the multiple city sequences and multiple city coordinates, obtains an analog level value according to the QUBO matrix and the spin state of each controllable probability unit in the controllable probability device within the last N set cycles, and randomly selects the positions of a target number of target controllable probability units according to the positions of the multiple controllable probability units, inputs an analog level signal corresponding to the analog level value into the target controllable probability unit according to the position of the target controllable probability unit, obtains a spin state array and obtains a city access sequence according to the spin state array when the spin energy of all controllable probability units no longer changes, thereby achieving the purpose of simplifying the calculation process of the traveling salesman problem, reducing hardware consumption and improving accuracy.
[0080] The method for solving the traveling salesman problem based on controllable probability devices provided by the present invention obtains the QUBO matrix by converting the traveling salesman problem into the QUBO problem, and performs annealing solution on the Ising model, thereby avoiding the situation where the solution of the traveling salesman problem falls into a local optimal solution; a target number of controllable probability units are selected to participate in the calculation at the same time, which can greatly shorten the calculation time and improve the calculation efficiency; the array composed of controllable probability devices can greatly reduce the hardware consumption, convert the complex function calculation into cumulative operation, and reduce the calculation complexity.
[0081] The traveling salesman problem solving device based on controllable probability devices provided by the present invention is described below. The traveling salesman problem solving device based on controllable probability devices described below and the traveling salesman problem solving method based on controllable probability devices described above can be referenced to each other.
[0082] Figure 5 Schematic diagram of the structure of the traveling salesman problem solving device based on controllable probability device provided by the present invention. Figure 5 As shown, the traveling salesman problem solving device 500 based on a controllable probability device includes: The acquisition module 501 is used to acquire multiple city sequences and multiple city coordinates of the traveling salesman problem.
[0083] The QUBO matrix calculation module 502 is used to obtain a QUBO matrix according to a plurality of city sequences and a plurality of city coordinates.
[0084] The level value calculation module 503 is used to obtain the analog level value according to the QUBO matrix and the spin state of each controllable probability unit in the controllable probability device within the last N set cycles stored locally after the start of solving the traveling salesman problem; wherein the spin state includes: flipping or not flipping; N is a positive integer.
[0085] The selection module 504 is used to randomly select the positions of a target number of target controllable probability units according to the positions of multiple controllable probability units; wherein the target number of target controllable probability units are not adjacent to each other, and the target number is the number of multiple city coordinates.
[0086] The level input module 505 is used to input the analog level signal corresponding to the analog level value into the target controllable probability unit according to the position of the target controllable probability unit.
[0087] The cache module 506 is used to cache the spin states of all controllable probability units in the controllable probability device every set period, and store the cached spin states of all controllable probability units in the controllable probability device locally after caching N set periods.
[0088] The storage module 507 is used to store the spin state of each controllable probability unit in the controllable probability device within N set periods from the cache module.
[0089] The judgment module 508 is used to judge whether the spin energy of all controllable probability units in the controllable probability device no longer changes based on the spin states of all controllable probability units in the controllable probability device within the current N set periods and the previous N set periods stored locally.
[0090] The processing module 509 is used to return to the selection module 504 to execute the functions of each module in the subsequent modules (level input module 505, cache module 506 and judgment module 507) by randomly selecting the positions of the target number of controllable probability units according to the positions of multiple controllable probability units when it is determined that the spin energy has changed.
[0091] The processing module 509 is also used to obtain a spin state array according to the spin states of the controllable probability units in the controllable probability device in the Kth N setting periods, in a total of M times N setting periods stored locally, when it is determined that the spin energy no longer changes; wherein the spin energy of all the controllable probability units in the controllable probability device in the Kth N setting periods is less than the spin energy of all the controllable probability units in the controllable probability device in the M times N setting periods of other orders; M and K are positive integers, M is greater than 1, and K is less than or equal to M.
[0092] The solution module 510 is used to obtain the city visit sequence according to the spin state array.
[0093] The traveling salesman problem solving device based on controllable probability devices provided by the present invention obtains multiple city sequences and multiple city coordinates of the traveling salesman problem, obtains a QUBO matrix according to the multiple city sequences and multiple city coordinates, obtains an analog level value according to the QUBO matrix and the spin state of each controllable probability unit in the controllable probability device within the last N set cycles, and randomly selects the positions of the target controllable probability units of the target number according to the positions of the multiple controllable probability units, inputs the analog level signal corresponding to the analog level value into the target controllable probability unit according to the position of the target controllable probability unit, obtains a spin state array and obtains a city access sequence according to the spin state array when the spin energy of all controllable probability units no longer changes, thereby achieving the purpose of simplifying the calculation process of the traveling salesman problem, reducing hardware consumption and improving accuracy.
[0094] It is understandable that, in actual situations, it may be necessary to merge several of the above-mentioned multiple functional modules or divide one functional module into multiple functional modules, etc., as long as the corresponding functions can be achieved.
[0095] Figure 6 Schematic diagram of the structure of the traveling salesman problem solving device provided by the embodiment of the present invention. Figure 6 As shown, the traveling salesman problem solving device 600 includes: a controllable probability device, and the above-mentioned traveling salesman problem solving device 500 based on the controllable probability device.
[0096] The controllable probability device includes: a plurality of controllable probability units arranged in an array, each of the plurality of controllable probability units flips with a corresponding probability according to the magnitude of the level signal when receiving a level signal.
[0097] The specific circuit structure of the controllable probability unit in the controllable probability device can be found in the above introduction to the controllable probability unit 200, which will not be repeated here.
[0098] In some embodiments, the functions of the functional modules of the traveling salesman problem solving device 500 based on controllable probability devices are re-divided to obtain the following: Figure 7 The traveling salesman problem solving apparatus 700 is shown.
[0099] See also Figure 7 The traveling salesman problem solving device 700 includes: a main operator 701, a TSP problem input module 702, a spin state storage module 703, an input and output module 704, an analog level generation module 705, a position selection module 706, a spin matrix 707, and a spin cache module 708.
[0100] The main operator 701 is used to obtain the J matrix (i.e., the QUBO matrix mentioned above) from the TSP problem input module, obtain the spin state of each controllable probability unit in the controllable probability device within the last N set periods stored locally from the spin state storage module 703, and obtain the analog level value according to the obtained J matrix and the spin state of each controllable probability unit in the controllable probability device within the last N set periods stored locally obtained in the spin state storage module.
[0101] The specific calculation process for obtaining the analog level value can refer to the corresponding description in the method embodiment, which will not be repeated here.
[0102] The TSP problem input module 702 is used to convert the traveling salesman problem parameters into the QUBO problem parameter matrix J according to the city sequence and city coordinate parameters (i.e., the multiple city sequences and multiple city coordinates mentioned above), and send the matrix J to the main operator after receiving the first read request issued by the main operator.
[0103] The spin state storage module 703 is used to store the spin state of each controllable probability unit in the controllable probability device, and send the spin state to the main operator after receiving the second read request sent by the main operator 701.
[0104] The input-output module 704 is specifically used to send the analog level value calculated by the main operator 701 to the analog level generation module 705, and to send the position of the controllable probability unit (i.e., the target controllable probability unit) randomly generated by the main operator 701 to the position selection module 706, and to send the spin state cached in the spin cache module 708 to the spin state storage module 703.
[0105] In a Field-Programmable Gate Array (FPGA) implementation, the input-output module 704 may be an Advanced eXtensible Interface (AXI) high-speed interface module.
[0106] The analog level generating module 705 is used to receive the analog level value calculated by the main operator 701 and convert the analog level value into an analog level signal.
[0107] The position selection module 706 is used to receive the position of the controllable probability unit randomly generated by the main operation unit 701, and input the analog level signal generated by the analog level generation module to the input end of the randomly generated controllable probability unit. The randomly generated controllable probability units are not adjacent to each other.
[0108] The spin matrix (i.e., the above-mentioned controllable probability device) 707 includes n×n controllable probability units, which are used to control the controllable probability units randomly selected by the main operator 701 to perform probability flipping under the regulation of the analog level signal provided by the analog level generation module; and send the spin states within N set periods to the spin cache module 708.
[0109] The spin cache module 708 is specifically used to cache the spin states of each controllable probability unit in the spin matrix within N set periods, and send the cached spin states of each controllable probability unit in the spin matrix within N set periods to the spin state storage module 703 through the input and output module 704.
[0110] The traveling salesman problem solving device provided by the present invention is closely integrated with hardware and gives full play to the intrinsic probability output characteristics of the controllable probability device. Compared with the general CMOS type traveling salesman problem solving device, it does not need to use a random number generation module and a comparison module, and avoids using complex functions such as exponential functions, thereby effectively reducing the occupied area of the computing device; by judging whether to accept the flip of the controllable probability unit according to the output statistics of the spin state in a number of clock cycles, the complexity of the computing system and the computing process caused by the use of random numbers and complex functions in the general CMOS type traveling salesman problem solving device is avoided; the present invention interconnects the logic calculation part and the spin flip part through the input and output module, thereby avoiding the clock interference between the logic calculation and the spin flip; and considering the long-term uneven technical development level of the logic calculation part and the spin flip part, the traveling salesman problem solving device based on the controllable probability device provided by the present invention can be optimized and improved respectively to achieve the improvement of the overall computing ability.
[0111] Figure 8 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 8As shown, the electronic device may include: a processor (processor) 810, a communication interface (Communications Interface) 820, a memory (memory) 830 and a communication bus 840, wherein the processor 810, the communication interface 820, and the memory 830 communicate with each other through the communication bus 840. The processor 810 can call the logic instructions in the memory 830 to execute a method for solving the traveling salesman problem based on a controllable probability device, wherein the controllable probability device includes a plurality of controllable probability units arranged in an array, and each of the plurality of controllable probability units flips with a corresponding probability according to the size of the level signal when receiving a level signal; the method includes: obtaining a plurality of city sequences and a plurality of city coordinates of the traveling salesman problem; obtaining a QUBO matrix according to the plurality of city sequences and the plurality of city coordinates; obtaining an analog level value according to the QUBO matrix and the spin state of each controllable probability unit in the controllable probability device within the last N set cycles stored locally after the traveling salesman problem is solved; wherein the spin state includes: flipping or not flipping; N is a positive integer; randomly selecting the positions of a target number of target controllable probability units according to the positions of the plurality of controllable probability units; wherein the target number of target controllable probability units are not adjacent to each other, and the target number is the number of the plurality of city coordinates; according to the position of the target controllable probability unit, inputting the analog level signal corresponding to the analog level value into the target controllable probability unit; caching every set period The spin states of all controllable probability units in the controllable probability device are stored locally after each cache of N set cycles; according to the spin states of all controllable probability units in the controllable probability device in the current N set cycles and the last N set cycles stored locally, it is determined whether the spin energy of all controllable probability units in the controllable probability device no longer changes; if it is determined that the spin energy has changed, the target number of target controllable probability units is randomly selected according to the positions of multiple controllable probability units. Position and subsequent steps thereof; when it is determined that the spin energy no longer changes, in the locally stored M times N setting periods, according to the spin states of the controllable probability units in the controllable probability device in the Kth N setting periods, a spin state array is obtained; wherein, the spin energy of all the controllable probability units in the controllable probability device in the Kth N setting periods is less than the spin energy of all the controllable probability units in the controllable probability device in the N setting periods of other orders in the M times; M and K are positive integers, M is greater than 1, and K is less than or equal to M; the city visit order is obtained according to the spin state array.
[0112] In addition, the logic instructions in the above-mentioned memory 830 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0113] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the traveling salesman problem solving method based on a controllable probability device provided by the above methods, wherein the controllable probability device includes a plurality of controllable probability units arranged in an array, and each of the plurality of controllable probability units flips with a corresponding probability according to the magnitude of the level signal when receiving a level signal; the method includes: obtaining a plurality of city sequences and a plurality of city coordinates of the traveling salesman problem; obtaining a QUBO matrix according to the plurality of city sequences and the plurality of city coordinates; obtaining a simulation level value according to the QUBO matrix and the spin state of each controllable probability unit in the controllable probability device within the last N set cycles stored locally after the traveling salesman problem is solved; wherein the spin state includes: flipping or not flipping; N is a positive integer; randomly selecting the positions of a target number of target controllable probability units according to the positions of the plurality of controllable probability units; wherein the target number of target controllable probability units are not adjacent to each other, and the target number is the number of the plurality of city coordinates; according to the positions of the target controllable probability units, the simulation level value is The analog level signal corresponding to the value is input into the target controllable probability unit; the spin state of all controllable probability units in the controllable probability device is cached every set period, and the spin state of all controllable probability units in the cached controllable probability device is stored locally after each N set period is cached; according to the spin state of all controllable probability units in the controllable probability device in the current N set periods and the last N set periods stored locally, it is judged whether the spin energy of all controllable probability units in the controllable probability device no longer changes; when it is determined that the spin energy has changed, the random selection according to the positions of multiple controllable probability units is re-executed The positions of the target number of controllable probability units and subsequent steps thereof; when it is determined that the spin energy no longer changes, in the locally stored M times N setting periods, according to the spin states of the controllable probability units in the controllable probability device in the Kth N setting periods, a spin state array is obtained; wherein, the spin energy of all controllable probability units in the controllable probability device in the Kth N setting periods is less than the spin energy of all controllable probability units in the controllable probability device in the M times N setting periods of other orders; M and K are positive integers, M is greater than 1, and K is less than or equal to M; the city visit order is obtained according to the spin state array.
[0114] On the other hand, the present invention also provides a computer-readable storage medium having a computer program stored thereon, which is implemented when the processor executes the method for solving the traveling salesman problem based on a controllable probability device provided by the above methods, wherein the controllable probability device includes a plurality of controllable probability units arranged in an array, and each of the plurality of controllable probability units flips with a corresponding probability according to the magnitude of the level signal when receiving a level signal; the method includes: obtaining a plurality of city sequences and a plurality of city coordinates of the traveling salesman problem; obtaining a QUBO matrix according to the plurality of city sequences and the plurality of city coordinates; obtaining an analog level value according to the QUBO matrix and the spin state of each controllable probability unit in the controllable probability device within the last N set cycles stored locally after the traveling salesman problem is solved; wherein the spin state includes: flipping or not flipping; N is a positive integer; randomly selecting the positions of a target number of target controllable probability units according to the positions of the plurality of controllable probability units; wherein the target number of target controllable probability units are not adjacent to each other, and the target number is the number of the plurality of city coordinates; according to the position of the target controllable probability unit, the analog level signal corresponding to the analog level value is input target controllable probability unit; cache the spin states of all controllable probability units in the controllable probability device at every set period, and store the cached spin states of all controllable probability units in the controllable probability device locally after caching N set periods; judge whether the spin energy of all controllable probability units in the controllable probability device no longer changes according to the spin states of all controllable probability units in the controllable probability device in the current N set periods and the last N set periods stored locally; if it is determined that the spin energy has changed, re-execute the target number of randomly selected units according to the positions of multiple controllable probability units Mark the position of the controllable probability unit and its subsequent steps; when it is determined that the spin energy no longer changes, in the locally stored M times N setting periods, according to the spin state of the controllable probability unit in the controllable probability device in the Kth N setting period, obtain a spin state array; wherein, the spin energy of all the controllable probability units in the controllable probability device in the Kth N setting period is less than the spin energy of all the controllable probability units in the controllable probability device in the M times N setting periods of other orders; M and K are positive integers, M is greater than 1, and K is less than or equal to M; obtain the city visit order according to the spin state array.
[0115] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, i.e., they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative effort.
[0116] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.
[0117] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for solving the traveling salesman problem based on a controllable probability device, characterized in that: The controllable probability device comprises a plurality of controllable probability units arranged in an array, and each of the plurality of controllable probability units flips with a corresponding probability according to the magnitude of the level signal when receiving a level signal; The method comprises: Get multiple city sequences and multiple city coordinates of the traveling salesman problem; Obtaining a QUBO matrix according to the plurality of city sequences and the plurality of city coordinates; According to the QUBO matrix and the spin state of each controllable probability unit in the controllable probability device within the last N set cycles stored locally after the start of solving the traveling salesman problem, an analog level value is obtained; wherein the spin state includes: flipping or not flipping; N is a positive integer; Randomly select the positions of a target number of target controllable probability units according to the positions of the multiple controllable probability units; wherein the target number of target controllable probability units are not adjacent to each other, and the target number is the number of multiple city coordinates; according to the positions of the target controllable probability units, input the analog level signal corresponding to the analog level value into the target controllable probability unit; Cache the spin states of all the controllable probability units in the controllable probability device at every set period, and store the cached spin states of all the controllable probability units in the controllable probability device locally after caching N set periods; According to the spin states of all the controllable probability units in the controllable probability device in the N setting periods of this time and the last N setting periods stored locally, determining whether the spin energy of all the controllable probability units in the controllable probability device no longer changes; In the case where it is determined that the spin energy has changed, re-execute the steps of randomly selecting the positions of the target number of controllable probability units according to the positions of the plurality of controllable probability units and subsequent steps; When it is determined that the spin energy no longer changes, in the locally stored M times N set periods, according to the spin states of the controllable probability units in the controllable probability device in the Kth N set periods, a spin state array is obtained; wherein the spin energy of all the controllable probability units in the controllable probability device in the Kth N set periods is less than the spin energy of all the controllable probability units in the controllable probability device in the M times N set periods of other orders; M and K are positive integers, M is greater than 1, and K is less than or equal to M; A city visiting sequence is obtained according to the spin state array.
2. The method for solving the traveling salesman problem based on a controllable probability device according to claim 1, characterized in that: The step of judging whether the spin energy of all the controllable probability units in the controllable probability device no longer changes according to the spin states of all the controllable probability units in the controllable probability device in the N setting periods of the current N setting periods and the last N setting periods stored locally includes: Calculating a first spin energy according to the spin state of each of the controllable probability units within the N set periods; Calculating a second spin energy according to the spin state of each of the controllable probability units in the last N set periods; When the first spin energy is equal to the second spin energy, it is determined that the spin energy does not change any more; and when the first spin energy is not equal to the second spin energy, it is determined that the spin energy changes.
3. The method for solving the traveling salesman problem based on a controllable probability device according to claim 1, characterized in that: N is greater than or equal to 16.
4. A traveling salesman problem solving device based on a controllable probability device, characterized in that: The controllable probability device comprises a plurality of controllable probability units arranged in an array, and each of the plurality of controllable probability units flips with a corresponding probability according to the magnitude of the level signal when receiving the level signal; The device comprises: An acquisition module is used to obtain multiple city sequences and multiple city coordinates of the traveling salesman problem; A QUBO matrix calculation module is used to obtain a QUBO matrix according to the plurality of city sequences and the plurality of city coordinates; a level value calculation module is used to obtain a simulation level value according to the QUBO matrix and the spin state of each controllable probability unit in the controllable probability device within the last N set cycles stored locally after the start of solving the traveling salesman problem; wherein the spin state includes: flipping or not flipping; N is a positive integer; A selection module is used to randomly select the positions of a target number of target controllable probability units according to the positions of the multiple controllable probability units; wherein the target number of target controllable probability units are not adjacent to each other, and the target number is the number of multiple city coordinates; A level input module, used for inputting the analog level signal corresponding to the analog level value into the target controllable probability unit according to the position of the target controllable probability unit; A cache module, used for caching the spin states of all the controllable probability units in the controllable probability device at every set period, and storing the cached spin states of all the controllable probability units in the controllable probability device locally after caching N set periods; A storage module, used for storing the spin states of each controllable probability unit in the controllable probability device within N set periods from the cache module; A judgment module, used to judge whether the spin energy of all the controllable probability units in the controllable probability device no longer changes according to the spin states of all the controllable probability units in the controllable probability device in the current N setting periods and the last N setting periods stored locally; A processing module, configured to, when it is determined that the spin energy has changed, return to the selection module to execute the functions of randomly selecting the positions of the target controllable probability units of the target number according to the positions of the multiple controllable probability units and each module in the subsequent modules; The processing module is further used to obtain a spin state array according to the spin states of the controllable probability units in the controllable probability device in the Kth N setting periods in a total of M times N setting periods stored locally, when it is determined that the spin energy no longer changes; wherein the spin energy of all the controllable probability units in the controllable probability device in the Kth N setting periods is less than the spin energy of all the controllable probability units in the controllable probability device in the Mth N setting periods of other orders; M and K are positive integers, M is greater than 1, and K is less than or equal to M; A solution module is used to obtain a city visit sequence according to the spin state array.
5. A traveling salesman problem solving device, characterized in that: include: A controllable probability device, and a traveling salesman problem solving device based on a controllable probability device as claimed in claim 4; The controllable probability device comprises: a plurality of controllable probability units arranged in an array, each of the plurality of controllable probability units flips with a corresponding probability according to the size of the level signal when receiving a level signal.
6. The traveling salesman problem solving device according to claim 5, characterized in that: The controllable probability unit includes: a resistor, a transistor, a magnetic tunnel junction, a positive voltage power supply terminal, a negative voltage power supply terminal, a comparator and a reference voltage terminal; One end of the resistor is connected to the positive voltage supply end, and the other end of the resistor is connected to the collector of the transistor; The top electrode of the magnetic tunnel junction is connected to the emitter of the transistor, and the bottom electrode of the magnetic tunnel junction is connected to the negative voltage supply terminal; The first input terminal of the comparator is connected to the collector of the transistor, and the second input terminal of the comparator is connected to the reference voltage terminal; The base of the transistor is the input end of the controllable probability unit, and the output end of the comparator is the output end of the controllable probability unit.
7. The traveling salesman problem solving device according to claim 5, characterized in that: Among the multiple controllable probability units arranged in the array, the number of the controllable probability units in each row and the number of the controllable probability units in each column are both n, where n is a positive integer and n is greater than or equal to 2.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the method for solving the traveling salesman problem based on a controllable probability device as described in any one of claims 1 to 3 is implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for solving the traveling salesman problem based on a controllable probability device as described in any one of claims 1 to 3 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method for solving the traveling salesman problem based on a controllable probability device as described in any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Problem solving optimization method and system based on probability bit circuit
CN113553028A
Traveling salesman optimal path determination method based on mixed meta-heuristic algorithm
CN114611755A
Multi-target traveling salesman problem solving method and system, storage medium and computer
CN116681190A
Travel salesman problem optimization method with access priority constraint
CN117649035A
