Five-axis numerical control finish machining tool path approximation error calculation method based on Optuna optimized BiLSTM-TCRA neural network

By optimizing the BiLSTM-TCRA neural network using Optuna and combining the TCRA attention mechanism and hyperparameter optimization framework, the problem of low efficiency in approximation error calculation for five-axis CNC machining was solved, achieving efficient and accurate approximation error calculation.

CN121455052APending Publication Date: 2026-02-03SUZHOU UNIV OF SCI & TECH +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202511542721.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-27
Publication Date
2026-02-03

AI Technical Summary

Technical Problem

Existing technologies suffer from low computational efficiency and difficulty in reusing previous calculation results when calculating the approximation error of five-axis CNC machining. In particular, the time required to generate high-quality toolpaths increases significantly, making it impossible to achieve a balance between accuracy and efficiency.

Method used

We employ a BiLSTM-TCRA neural network based on Optuna optimization, combining the TCRA attention mechanism and the Optuna hyperparameter optimization framework to optimize feature extraction and hyperparameter selection. We also adjust the model weights through backpropagation and gradient descent to improve the efficiency and accuracy of approximation error calculation.

Benefits of technology

It significantly improves the calculation efficiency and accuracy of toolpath approximation error in five-axis CNC machining, reduces calculation time, and enhances the model's generalization ability and robustness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121455052A_ABST
    Figure CN121455052A_ABST
Patent Text Reader

Abstract

The invention discloses a five-axis numerical control finish machining tool path approximation error calculation method based on an Optuna optimization BiLSTM-TCRA (BiLSTM, Bidirectional Long Short Term Memory Network, a Bidirectional Long Short Term Memory Network, a Temporal-Channel Residual Attention, a Time-Channel Residual Attention mechanism) neural network, and relates to a tool path approximation error calculation method based on an Optuna optimization method of a BiLSTM-TCRA (BiLSTM, Bidirectional Long Short Term Memory Network, a Bidirectional Long Short Term Memory Network, a Time-Channel Residual Attention Mechanism) neural network and a tool path approximation error calculation method based on the BiLSTM-TCRA neural network. The method comprises the following steps: firstly, acquiring core parameters required by calculation of a neural network model, and mapping the parameters to the same scale by using mean variance normalization to eliminate the influence of dimensional difference between different features on the performance of the model; then, each hyper-parameter of the BiLSTM model is optimized by using an Optuna hyper-parameter optimization framework; a TCRA attention mechanism module is introduced to dynamically distribute different time step feature weights, so that the model can pay more attention to effective information which greatly influences an approximation error, the learning ability of the model is enhanced, and the training precision is improved; dropout mechanism sparsity is added to optimize a network structure, and part of neurons are randomly discarded in each iteration process, so that interference of non-core knife contacts on an approximation error value is reduced, and model overfitting is avoided; finally, the effectiveness of the method is verified in combination with actual curved surface model data, and efficient and accurate prediction of the five-axis machining approximation error is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the technical field of Computer Aided Manufacturing (CAM), and in particular to a method for solving approximation errors in five-axis precision machining. Background Technology

[0002] In CNC machining, approximation error refers to the deviation between the tool envelope and the tool contact point trajectory line formed during the cutting process as the tool moves from one tool position point to the next. In a three-axis machining environment, approximation error specifically manifests as chord length error (also known as bow height error), which is a linear error type. However, in five-axis machining, the composition of approximation error is more complex. In addition to linear errors, it also includes nonlinear errors. This nonlinear error arises from the fact that when the rotary axis is linked with other axes, the spatial trajectory formed by the linear interpolation motion of each axis deviates from the original programmed trajectory.

[0003] The common method for calculating five-axis approximation error currently involves selecting discrete points on the tool contact trajectory and iteratively calculating the distances from these points to the tool contact point or the line connecting the tool contact points. The maximum distance is then used as the approximation error. This iterative calculation method, which relies on geometric data, has significant drawbacks: previous data cannot be reused for each approximation error calculation, making it difficult to balance accuracy and efficiency. This is especially problematic when generating high-quality toolpaths with maximized step size and uniform error, requiring substantial computational resources and significantly increasing processing time, becoming a core bottleneck limiting the practical application of high-quality toolpaths. Therefore, improving the computational efficiency of approximation error while maintaining computational accuracy is of significant practical importance.

