PCB two-way routing method, medium, and device based on ant colony bidirectional search
By optimizing the PCB routing algorithm through bidirectional ant colony search and multi-threading technology, the low efficiency and risk of getting trapped in local optima in large-scale routing problems are solved, resulting in shorter routing paths and higher routing efficiency.
Patent Information
- Application Number
- CN202411538024.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2044-10-31
AI Technical Summary
Existing PCB routing algorithms are inefficient for large-scale routing problems, are prone to getting trapped in local optima, and have high routing time and complexity, making it difficult to meet the design requirements of modern electronics and integration.
A bidirectional ant colony search-based approach is adopted, which divides the ant colony into two groups with different directions and processes them in parallel. By combining multi-threading technology and an optimized probabilistic selection formula, and utilizing a target point guiding function and an adaptive pheromone factor, local optima are avoided and global search capabilities are improved.
It significantly reduces routing time, decreases the number of inflection points and routing length, improves routing efficiency and quality, and meets the needs of large-scale PCB design.
Smart Images

Figure CN119443035B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of printed circuit board (PCB) design technology, specifically relating to a PCB end wiring method, medium, and device, which can be used for integrated circuit design. Background Technology
[0002] PCB design is a crucial part of the integrated circuit industry. Modern engineering technology is constantly evolving towards electronification, integration, and systematization, which places increasingly higher demands on PCB design. In PCB design, routing is usually the final step, and the routing result often determines the final quality of the circuit board. Therefore, the PCB design process must adhere to PCB design principles and meet the requirements of circuit immunity design to achieve optimal circuit performance. However, the difficulty of PCB design increases exponentially with the scale of the circuit, and the number of factors that need to be considered also increases. For example, limitations of routing obstacle areas, the number of vias, routing length, and line bends all affect circuit performance.
[0003] Traditional PCB routing primarily relies on manual routing, which is time-consuming, labor-intensive, and prone to errors. Modern PCBs are characterized by a large number of electronic components, high density, and numerous ports, further reducing the efficiency of manual routing. While some existing automatic routing algorithms can provide routing results to a certain extent, they may get stuck in local optima, and their routing speed decreases significantly with the size of the PCB, resulting in low routing efficiency.
[0004] Patent document CN110220525A discloses a path planning method based on the potential field ant colony algorithm. Addressing the blindness problem in the early search phase of the ant colony algorithm, it introduces an artificial potential field method. This guides the ants' search from the outset by using the target point, maintaining its attractiveness throughout the optimization process. The method uses the artificial potential field to calculate the distance from the next feasible node to the destination, constructing heuristic information. While this method reduces the "blindness" of the ant colony's early search to some extent, as the problem size increases and the number of obstacles on the path increases, this method of improving heuristic information by introducing an artificial potential field still carries the risk of the ant colony getting stuck in local optima or even stalling during the search process.
[0005] Patent document CN116702694B discloses a method, medium, and apparatus for routing at both ends of a printed circuit board based on an ant colony algorithm. The basic idea is as follows: the printed circuit board is topologically mapped into a mesh. Ants are placed on one pin of the routing at both ends of the board, and the nearest points that the ant can choose from at its current position are determined. The probability of each nearest point being selected is calculated using a probability formula. These steps are repeated until the ant reaches the other pin of the routing at both ends. Compared to traditional ant colony search algorithms, this invention uses a method of dynamically changing the ant's search step size, which can provide shorter paths and faster search speeds for small-scale PCB routing problems. However, this method still uses a unidirectional serial search method, i.e., the ant searches from one pin to the other. As the scale of the PCB routing increases, the routing complexity also increases, significantly increasing the routing time. Furthermore, dynamically changing the ant's search step size increases the number of inflection points in the routing, which cannot meet practical requirements. Summary of the Invention
[0006] The purpose of this invention is to address the shortcomings of the prior art by providing a PCB end-to-end routing method, medium, and device based on ant colony bidirectional search, so as to reduce the length of the routing and the number of inflection points, and improve routing efficiency.
[0007] To achieve the above objectives, the technical solution of the present invention includes the following:
[0008] 1. A PCB end-to-end routing method based on ant colony bidirectional search, characterized by comprising the following steps:
[0009] S1) Convert a completed PCB design into a mesh diagram;
[0010] S2) Determine the positions of the circuit pins that need to be wired at both ends on the mesh diagram and initialize the ant colony algorithm parameters;
[0011] S3) Based on the endpoint selection theory, determine the common target point that the ant colony needs to reach during the bidirectional search process:
[0012] If no electronic component is placed at the midpoint of the connection between the two pins connected by the wiring at both ends, then the midpoint is regarded as the common target point of the ant colony during the bidirectional search process.
[0013] If an electronic component is placed at the midpoint of the connection between two pins connected by wiring, the coordinates of the non-electronic component that is closest to the midpoint and located on the connection between the two pins are found and regarded as the common target point of the ant colony in the bidirectional search process.
[0014] S4) Divide the ant colony into two populations with different search directions, and have the ants in each population search towards a common target point:
[0015] S4a) Divide the initial ant colony into two populations with the same number of ants but different search directions;
[0016] S4b) Using multithreading technology, two threads are set up to process the ant colony's search for the wiring path in parallel. The two threads handle the search tasks of the two populations respectively, that is, the ants start from the two pins at both ends of the wiring simultaneously to search for the common target point.
[0017] S5) Determine the neighboring points of the ants during the search process on the grid diagram, calculate the probability of each neighboring point being selected according to the optimized probability selection formula, and then determine the next neighboring point for the ant colony to move to.
[0018] S6) Repeat step S5 until all ants in both populations reach the common target point. Then, taking into account the wiring length, number of vias, and number of inflection points obtained from the ant colony search, select the optimal wiring path.
[0019] 2. A PCB end-to-end routing medium based on ant colony bidirectional search, storing a computer program, characterized in that the computer program, when executed by a processor, implements the PCB end-to-end routing method based on ant colony bidirectional search.
[0020] 3. A PCB end-to-end wiring device based on bidirectional ant colony search, characterized in that it includes a processor and a memory;
[0021] The memory is used to store program instructions;
[0022] The processor is used to run program instructions to execute a PCB end-to-end routing method based on bidirectional ant colony search.
[0023] Compared with the prior art, the present invention has the following advantages:
[0024] Firstly, this invention employs a mesh routing method, which simplifies the design process and greatly reduces routing complexity compared to meshless routing. Mesh routing discretizes the design space, reducing the number of possible paths to consider and further improving the routing efficiency of the mesh.
[0025] Secondly, because this invention uses thread pool technology, it can realize bidirectional parallel search of PCB routing paths by ant colonies. Compared with the existing traditional ant colony algorithm that uses a unidirectional serial search method, it can significantly reduce the search space of ants, thereby reducing PCB routing time and improving routing efficiency.
[0026] Thirdly, by incorporating a target point guiding function into the state transition probability formula, this invention ensures that the ant colony always has a high probability of moving toward the target point during the search process, effectively avoiding the risk of the ant colony getting trapped in local optima. At the same time, due to the guiding role of the target point, the ant colony can avoid unnecessary searches, thereby reducing the wiring length and the number of inflection points in the wiring.
[0027] Fourth, because this invention uses an adaptive method to change the pheromone factor and the heuristic factor, the heuristic function has a higher weight in the early stage of ant colony search, which can prevent the ant colony from blindly searching; in the later stage of ant colony search, the guiding role of pheromone on the ant search path is improved, which is conducive to the ant colony to perform global search and thus obtain the global optimal solution. Attached Figure Description
[0028] Figure 1 This is a flowchart illustrating the implementation of the present invention;
[0029] Figure 2 This is an example diagram of searching for common target points in this invention.
[0030] Figure 3 The diagram shows the wiring results at both ends of the PCB obtained using existing methods and the method of this invention. Detailed Implementation
[0031] To enable those skilled in the art to better understand the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings.
[0032] Reference Figure 1 The implementation steps for this example are as follows:
[0033] Step 1: Construct the PCB routing mesh diagram.
[0034] 1.1) Based on the size of the PCB board, the location, quantity and size of the electronic components on the board, and the circuit pins that need to be wired, a two-dimensional wiring grid diagram is constructed using the grid method.
[0035] 1.2) With the top left corner of the grid diagram as the origin, the positive X-axis is horizontal to the right and the positive Y-axis is vertical downward. In the grid diagram, white grids represent the locations where wiring is allowed, and black grids represent electronic components on the PCB board, i.e., the locations where wiring is not allowed.
[0036] 1.3) Each grid cell has a unique index and its corresponding coordinates. Assume the coordinates obtained from the wiring are (x... i ,y i If ), then the corresponding index on the grid diagram is:
[0037] N = y i ×Ngrid +x i
[0038] Where N is the index on the corresponding grid diagram, N grid The size of the grid diagram;
[0039] 1.4) Determine the locations of the circuit pins that require two-way wiring and mark them on the grid diagram.
[0040] Step 2, search for common target points.
[0041] Reference Figure 2 The specific implementation of this step includes the following:
[0042] 2.1) Connect the two pins of the wiring at both ends, and find the grid where the midpoint of the connection is located, such as... Figure 2 As shown in (a);
[0043] 2.2) Find the common target point based on the midpoint position described in step 2.1):
[0044] If no electronic components are placed at the midpoint of the line, then the midpoint is considered the common target point of the ant colony during the bidirectional search process.
[0045] If electronic components are placed at the midpoint of the connection, such as Figure 2 As shown in (b), the coordinates of the non-electronic component that is closest to the midpoint and located on the line connecting the two pins are found along the direction of the line and regarded as the common target point of the ant colony in the bidirectional search process.
[0046] 2.3) Repeat step 2.2), that is, from Figure 2 (c) Repeatedly search for common target points to Figure 2 (e) until a non-electronic component location coordinate is found, and this is regarded as the common target point of the ant colony in the bidirectional search process. The final wiring effect is as follows: Figure 2 As shown in (f).
[0047] Step 3: The ant colony searches for PCB routing paths in both directions in parallel.
[0048] 3.1) Divide the initial ant colony into two populations of equal size but with different search directions;
[0049] 3.2) Select a suitable multithreading library. The multithreading library may vary depending on the programming language. In this embodiment, the programming language used is not limited to Java, so the thread pool in java.util.concurrent that comes with Java is used.
[0050] 3.3) Iteratively search the wiring path and assign wiring tasks to each ant:
[0051] 3.3.1) Initialize the population size and the number of algorithm iterations. Set the population size to 100 and the maximum number of algorithm iterations to 100.
[0052] 3.3.2) At the initial moment, place the ants from the two populations at the positions of the two pins of the wiring at both ends;
[0053] 3.3.3) Ants from the two populations start from the positions of the two pins at both ends of the wiring and search for the wiring path towards the common target point;
[0054] 3.3.3) Once all ants in both populations have reached the common target point, the current iteration ends, and the next iteration search continues;
[0055] 3.3.4) After reaching the maximum number of iterations, terminate the iteration, record the wiring path obtained by the ant colony search, and calculate the wiring length, number of vias and number of inflection points.
[0056] 3.4) Based on the multithreading library selected in step 3.2), namely the thread pool in java.util.concurrent which comes with Java, use the ThreadPoolExecutor component in multithreading technology to set up two threads that can process the ant colony search wiring path in parallel, and submit these two threads to the thread pool for subsequent parallel processing of the search tasks of these two populations.
[0057] Step 4: Determine the nearest point the ant chooses to move to during the search process.
[0058] 4.1) Add the target point guiding function H to the existing probability selection formula. ij :
[0059]
[0060] Where H is a constant, taking a value between 2 and 4. L ij Let L be the Euclidean distance between the ant's current position i and its neighbor j. ik Let be the Euclidean distance between the ant's current position i and the target point k; the smaller the angle between the direction from the ant to the candidate neighboring point and the direction from the ant to the target, the better. The larger the value, the more the guiding function H... ij The greater the guiding role in the ant colony search process;
[0061] 4.2) Optimize the heuristic information in the probability selection formula to obtain the optimized heuristic information η. jk :
[0062]
[0063] in: λ represents the heuristic information η jk The coefficient of λ gradually decreases as the number of algorithm iterations increases, so it has high heuristic information in the early stage of ant colony search and can avoid the ant colony from performing too many useless searches.
[0064] d ij Let d be the Manhattan distance from ant's current position i to its neighboring point j. jk Let w1 and w2 be the Manhattan distances from neighboring point j to the destination k, respectively. ij and d jk The weighting coefficients, w1 and w2, are summed to 1. In this example, the values of w1 and w2 are set to 0.3 and 0.7 respectively.
[0065] n is the number of iterations the current ant is performing, N is the total number of iterations of the algorithm, and the value of N is set to 100;
[0066] 4.3) To avoid the blindness of the ant colony in the early search and to enhance the global search capability of the ant colony in the later search, the pheromone factor α and heuristic factor β are dynamically changed to optimize the pheromone factor α and heuristic factor β in the probability selection formula, resulting in the optimized pheromone factor α and heuristic factor β:
[0067]
[0068] Where α(0) is the initial value of the pheromone factor α, and β(0) is the initial value of the heuristic factor β. In this example, α(0) is set to [1,4] and β(0) is set to [0,5].
[0069] 4.4) Substitute the optimization results from steps 4.1) to 4.3) into the existing probability selection formula to obtain the final optimized probability selection formula:
[0070]
[0071] Where: p ij Let τ be the probability that an ant, when at position i, chooses its neighbor j. ij The pheromone at neighboring point j is represented by next. dot(i) This represents the set of all neighboring points of an ant at position i.
[0072] 4.5) Calculate the probability of each neighboring point being selected using the final optimized probability selection formula obtained in step 4.4);
[0073] 4.6) The roulette wheel method is used to determine the nearest neighbor selected by the ant, that is, a random number q is selected and a fixed number q is defined.0, Compare the two:
[0074] If q > q0, directly select the neighboring point with the highest probability among all neighboring points as the next neighboring point for the ant to move to;
[0075] If q < q0, since the probability calculation formula ensures that the sum of the probabilities of all neighboring points is 1, divide the interval of length 1 according to the probability of each neighboring point, take a random number in the range (0, 1], and the ant chooses to move to the neighboring point where the random number falls.
[0076] Step 5, select the optimal wiring path.
[0077] 5.1) Design a multi-objective optimization function f(p):
[0078] f(p) = α l k l + β g k g + γ h k h
[0079] Where: k l is the total wiring length, k g is the number of inflection points, k h is the number of vias, α l is the weight coefficient of the total wiring length, β g is the weight coefficient of the number of inflection points, γ h is the weight coefficient of the number of vias;
[0080] 5.2) Use the multi-objective optimization function designed in step 5.2) to balance the performance indicators such as wiring length, number of vias, and number of inflection points, and obtain the best wiring effect at the lowest cost.
[0081] The specific implementation of the above method is completed by a computer program, which is stored in the PCB two-end wiring medium based on ant colony bidirectional search. The computer storage medium includes magnetic storage media, optical recording media, or memories. Among them, magnetic storage media include floppy disks and hard disks, optical recording media include CD-ROMs and DVDs, and memories include memory cards, ROMs, or RAMs. The computer storage medium can also be distributed on computer systems connected by a network, such as an application store. The computer program stored in the medium is used to complete any one of the 5 steps when executed by a processor.
[0082] The PCB two-end wiring device based on ant colony bidirectional search in this example includes a processor and a memory.
[0083] The memory is used to store program instructions, which are compiled from a computer program;
[0084] The processor is configured to run program instructions to perform any one of the steps in the above methods.
[0085] The effects of this invention can be further illustrated by the following simulation examples:
[0086] I. Simulation Experiment Conditions
[0087] The simulation experiment hardware requirements for this invention are an Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz and 16G of memory.
[0088] The experimental simulation platform of this invention is a Windows 10 operating system. The experimental verification is performed using Java. The development environment is IntelliJ IDEA 2021. The image drawing program is written in Python and the development environment is PyCharm 2022.
[0089] II. Simulation Experiment Content and Result Analysis
[0090] Simulation 1: Under the above conditions, using the method of this invention and the existing traditional ant colony algorithm, two-end routing is performed on a 100×100 PCB. The results are as follows. Figure 3 ,in Figure 3 (a) is a diagram of the wiring result obtained using the existing traditional ant colony algorithm. Figure 3 (b) is a diagram of the wiring result obtained using the method of the present invention.
[0091] contrast Figure 3 (a) and Figure 3 (b) It can be seen that the method of the present invention has a better routing effect in dealing with the routing problem at both ends of the PCB, and the PCB routing is more reasonable, which further proves the effectiveness of the present invention.
[0092] The total wiring length, time, number of inflection points, and number of vias obtained from the two methods described above are summarized in Table 1.
[0093] Table 1 compares the data of PCB end-to-end routing using the method of the present invention and existing methods.
[0094] Algorithm type Run 10 times in seconds Inflection point Number of vias Average total wiring length Traditional ant colony algorithm 86.912 25 8 569.88 Ant colony bidirectional search 55.279 21 6 559.79
[0095] As can be seen from Table 1, compared with the traditional ant colony algorithm, the present invention significantly reduces the routing time, number of inflection points, number of vias, and average total routing length at both ends of the PCB. The running time is reduced by 36.4% compared with the traditional ant colony algorithm, indicating that the present invention can significantly reduce PCB routing time and improve the routing efficiency at both ends of the PCB while ensuring the shortest total routing length.
[0096] The above description is merely a specific example of the present invention and does not constitute any limitation on the present invention. Obviously, those skilled in the art, after understanding the content and principle of the present invention, may make various modifications and changes in form and details without departing from the principle and structure of the present invention. However, these modifications and changes based on the concept of the present invention are still within the scope of protection of the claims of the present invention.
[0097] It should be noted that the step numbers in the specification and claims of this invention are only for the purpose of clearly describing the embodiments of this invention and facilitating understanding, and their order is not limited.
Claims
1. A PCB routing method based on bidirectional ant colony search, characterized in that, Includes the following steps: S1) Convert a completed PCB design into a mesh diagram; S2) Determine the positions of the circuit pins that need to be wired at both ends on the mesh diagram and initialize the ant colony algorithm parameters; S3) Based on the endpoint selection theory, determine the common target point that the ant colony needs to reach during the bidirectional search process: If no electronic component is placed at the midpoint of the connection between the two pins connected by the wiring at both ends, then the midpoint is regarded as the common target point of the ant colony during the bidirectional search process. If an electronic component is placed at the midpoint of the connection between two pins connected by wiring, the coordinates of the non-electronic component that is closest to the midpoint and located on the connection between the two pins are found and regarded as the common target point of the ant colony in the bidirectional search process. S4) Divide the ant colony into two populations with different search directions, and have the ants in each population search towards a common target point: S4a) Divide the initial ant colony into two populations with the same number of ants but different search directions; S4b) Using multithreading technology, two threads are set up to process the ant colony's search for the wiring path in parallel. The two threads handle the search tasks of the two populations respectively, that is, the ants start from the two pins at both ends of the wiring simultaneously to search for the common target point. S5) Determine the neighboring points of the ants during the search process on the grid diagram, calculate the probability of each neighboring point being selected according to the optimized probability selection formula, and then determine the next neighboring point for the ant colony to move to; the implementation steps include the following: 4a) Add a target point guiding function to the existing probability selection formula. : ; in, It is a constant. , Let be the Euclidean distance between the ant's current position i and its neighboring point j. Let i be the Euclidean distance between the ant's current position i and the target point k; 4b) Optimize the heuristic information in the probability selection formula to obtain the optimized heuristic information. : ; in: , Let i be the Manhattan distance from the ant's current position i to its neighboring point j. Let j be the Manhattan distance from the nearest point j to the destination k. and They are respectively and The weighting coefficients, and The sum of is 1, n is the number of iterations the current ant has performed, and N is the total number of iterations of the algorithm; 4c) Optimize the pheromone factor and heuristic factor in the probability selection formula to obtain the optimized pheromone factor α and heuristic factor β: ; ; in and It is a constant; 4d) Substitute the optimization results from steps 4a) to 4c) into the existing probabilistic selection formula to obtain the final optimized probabilistic selection formula: ; in: Let be the probability that an ant, when at position i, chooses its neighboring point j. This represents the pheromone at neighboring point j. Let i represent the set of all neighboring points when the ant is at position i. The probability of each neighboring point being selected by the ant is calculated based on the optimized probability selection formula. 4e) Using the final optimized probability selection formula obtained in step 4d), calculate the probability of each neighboring point being selected. Each ant uses the roulette wheel method to determine the next neighboring point to move from all the selected neighboring points. S6) Repeat step S5 until all ants in both populations have reached the common target point. Then, taking into account the wiring length, number of vias, and number of inflection points obtained from the ant colony search, select the optimal wiring path as follows: S6a) Design a multi-objective optimization function : ; in: This is the total length of the wiring. The number of inflection points. For the number of vias, The weighting factor is the total length of the cabling. The weighting coefficient for the number of inflection points. This is a weighting factor for the number of vias; S6b) Use the multi-objective optimization function designed in step S6a) to balance performance indicators such as routing length, number of vias and number of inflection points, so as to obtain the best routing effect at the lowest cost.
2. The method according to claim 1, characterized in that, Step S1) Convert a completed PCB design into a mesh diagram. The steps include the following: 2a) Based on the size of the PCB board, the location, quantity and size of the electronic components on the board, and the circuit pins that need to be wired, a two-dimensional wiring grid diagram is constructed using the grid method. 2b) With the top left corner of the grid diagram as the origin, the positive X-axis is horizontal to the right and the positive Y-axis is vertical downward. In the grid diagram, white grids represent the locations where wiring is allowed, and black grids represent electronic components on the PCB board, i.e., the locations where wiring is not allowed. 2c) Each grid has a unique index and its corresponding coordinates. Assume the coordinates obtained from the routing are... The corresponding index on the grid diagram is: ; Where N is the index on the corresponding grid diagram. This represents the size of the grid diagram.
3. The method according to claim 1, characterized in that, In step S4b), two threads are set up using multithreading technology to process the ant colony's search for wiring paths in parallel. The implementation steps include the following: S4b1) Select a multithreading library written in Java and use the thread pool in java.util.concurrent that comes with Java. S4b2) Iteratively search the wiring path and assign wiring tasks to each ant; S4b3) Use ThreadPoolExecutor to create two parallel threads, submit these two threads to the thread pool to run, and each thread is responsible for the ant's wiring path search task.
4. A PCB end-to-end wiring medium based on bidirectional ant colony search, storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the PCB two-end routing method based on ant colony bidirectional search as described in any one of claims 1-3.
5. A PCB end-to-end routing device based on bidirectional ant colony search, characterized in that, Including processor and memory; The memory is used to store program instructions; The processor is configured to run program instructions to execute the PCB two-end routing method based on ant colony bidirectional search as described in any one of claims 1-3.
Citation Information
Patent Citations
Route planning method based on potential field ant colony algorithm
CN110220525A
Printed circuit board wiring method, medium and device based on ant colony algorithm
CN116702694B
Parking path planning method and system based on improved ant colony algorithm
CN114721402A
UUV (Unmanned Underwater Vehicle) ant colony path planning method for bidirectional search under multiple obstacles
CN117109622A