An improved LKH algorithm-based FDM printing path optimization method
By improving the LKH algorithm to optimize the FDM printing path, the problems of long nozzle travel distance and discontinuous fiber placement in carbon fiber composite materials were solved, achieving a synergistic improvement in printing efficiency and component strength.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA JILIANG UNIV
- Filing Date
- 2026-04-14
- Publication Date
- 2026-07-10
AI Technical Summary
In existing FDM printing technology, the optimization of the nozzle movement path for carbon fiber composite materials suffers from problems such as long idle travel distance, low printing efficiency, and discontinuous fiber placement, resulting in insufficient strength of the printed parts.
An improved LKH algorithm is adopted to optimize the nozzle path sequence by calculating the generalized distance and transfer cost of the path segment, ensuring the continuity of fiber deposition, and optimizing the direction of the path segment and the transfer between regions under process constraints to generate a continuous printing path.
It significantly shortens the nozzle travel distance, reduces the number of times the equipment starts and stops, improves printing efficiency, and enhances the forming strength of components.
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] This invention relates to the field of 3D printing path planning and optimization technology, specifically to an FDM printing path optimization method based on an improved LKH algorithm. Background Technology
[0002] Fused deposition modeling (FDM) 3D printing technology constructs three-dimensional solids by extruding and curing material layer by layer, and is currently widely used in the manufacturing of carbon fiber reinforced composite materials. In the actual printing process, the nozzle's movement path consists of an extrusion path for performing deposition tasks and a no-run path for performing non-extrusion transitions. For carbon fiber composites, the nozzle's movement sequence not only directly determines the length of the no-run distance but also relates to the physical continuity of fiber deposition, making it a core factor affecting printing efficiency and component performance.
[0003] Most existing path optimization methods abstract the problem into the traditional Traveling Salesman Problem, using the shortest geometric distance as the optimization objective to improve printing efficiency. However, in multi-region infilling tasks, solely pursuing optimal distance leads to frequent jumps in the printing path between different regions, significantly increasing the number of fiber cuts and causing discontinuities in the layup path. This results in a substantial reduction in the overall strength of the printed part, making it difficult to leverage the structural advantages of composite materials. Therefore, achieving synergistic optimization of printing efficiency and component strength through process constraints—while significantly reducing idle travel distance and shortening printing time—is of great significance for FDM printing of carbon fiber composites. Summary of the Invention
[0004] The purpose of this invention is to propose an FDM printing path optimization method based on an improved LKH algorithm to solve problems such as long idle travel distance, low printing efficiency, and discontinuous fiber placement in critical areas in existing FDM printing methods. This invention is achieved through the following technical solution:
[0005] S1. Obtain pre-generated slice fill path data, including the set of all path segments to be printed within a single slice. Each path segment includes the starting coordinates, the ending coordinates, and the region attributes to which it belongs.
[0006] S2, for any two path segments and Extract its starting and ending points respectively. Endpoint Specifically, path segment The endpoint set is Path segment The endpoint set is Calculate the Euclidean distance for the four endpoint combinations, and take the minimum value as the generalized distance between them. The formula is: The Euclidean distance calculation formula is as follows: .
[0007] S3. Traverse all path segment combinations to generate Symmetric generalized distance matrix ,in This represents the total number of path segments within a single-layer slice.
[0008] S4, Define all permutations The executable order of the path segments. Indicates the first The visited path segment numbers are used to optimize the total nozzle relocation cost, as shown in the formula:
[0009] S5. Specified process constraints: (1) Follow the execution order of "contour area, high stress area, low stress area"; (2) Use open-loop printing, and the printhead does not need to return to the starting position after completing the printing of the last path segment.
[0010] S6. Based on the region identifier of the path segment, divide the path set into three independent optimization units: contour region, high stress region, and low stress region. The path segments in each unit are optimized sequentially.
[0011] S7. Based on the generalized distance matrix D in S3, extract the submatrix corresponding to each region optimization unit and input it into the LKH algorithm.
[0012] S8. Obtain the closed-loop access sequence of path segments within each region through iterative calculation. ,in For the region The total number of path segments within.
[0013] S9. Calculate the transfer cost of adjacent path segments in the closed-loop access sequence of each region, locate and cut the connection edge with the highest cost, and convert the closed-loop sequence into an open-loop access sequence within the region that conforms to the FDM open-loop printing characteristics.
[0014] S10, Define path segment Directional state , This indicates printing in the original orientation. This indicates reverse printing; the execution direction of each path segment is optimized with the goal of minimizing the actual transfer distance between adjacent path segments, using the following formula:
[0015] S11. Determine the entry endpoint for each region based on the optimized access order and execution direction. and export endpoint Each region is abstracted into a continuous printing cell with in and out endpoints.
[0016] S12. Abstract the continuous printing cells of a region into region supernodes, and calculate the transfer cost (Euclidean distance from the exit endpoint of the previous region to the entrance endpoint of the next region) between any two region supernodes. The formula is as follows:
[0017] S13. Traverse all region combinations and construct the region-level cost matrix: .
[0018] S14. The objective is to minimize the cumulative transfer cost between regions: .in For the total number of regions, This determines the order in which regions are accessed.
[0019] S15. Under the premise of following the process timing constraints described in S5, solve for the optimal access order between regions. .
[0020] S16. According to the optimal access order between regions, the optimized path sequence in each region is seamlessly spliced with the inter-region transfer path to form a global optimized printing path for the entire layer.
[0021] S17. Generate a Gcode file that can be printed from the optimized path data using an algorithm. Attached Figure Description
[0022] Figure 1 This is a flowchart of the present invention;
[0023] Figure 2 This is a schematic diagram of the printing process timing of the present invention;
[0024] Figure 3 This is a schematic diagram comparing the open-loop correction before and after within the region of this invention;
[0025] Figure 4 This is a schematic diagram illustrating path direction optimization within the region of this invention;
[0026] Figure 5 This is a dimensional schematic diagram of an embodiment of the present invention;
[0027] Figure 6 This is a comparison chart of the idle walk ratio of various algorithms under different densities in an embodiment of the present invention;
[0028] Figure 7 This is a comparison chart of the idle travel distances of various algorithms under different densities in this embodiment of the invention; Detailed Implementation
[0029] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0030] Please see Figure 1 This embodiment provides an FDM printing path optimization method based on an improved LKH algorithm. To verify the effectiveness of this method, this embodiment selects a cross-shaped perforated plate as the printing research object (its specific dimensions are shown in [reference]). Figure 5 The component is 2mm thick and was printed using a Tuozhu X1C printer with a nozzle diameter of 0.4mm, a layer thickness of 0.2mm, and a fill density of 100%. The printing material used is carbon fiber reinforced nylon (PA6-CF).
[0031] The detailed steps of the method described in this invention are as follows:
[0032] Import the original fill data file and extract the set of all line segments to be printed within a single layer slice. Divide the line segments to be printed into contour regions, high-stress regions, and low-stress regions. As shown in Figure 2, this embodiment strictly follows the process timing constraints described above for path optimization.
[0033] For any line segment to be printed, calculate the Euclidean distance between its four endpoints and take the minimum value as the generalized distance between them. Traverse all line segment combinations to generate a symmetric generalized distance matrix, which serves as the cost basis for subsequent LKH iterations.
[0034] The shortest closed-loop access sequence in each region is obtained through iterative calculation, and then open-loop correction is performed.
[0035] With the goal of minimizing the actual transfer cost between adjacent line segments, the printing direction of each line segment is determined, thereby transforming the discrete path set into a continuous printing unit.
[0036] The optimized continuous printing units described above are abstracted as region supernodes. The transfer cost between the exit endpoint of each region and the entry endpoint of the next region is calculated, and a region-level cost matrix is constructed. Under process timing constraints, the optimal access order between regions is solved, and the local sequences are globally concatenated to finally generate an optimized Gcode printing file.
[0037] To verify the optimization performance of the method of this invention, the improved LKH algorithm of this invention was compared with the original printing order, genetic algorithm (GA), particle swarm optimization algorithm (PSO), and simulated annealing algorithm (SA). All methods were executed under the same process constraints. The evaluation indicators were the length of the entire layer of idle space, the proportion of idle space, and the computation time of the algorithm. The results are shown in the table below: algorithm Idle walking length (mm) percentage of empty walks (%) Time elapsed (s) Original order 1770 19.53 0.0106 Improved LKH 283.2 3.74 0.3248 GA 808.04 9.98 1.0225 PSO 968.8 11.73 0.4108 SA 904.44 11.04 0.1717
[0038] As can be seen from the table above, under the premise of meeting the process timing constraints, the idle travel length of the method of the present invention is reduced by 83.99% compared with the original sequence, the idle travel ratio is significantly reduced, and the optimization effect is significantly better than the traditional algorithm. It can effectively reduce the idle travel of the printhead and improve printing efficiency.
[0039] Combination Figure 6 and Figure 7 As can be seen from the comparative data, the method of the present invention achieved good results under different filling densities.
[0040] The advantages and beneficial effects of this invention are as follows: by improving the LKH algorithm, the nozzle travel distance is significantly shortened, reducing the number of equipment start-ups and shutdowns; at the same time, by strengthening the continuous laying of carbon fiber composite materials in high-stress areas, the forming strength of the components is greatly improved while increasing printing efficiency.
[0041] Those skilled in the art will recognize that the embodiments described herein are intended to help the reader understand the principles of the invention, and should be understood that the scope of protection of the invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific modifications and combinations based on the technical teachings disclosed in this invention without departing from the spirit of the invention, and these modifications and combinations are still within the scope of protection of this invention.
Claims
1. A method for optimizing FDM printing paths based on an improved LKH algorithm, characterized in that, The method includes the following steps: S1. Obtain the path data to be printed: including the coordinate information of all path segments within a single layer slice and the attributes of the region to which they belong (contour area, high stress area, low stress area). S2. Construct the generalized distance matrix: Calculate the Euclidean distance between the endpoints of the path segments and take the minimum value as the generalized distance. And generate a symmetric cost matrix. S3. Local path optimization within the region: The LKH algorithm is used to generate the optimal access sequence in each region and open-loop correction is performed to convert the closed loop into an open-loop path. S4. Adaptive decision-making for path execution direction: With the goal of minimizing the actual jump distance between adjacent path segments, optimize the printing direction of each path segment to form continuous printing units. S5. Global Scheduling and Assembly Between Regions: Under process timing constraints, solve for the optimal access order of regional supernodes, assemble them to generate a globally optimized path, and export the Gcode file.
2. The method according to claim 1, characterized in that, The generalized distance mentioned in step S2 The calculation formula is: . The Euclidean distance calculation formula is as follows: .
3. The method according to claim 1, characterized in that, The open-loop correction in step S3 includes: calculating the transition cost between adjacent path segments in the closed-loop access sequence, and searching for and removing the connection edge with the highest cost.
4. The method according to claim 1, characterized in that, In step S4, a direction state variable is introduced. .when When the path segment is printed, it maintains its original direction; when When the path segment is reversed, it is printed in reverse.
5. The method according to claim 1, characterized in that, The process timing constraints in step S5 specify the printing order as follows: outline area High stress area Low-stress areas are used to ensure the continuity of carbon fiber composite material placement in critical stress areas.
6. The method according to claim 1, characterized in that, The inter-region transfer cost in step S5 is: .