[0004] Chinese invention patent (application number: ZL202110004876.3) discloses a method for generating constant-error toolpaths in five-axis machining with a flat-end tool. This method first calculates the tool position point and tool axis vector in five-axis machining based on the tool contact point on the tool contact trajectory line, and then calculates the approximation error of the five-axis machining. Subsequently, by adjusting the step size to meet the constant-error requirements, the constant-error toolpath for five-axis machining of the flat-end tool is finally generated. This patent, for five-axis machining with a flat-end tool, calculates the maximum deviation between the envelope surface formed by the five-axis linkage of the flat-end tool and the curved surface, which is affected by both the nonlinear error generated by the rotation axis linkage and the linear error generated by the XYZ axis linkage.

[0005] The paper "A Method for Generating Toolpaths in Five-Axis Variable Step-Length CNC Machining of Freeform Surfaces" (published in the journal *Modern Manufacturing Engineering*, Vol. 2, pp. 76-80, 2021) proposes a method for generating toolpaths in five-axis variable step-length CNC machining of freeform surfaces. This method, based on meeting the approximation error requirements, calculates the approximation error using an adaptive discretization method. By iteratively increasing or decreasing the tool contact point step size through parameter iteration, the error is kept within an ideal range, ultimately maximizing the step size and minimizing redundant toolpaths.

[0006] The paper "Adaptive Five-Axis CNC Machining Toolpath Generation Method for Freeform Surfaces" (published in *Modern Manufacturing Engineering*, Vol. 5, pp. 61-67, 2022) proposes a toolpath generation method for five-axis CNC machining of freeform surfaces. This method optimizes the row spacing using the equal residual height method to reduce the total number of toolpath rows and the total length, and utilizes ellipses to simulate the cutting profile of the tool. By iteratively calculating the equal residual height points and adjusting the position of the cutting profile, a toolpath that meets the residual height requirements is finally generated, achieving adaptive row spacing planning with minimal parameter differences.

[0007] The paper "Generation of CNC Machining Toolpaths Based on Equal Error Step Size Method of Real Approximation Error" (published in the journal "Modular Machine Tools & Automated Machining Technology", Issue 6, pp. 22-26, June 2023) proposes an equal error step size method to optimize the approximation error of CNC machining toolpaths. This method utilizes real approximation error calculation and an efficient iterative algorithm to drive iterative adjustment of the step size, achieving theoretical maximization of the step size, reducing redundant tool positions, and improving the accuracy and efficiency of toolpath generation.

[0008] The paper "Calculation of Step Error in CNC Machining Based on Hybrid Particle Swarm Optimization" (published in the journal *Modular Machine Tools & Automated Manufacturing Technology*, June 2024, Vol. 133, pp. 3151-3162) proposes a hybrid particle swarm optimization (HPSO) method combining genetic algorithm and simulated annealing algorithm for calculating step error in CNC machining. This method optimizes the initialization process of the particle swarm (using Tent mapping for chaotic initialization), the nonlinear control of inertia weights and learning factors (based on the Sigmoid function and the number of iterations), and introduces a crossover mutation strategy and Metropolis criterion to enhance particle diversity and global search capability. Simultaneously, it utilizes an improved particle swarm optimization (IPSO) algorithm to improve the convergence speed of elite particles. This method improves the computational efficiency of step error, significantly reducing toolpath generation time compared to geometric iteration algorithms and standard particle swarm optimization algorithms, thus verifying its feasibility and effectiveness.

[0009] The algorithms proposed in the aforementioned papers and patents are all based on iterative calculation methods to calculate approximation errors in CNC machining. These methods rely on explicit mathematical expressions, and the computation time increases with the increase in accuracy requirements, while also being affected by CPU performance. Furthermore, the calculation process for each surface is independent, making it impossible to share "experience" using past calculation results. Therefore, when generating a large number of high-quality toolpaths for approximation error calculations (e.g., equal-error toolpaths with maximized step size), the overall computational time cost increases significantly.

[0010] The calculation of approximation error is essentially a process of solving for the unknown (approximation error) using known input data (such as tool radius, tool contact trajectory, etc.). There is a complex functional correspondence between the known input data and the unknown approximation error. If we can fully reuse the "computational experience" accumulated in the past approximation error calculation process to solve and adapt this functional relationship, it may improve the efficiency of subsequent approximation error calculation.

[0011] By utilizing a bidirectional long short-term memory neural network combined with the TCRA attention mechanism module to optimize feature extraction, the model can more accurately focus on important time steps and filtered feature parts in the data. Considering the significant differences in parameters between different surfaces, the Optuna hyperparameter optimization framework is added to adaptively adapt to the optimal hyperparameter combination required for each freeform surface, which greatly improves the model's generalization ability and prediction efficiency. Therefore, applying the bidirectional long short-term memory neural network combining the Optuna hyperparameter optimization framework and the TCRA attention mechanism module to the calculation of approximation error has strong practical significance.

[0012] The background section is provided only to enhance the overall understanding of the invention and should not be considered as prior art known to those skilled in the art. Summary of the Invention

[0013] The purpose of this invention is to provide a method for calculating the approximation error of a five-axis CNC finishing toolpath based on an Optuna-optimized BiLSTM-TCRA neural network, which can efficiently calculate the approximation error of a five-axis CNC machining toolpath.

[0014] To achieve the above objectives, embodiments of the present invention provide a method for calculating the approximation error of a five-axis CNC finishing toolpath based on an Optuna-optimized BiLSTM-TCRA neural network, characterized by comprising the following steps:

[0015] Step 1: Import the surface model and plan the toolpath with equal parameters;

[0016] Step 2: Data preparation and preprocessing;

[0017] Step 3: Establish a neural network model;

[0018] Step 4: Optimize the neural network framework;

[0019] Step 5: Calculate the approximation error value;

[0020] In one or more embodiments of the present invention, step 2, the data preparation and preprocessing process includes:

[0021] Step 2.1 Select the core parameters for approximation error calculation from Step 1. Each sample includes the following parameters: coordinates of the point set on the tool contact curve. Adjacent knife sites , Adjacent cutter shaft cutter positions , Tool radius R, tool length L, tool tip radius r, tool rake angle α, theoretical approximation error Approximation error theoretical value Approximation error calculation value ;

[0022] Step 2.2 Map the data to the same scale using mean-variance normalization;

[0023] Step 2.3 To verify the model's fitting accuracy, the dataset needs to be divided into a training set and a test set. The training set is used to train the samples, and the test set is used to verify the model's accuracy and generalization ability.

[0024] In one or more embodiments of the present invention, step 3, the process of establishing a neural network, includes:

[0025] Step 3.1 Set the parameters required to create a neural network: Number of neurons in the hidden layer Number of hidden layers Number of iterations Batch size Model learning rate Initial weights of neurons Neuron initial bias ReLU (Rectified Linear Unit) activation function, Adam optimizer, time sliding window, time step Introducing Dropout sparse technology;

[0026] Step 3.2 Establish a BiLSTM neural network model using the above parameters.

[0027] In one or more embodiments of the present invention, step 4, optimizing the neural network framework, includes:

[0028] Step 4.1 Configure the TPESampler sampler and the number of trials for the Optuna optimization algorithm framework. Pruning strategies The hyperparameter optimization range is set by introducing a TCRA attention mechanism module between the hidden layer of the bidirectional long short-term network and the output fully connected layer, and by setting regularization processing between the two hidden layers.

[0029] Step 4.2 Through the above optimization layer settings, establish an optimization framework for the BiLSTM-TCRA neural network based on Optuna optimization.

[0030] In one or more embodiments of the present invention, step 5, the process of calculating the approximation error value, includes:

[0031] Step 5.1 Import the normalized parameters into the input layer of the network, store the theoretical values ​​in the output layer, and start the model to propagate forward.

[0032] Step 5.2 During forward propagation, the data from the input layer is passed to the hidden layer. Each neuron in the hidden layer performs a weighted sum of the input, which is then passed to the output layer after a nonlinear transformation.

[0033] Step 5.3 Use Indicates theoretical value Compared with calculated values The degree of fit between the two is determined using the MSE loss function to judge the theoretical value. Compared with calculated values The magnitude of the error;

[0034] Step 5.4 If the error is large, it is necessary to backpropagate the error, use the TCRA attention mechanism module to assign values ​​to the weights and biases of the key features, and use the gradient descent algorithm to adjust the weights and biases of the neurons.

[0035] Step 5.5 If backpropagation still fails to achieve the required accuracy, then adjust the learning rate. Time step The model hyperparameters were repeatedly adjusted until the error between the calculated and theoretical values ​​was minimized.

[0036] Compared with existing technologies, according to the present invention, in step 2, feature extraction is optimized through the TCRA attention mechanism module to highlight key task features, thereby reducing the interference of secondary features on the bidirectional long short-term memory network; in step 3, the Optuna hyperparameter optimization framework is adopted to adaptively adjust the selection range of each hyperparameter, and combined with the pruning strategy mechanism, the optimization cycle can be significantly shortened; the Dropout mechanism is introduced into the model to process the sparse feature network, effectively suppressing overfitting and improving the model's generalization ability; at the same time, the Adam optimizer is used to accelerate the training process, helping the model converge faster and enhancing the global search ability, thereby significantly improving the accuracy and robustness of task prediction.

[0037] In step 4, according to The numerical method assesses the degree of fit between the theoretical and actual values, determines the magnitude of the error between the theoretical and calculated values ​​based on the MSE loss function value, adjusts the weights and biases through backpropagation, and adjusts the hyperparameters of the neural network model to bring the calculation results to the optimal solution. Attached Figure Description

[0038] Figure 1 These are schematic diagrams of four free-form surfaces according to an embodiment of the present invention;

[0039] Figure 2 This is a schematic diagram of a BiLSTM model according to an embodiment of the present invention;

[0040] Figure 3 This is a flowchart of the Optuna hyperparameter optimization algorithm framework according to an embodiment of the present invention;

[0041] Figure 4 This is a schematic diagram of the TCRA attention mechanism module combined with a BiLSTM model according to an embodiment of the present invention.

[0042] Figure 5 This is a comparison diagram of the expected value of surface 1 and the calculated value of the model according to an embodiment of the present invention;

[0043] Figure 6 This is a comparison diagram of the expected value of surface 2 and the calculated value of the model according to an embodiment of the present invention;

[0044] Figure 7 This is a comparison diagram of the expected value of surface 3 and the calculated value of the model according to an embodiment of the present invention;

[0045] Figure 8 This is a comparison diagram of the expected value of surface 4 and the calculated value of the model according to an embodiment of the present invention.

[0046] Figure 9This is a flowchart of a five-axis CNC finishing toolpath approximation error calculation method based on an Optuna-optimized BiLSTM-TCRA neural network according to an embodiment of the present invention. Detailed Implementation

[0047] The specific embodiments of the present invention will now be described in detail with reference to the accompanying drawings, but it should be understood that the scope of protection of the present invention is not limited to the specific embodiments.

[0048] Unless otherwise expressly stated, throughout the specification and claims, the term "comprising" or its variations such as "including" or "comprises" shall be understood to include the stated elements or components without excluding other elements or other components.

[0049] like Figures 1 to 8 As shown, this invention presents a preferred embodiment of a method for calculating the toolpath approximation error in five-axis CNC finishing based on an Optuna-optimized BiLSTM-TCRA neural network. The specific implementation is as follows:

[0050] Step 1: Import the surface model and plan the isoparameter toolpaths.

[0051] Import the surface model and obtain data for four freeform surface models. Use the isoparametric method to calculate toolpaths and obtain sample data for surfaces 1, 2, 3, and 4, where the tool radius is 6mm. Schematic diagrams of the four freeform surfaces are shown below. Figure 1 As shown.

[0052] (1) For surface model 1 (bounding box size is The dataset is designed with 190 and 180 toolpaths, each with 100 tool positions. T190×100 (number of toolpath rows × number of tool positions) are used as training samples (18612 samples), and T180×100 are used as test samples (17820 samples). The approximation error distribution range is... .

[0053] (2) For surface model 2 (bounding box size is...) The dataset consists of 190 and 180 toolpaths, with 100 toolpath positions per row. T190×100 samples are used as the training set (18612 samples), and T180×100 samples are used as the test set (17820 samples). The approximation error distribution range is... .

[0054] (3) For surface model 3 (bounding box size is...) The dataset consists of 190 and 180 toolpaths, with 100 toolpath positions per row. T190×100 samples are used as the training set (18612 samples), and T180×100 samples are used as the test set (17820 samples). The approximation error distribution range is... .

[0055] (4) For surface model 4 (bounding box size is...) The dataset consists of 190 and 180 toolpaths, with 100 toolpath positions per row. T190×100 samples are used as the training set (18612 samples), and T180×100 samples are used as the test set (17820 samples). The approximation error distribution range is... .

[0056] Step 2 Data Preparation and Preprocessing

[0057] The approximation error is the maximum distance between the tool contact trajectory and the tool envelope surface between two adjacent tool contacts. The tool contact trajectory is typically replaced by discrete points on it, a method that is more convenient in practical applications. The approximation error value is calculated from the discrete tool contacts, two adjacent tool positions, and tool information.

[0058] Input data includes: tool radius R, tool rake angle Tool length L, and 10 discrete points on the tool contact trajectory line. Three coordinates knife point , Three coordinates , Tool axis point , Three coordinates , .

[0059]

[0060] To eliminate the influence of different dimensions between samples, normalization is used to map the data to the same scale. Assume the dataset contains n samples and m parameters, i.e. The normalized data is shown in formula (1):

[0061] (1)

[0062] in The value is the normalized value. For the parameters that need to be normalized, Std represents the mean error and standard deviation of this parameter.

[0063] Step 3: Build a neural network model

[0064] Step 3.1 Create a BiLSTM neural network model

[0065] A BiLSTM neural network consists of an input layer, bidirectional hidden layers, and an output layer. The input layer receives the temporal dataset required for model computation, and the output layer outputs the target result. The bidirectional hidden layers include forward LSTM layers and backward LSTM layers. The forward LSTM layer processes the forward temporal dependencies of the data, and the backward LSTM layer processes the inverse temporal dependencies. These two layers work together to fuse the bidirectional temporal features, which are then passed to the output layer through a fully connected layer. The BiLSTM network structure is as follows: Figure 2 As shown. Optuna is an adaptive hyperparameter optimization algorithm framework that can quickly find the required hyperparameters using a dataset. The Optuna optimization framework is as follows: Figure 2 As shown. The TCRA attention mechanism dynamically weights the hidden layer output, focusing on key features and suppressing redundant information interference. Its operating mechanism is as follows: Figure 4 As shown.

[0066] Step 4: Optimize the neural network framework

[0067] Step 4.1 Set up the Optuna hyperparameter optimization framework

[0068] The Optuna hyperparameter optimization framework employs advanced Bayesian optimization strategies, incorporating sampling algorithms such as TPESampler (Tree-structured Pareto Estimation Sampler) and pruning strategies. It continuously builds probabilistic models based on historical experimental results and proactively recommends more promising parameter regions to improve the training speed and accuracy of BiLSTM models and reduce manual training time.

[0069] At the start of Optuna, an initial set of trials is generated by randomly initializing a set of trial positions in the search space. The trial set is of size N, and each trial has a position vector. The solution (i.e., hyperparameter configuration) corresponding to the problem to be optimized can be calculated from equation (2). and These represent the lower and upper bounds of the solution, respectively. Indicates the first The position vector of each test It is a random number between 0 and 1

[0070]

[0071] The fitness value determines the quality of an experiment and is usually calculated using an objective function, which can be obtained from equation (3). The fitness value is used to evaluate the performance of hyperparameter configurations (e.g., loss value or accuracy). Indicates the first The fitness value of each experiment It is a user-defined objective function.

[0072]

[0073] Based on fitness values, the trial history is divided into good and poor groups. The good group consists of trials with relatively good fitness values ​​(e.g., low loss values), and the poor group consists of trials with relatively poor fitness values. The proportion of the good group is determined by the quantile γ, typically γ = 0.25, meaning the top 25% of trials are classified as the good group, and the rest as the poor group. This division into good and poor groups is used in subsequent sampling processes.

[0074] Optuna uses the TPE (Tree-structured Parzen Estimator) sampler to generate new test locations. The TPE models the distributions of the good and bad groups using kernel density estimation (KDE) and then samples new points from the distribution of the good group to maximize the expected improvement, which can be calculated by equations (4) and (5).

[0075]

[0076]

[0077] Specifically, new points from The mid-sample can be calculated using equation (6). And through optimization... This guides the search. The formula for generating new points is based on the good-group distribution. Sum and difference group distribution It can be calculated from equations (7) and (8).

[0078]

[0079] in, It is a good group of kernel density estimates. It is the kernel density estimate of the difference set, where K is the kernel function.

[0080]

[0081]

[0082] In each trial, the Optuna framework evaluates the fitness value of new points and updates the historical data. Then, based on the updated historical data, the good and bad groups are recalculated, and new points are sampled again. This process is repeated until the maximum number of trials is reached or the convergence condition is met.

[0083] Step 4.2 Configure the TCRA attention mechanism module

[0084] To adapt to the processing requirements of the TCRA attention mechanism module for temporal features, a time sliding window operation is first performed on the original dataset. Let the original dataset be a time series. Where N is the total number of items. These are the relevant features. If the sliding window size is set to L and the window step size to S, then the processed input feature matrix is... The window division can be calculated using equation (9), where M is the number of windows. C is the window index, and C is the feature dimension for a single time step.

[0085]

[0086] The temporal attention mechanism targets the temporal features after sliding window processing, focusing on extracting information from key time steps. First, it performs spatial compression on the input feature X to obtain the temporal feature matrix. Subsequently, temporal attention weights are calculated, and a weight matrix is ​​generated by measuring the association similarity at different time steps. It can be calculated from equation (10), where The compressed feature dimension, This is the scaling factor.

[0087]

[0088] Finally, the weights are weighted and fused with the initial temporal features to obtain the temporal attention enhancement features. It can be calculated from equation (11).

[0089]

[0090] Subsequently, the channel attention mechanism follows the temporal attention output, further optimizing the discriminative power of the feature channels. First, for... Temporal-spatial dimension compression is performed, and channel statistical features are obtained through global average pooling. The channel weights can be calculated using equation (12); then, the channel weights are generated through a "compression-excitation" structure. It can be calculated by equation (13); then channel weighting is achieved by multiplying element by element, to obtain It can be calculated from equation (14);

[0091]

[0092]

[0093]

[0094] To mitigate gradient vanishing in deep networks, the module introduces residual connections, adding the channel attention output to the original features processed by the time sliding window. Combined with batch normalization for stable training, the final output is the optimized feature of the TCRA module, which can be calculated using equation (15), where... , It is a parameterized fully connected layer, and BN is batch normalization.

[0095]

[0096] Step 5: Calculate the approximation error value

[0097] Step 5.1 After obtaining the approximation error value from the output layer, use equation (16) to calculate the theoretical value. Compared with calculated values The smaller the MSE, the higher the accuracy of the model calculation.

[0098] (16)

[0099] Step 5.2 If the model's prediction error is insufficient to meet the requirements, backpropagation is performed. This involves optimizing the Attention weights and biases to obtain the Attention weight matrix. After backpropagation, adjustments are made according to the gradient using equation (17) to reallocate task-specific concerns and obtain a new weight matrix. :

[0100] (17)

[0101] Considering that BiLSTM (Bidirectional Long Short-Term Memory) networks are prone to overfitting and getting trapped in local optima when using the SGDM (Stochastic Gradient Descent with Momentum) optimizer, the optimizer needs to be replaced with Adam (Adaptive Moment Estimation) to achieve reasonable adjustment of the network weights and biases, as shown in Equation (18). The first-order and second-order momentum decay coefficients are used to control the weights of historical information, respectively. and This represents the corrected momentum term. For the network's learning rate, and The momentum term is responsible for adjusting the learning step size, and t-1 is the number of the current iteration.

[0102] (18)

[0103] Step 5.3 Each iteration includes one forward propagation and one backward propagation process. In each iteration t, the Attention bias vector... Feedback error adjustment is performed according to equation (19). After multiple iterations, if the model's computational accuracy reaches the expected level, training is stopped and the model's computational values, weights, and biases are saved. If the expected level is still not reached, the learning rate is adjusted. Momentum hyperparameter Adjust the hyperparameters of the model and retrain it until the computational accuracy reaches its maximum. Then save the weights, biases, and calculated values ​​when the loss function is minimized.

[0104] (19)

[0105] Step 5.4 To further verify the model's test accuracy and speed, the test sample sets of surfaces 1, 2, 3, and 4 were placed into the test set for accuracy testing and compared with the other neural networks. OP-BiLSTM-TCRA is the model used in this invention. The verification comparison results for surface 1 are as follows: Figure 5 As shown in Table 2; the verification comparison results of surface 2 are as follows: Figure 6 As shown in Table 3; the verification comparison results of surface 3 are as follows: Figure 7 As shown in Table 4; the verification comparison results of surface 4 are as follows: Figure 8 As shown in Table 5.

[0106]

[0107]

[0108]

[0109]

[0110] A typical embodiment of the present invention is as follows:

[0111] Toolpaths were generated for surface models 1, 2, 3, and 4 using the isoparametric method. The tool radius for each model was 6mm. Specific details are as follows:

[0112] (1) For surface model 1 (bounding box size is The sample surface is planned into two sets: one with 190 rows and another with 180 rows of toolpaths. Each row of toolpaths has 100 tool positions. The dataset consists of 18612 training samples (T190×100, number of toolpath rows × number of tool positions) and 17820 test samples (T180×100). The approximation error distribution range is... ,like Figure 5 As shown, the error between the predicted result and the average value of the approximation error is only... It exhibits very high precision.

[0113] (2) For surface model 2 (bounding box size is...) The sample surface is planned into two sets: one with 190 rows and another with 180 rows of toolpaths. Each row of toolpaths has 100 tool positions. The dataset consists of 18612 training samples (T190×100, number of toolpath rows × number of tool positions) and 17820 test samples (T180×100). The approximation error distribution range is... ,like Figure 6 As shown, the error between the predicted result and the average value of the approximation error is only... It exhibits very high precision.

[0114] (3) For surface model 3 (bounding box size is...) The sample surface is planned into two sets: one with 190 rows and another with 180 rows of toolpaths. Each row of toolpaths has 100 tool positions. The dataset consists of 18612 training samples (T190×100, number of toolpath rows × number of tool positions) and 17820 test samples (T180×100). The approximation error distribution range is... ,like Figure 7 As shown, the error between the predicted result and the average value of the approximation error is only... It exhibits very high precision.

[0115] (4) For surface model 4 (bounding box size is...) The sample surface is planned into two sets of toolpaths, one with 190 rows and the other with 180 rows. Each toolpath has 100 tool positions. The dataset consists of 18612 training samples (T190×100, number of toolpath rows × number of tool positions) and 17820 test samples (T180×100). The approximation error distribution range is given. ,like Figure 8 As shown, the error between the predicted result and the average value of the approximation error is only... It exhibits very high precision.

[0116] The algorithm in this example runs on a PC with an Intel i5-12700F processor, an NVIDIA RTX 4060 graphics card, and 32GB of RAM. The OP-BiLSTM-TCRA model implements an adaptive hyperparameter search strategy by introducing the Optuna hyperparameter optimization framework. Relying on Bayesian optimization, it dynamically adjusts the hyperparameter sampling direction based on historical experimental results and features a dynamic pruning mechanism. This pruner evaluates experimental performance in real time, allowing for the early termination of poorly performing trials, thus conserving computational resources and improving optimization efficiency. Furthermore, the TCRA attention mechanism effectively distinguishes feature importance and handles noisy or outlier data more efficiently, reducing prediction error fluctuations. This results in better generalization performance and operational efficiency for the OP-BiLSTM-TCRA model.

[0117] The foregoing description of specific exemplary embodiments of the invention is for illustrative and explanatory purposes. These descriptions are not intended to limit the invention to the precise forms disclosed, and it will be apparent that many changes and variations can be made in accordance with the foregoing teachings. The exemplary embodiments were chosen and described in order to explain the specific principles of the invention and its practical application, thereby enabling those skilled in the art to implement and utilize various different exemplary embodiments of the invention, as well as various different choices and variations. The scope of the invention is intended to be defined by the claims and their equivalents.

Claims

1. A method for calculating the toolpath approximation error in five-axis CNC finishing based on an Optuna-optimized BiLSTM-TCRA neural network, characterized in that, Includes the following steps: Step 1: Import the surface model and plan the toolpath with equal parameters; Step 2: Data preparation and preprocessing; Step 3: Establish a neural network model; Step 4: Optimize the neural network framework; Step 5: Calculate the approximation error value.

2. The method for calculating the toolpath approximation error of five-axis CNC finishing based on an Optuna-optimized BiLSTM-TCRA neural network as described in claim 1, characterized in that, Step 1: Import the surface model, plan the isoparametric toolpath, use the isoparametric method to plan the line spacing and step size of the surface model, generate the toolpath, and obtain each tool contact point, tool position point and its local tool contact point curve, and approximation error information.

3. The method for calculating the toolpath approximation error of five-axis CNC finishing based on an Optuna-optimized BiLSTM-TCRA neural network as described in claim 1, characterized in that, Step 2, data preparation and preprocessing, includes: A sample is constructed for each cutter site, including the following parameters: theoretical value of approximation error. The parameters are: tool radius R, tool length L, tool tip radius r, tool rake angle α, coordinates of two adjacent tool positions, tool axis vector of two adjacent tool positions, coordinates of discrete points on the local tool contact curve between two adjacent tool contact points, and theoretical value of approximation error. Z-score normalization is used to map the parameters within the samples to the same scale; all samples constitute the sample dataset.

4. The method for calculating the toolpath approximation error of five-axis CNC finishing based on an Optuna-optimized BiLSTM-TCRA neural network as described in claim 1, characterized in that, Step 3, establishing the neural network model, includes: Set the parameters required to create a neural network: Number of neurons in the hidden layer. Number of hidden layers Number of iterations Batch size Model learning rate Initial weights of neurons Neuron initial bias ReLU (Rectified Linear Unit) activation function, Adam (Adaptive Moment Estimation) optimizer, time sliding window, time step By introducing Dropout sparsity technology, a bidirectional long short-term neural network model was created.

5. The method for calculating the toolpath approximation error of five-axis CNC finishing based on an Optuna-optimized BiLSTM-TCRA neural network as described in claim 1, characterized in that, Step 4, optimizing the neural network framework, includes: Configure the TPESampler sampler and the number of trials in the Optuna optimization algorithm framework. Pruning strategies The hyperparameter optimization range is determined by setting a TCRA attention mechanism module between the hidden layer and the fully connected output layer of the bidirectional long short term network, and setting regularization processing between the two hidden layers, thus completing the creation of the BiLSTM-TCRA neural network model optimized based on Optuna.

6. The method for calculating the toolpath approximation error of five-axis CNC finishing based on an Optuna-optimized BiLSTM-TCRA neural network as described in claim 1, characterized in that, Step 5, calculating the approximation error value, includes: The samples in the dataset are fed into the neural network one by one. The sample data is propagated forward in the network, and the output data at the output layer is the calculated approximation error value of the network model. ; use Indicates theoretical value Compared with calculated values The goodness of fit between the two is calculated using the MSE (Mean Squared Error) loss function to determine the theoretical value. Compared with calculated values The error between them is used to measure the accuracy of the model's approximation error calculation; If the accuracy does not meet expectations, backpropagation begins, and the gradient descent algorithm is used to adjust the weights and biases of the neurons to minimize the MSE loss function value. If the accuracy still does not meet expectations, adjust the hyperparameters of the network model and start the calculation again until the model's computational accuracy reaches its maximum. Save the approximation error calculation value of the model, as well as the weights and biases of the neural network model.

Citation Information

Patent Citations

  • Method for Generating Equal Error Toolpaths in Parametric Surface Flat End Machining (5-Axis)

    CN112987647B