Chocolate 3D printing temperature real-time regulation method

By constructing a Lüperfox-optimized Transformer-BiLSTM hybrid neural network model, the problems of accuracy and adaptability in temperature control for chocolate 3D printing were solved, achieving high-precision, low-fluctuation real-time temperature control and improving printing quality and stability.

CN122632944APending Publication Date: 2026-08-25YANGZHOU UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610783608.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-02
Publication Date
2026-08-25

AI Technical Summary

Technical Problem

Existing technologies make it difficult to establish accurate temperature control models for chocolate 3D printing. Traditional models rely on manually setting hyperparameters to predict performance, which makes it difficult to adapt to changes in different formulas, shelf life, and extrusion conditions. Furthermore, they lack temperature smoothness constraints, leading to large prediction deviations and extrusion blockages.

Method used

A Transformer-BiLSTM hybrid neural network model based on Lüperfox optimization was constructed. The optimal viscosity was determined through extrusion and printing experiments. Data from multiple operating conditions were collected, an inverse mapping model was constructed, and hyperparameters were optimized using the Lüperfox optimization algorithm. A temperature change smoothing penalty term was added to achieve real-time adaptive temperature control.

Benefits of technology

It improves the adaptability and generalization ability of the model under different batches, different shelf lives and different extrusion conditions, realizes high-precision and low-fluctuation real-time temperature control, avoids extrusion clogging, and improves printing accuracy and stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122632944A_ABST
    Figure CN122632944A_ABST
Patent Text Reader

Abstract

The present application belongs to the field of combination of additive manufacturing and intelligent manufacturing, and discloses a chocolate 3D printing temperature real-time regulation method. The present application proposes a RFO-Transformer-BiLSTM hybrid neural network regulation method based on Lueper fox optimization. The viscosity time series data of chocolate at different temperatures, shear rates and shelf lives are collected by a rotary rheometer; a TransformerBiLSTM network with time, viscosity and shear rate as input and target control temperature as output is constructed, and the RFO algorithm is used to automatically optimize the number of self-attention heads, the number of hidden layer nodes, the learning rate and the L2 regularization coefficient of the network. According to the viscosity and shear rate collected in real time, the required temperature is predicted, and the adaptive regulation of the temperature in the chocolate 3D printing process is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of 3D printing and artificial intelligence technology, and specifically relates to a method for real-time temperature control in chocolate 3D printing. Background Technology

[0002] Chocolate 3D printing is a specific application of additive manufacturing technology in the food industry, fully demonstrating the broad application prospects of additive manufacturing technology in areas such as personalized food customization and complex structural modeling. In thermal extrusion printing, the rheological properties of chocolate materials are highly sensitive to temperature, time, and shear rate. During the printing process, multiple factors such as nozzle temperature, extrusion speed, and shear rate are coupled, leading to nonlinear changes in chocolate viscosity, which in turn affects the printing quality. Furthermore, traditional constitutive equations (such as Carreau and Cross equations) are difficult to accurately fit the relationships between rheological properties, limiting research on optimizing printing accuracy. Therefore, establishing an accurate dynamic mapping model between temperature and viscosity and achieving real-time control of printing temperature are key technical challenges for improving the accuracy and stability of chocolate 3D printing.

[0003] For temperature control of nonlinear systems, deep learning models such as Transformer and BiLSTM have been widely used in industrial time series prediction tasks. These models theoretically possess the ability to learn complex nonlinear mappings, but their prediction performance heavily relies on the manual setting of hyperparameters (such as the number of self-attention heads, the number of hidden layer nodes, the learning rate, and the regularization coefficient). Applying such models directly to temperature control in chocolate 3D printing presents several challenges. For instance, the rheological properties of chocolate vary significantly under different formulations, shelf lives, and extrusion speeds. Fixing hyperparameters or relying on manual parameter tuning makes it difficult to adapt to changes in engineering conditions, leading to large prediction biases. Furthermore, chocolate materials are highly sensitive to temperature; drastic temperature changes between adjacent time points can easily cause extrusion blockage. Conventional time series prediction models only aim to minimize prediction errors, without considering the smoothness constraints of temperature output. Additionally, existing models often employ offline training and control modes, lacking adaptive adjustment capabilities.

[0004] Therefore, a real-time temperature control method for chocolate 3D printing is needed that can automatically optimize hyperparameters, has temperature smoothing constraints, and online adaptive capabilities. Summary of the Invention

[0005] The purpose of this invention is to provide a real-time temperature control method for chocolate 3D printing to solve the problem that the strong nonlinearity, thermal hysteresis, and crystallization aging characteristics between the viscosity, temperature, shear rate, and time of chocolate materials make it difficult to establish an accurate inverse temperature prediction model.

[0006] Based on the above concept, the technical solution adopted by this invention is as follows: According to a first aspect of the present invention, a method for real-time temperature control in chocolate 3D printing is provided, comprising the following steps: S1. Determine the optimal viscosity of the target chocolate during the 3D printing process through extrusion and printing experiments; S2. Construct a multi-condition orthogonal experiment to collect viscosity data of the target chocolate at different times, temperatures and shear rates to form a sample set. S3. Construct a viscosity-temperature inverse mapping model with time series, viscosity series and shear rate series as inputs and temperature series as output; the viscosity-temperature inverse mapping model is a Transformer-BiLSTM hybrid neural network model with hyperparameter optimization by Lüpertz algorithm; S4. Deploy the trained viscosity-temperature inverse mapping model to the controller of the chocolate 3D printer; S5. During the actual printing process, the current printing time, the optimal viscosity, and the current shear rate are obtained in real time and input into the viscosity-temperature inverse mapping model to dynamically predict and control the heating temperature of the print head.

[0007] In some embodiments, the specific criteria for determining the optimal viscosity in step S1 include: in the extrusion experiment, the chocolate paste is continuous and the extrusion line diameter is 1 to 1.3 times the nozzle diameter; in the printing experiment, the first layer has no shrinkage, warping, or slippage, and there is no collapse after printing 5 to 10 layers continuously; when the above criteria are met, the real-time viscosity of the chocolate paste at this time is measured as the optimal viscosity.

[0008] In some embodiments, in step S2: The time range is within the shelf life of the chocolate, and the sampling interval is 2 hours; The temperature range is 35°C to 40°C, and the sampling interval temperature is 0.1°C. The shear rate range covers the shear rate interval corresponding to the extrusion flow during chocolate printing.

[0009] In some embodiments, in step S3, the Transformer-BiLSTM hybrid neural network model includes: The location embedding layer is used to add temporal location information to the input time, viscosity, and shear rate sequences; The first self-attention layer contains a causal mask to ensure that temperature prediction depends only on input data from historical moments. The second self-attention layer, which does not contain a mask, is used to capture the global dependency features of the chocolate material over the entire time span; A bidirectional LSTM layer is used to receive the feature sequence output by the second self-attention layer and output the hidden state of the last time step; A fully connected layer is used to map the hidden state of the last time step to the predicted temperature value.

[0010] In some embodiments, the Lüperfox optimization algorithm described in step S3 is used to adaptively optimize the number of self-attention heads, the number of hidden layer nodes, the initial learning rate, and the L2 regularization coefficient in the Transformer-BiLSTM hybrid neural network model.

[0011] Furthermore, the Lüper Fox optimization algorithm uses a weighted sum as the fitness function for optimization; the weighted sum is composed of a temperature prediction error term and a temperature change smoothing penalty term; the temperature change smoothing penalty term is used to suppress drastic fluctuations in the predicted temperature at adjacent time points.

[0012] In some embodiments, the temperature change smoothing penalty term is defined as:

[0013] in, λ Indicates the weighting coefficient. α For balance coefficient, Temperature t Indicates the first t Temperature value at time, T Indicates the current moment; The fitness function is a weighted sum of the root mean square error of temperature prediction and the temperature change smoothing penalty term, expressed by the formula:

[0014] in, RMSE temperature This indicates the error value at the current temperature.

[0015] According to a second aspect of the present invention, a real-time temperature control system for chocolate 3D printing is provided, comprising: The data acquisition module is used to execute steps S1 and S2 to obtain the optimal viscosity of the target chocolate and construct a sample set; The model building and optimization module is used in step S3 to build and train the Transformer-BiLSTM hybrid neural network model optimized by the Lüpertz fox optimization algorithm as a viscosity-temperature inverse mapping model. The real-time control module, used in steps S4 and S5, deploys the model on the printer controller and predicts and controls the printing temperature based on the real-time collected printing time, optimal viscosity, and shear rate.

[0016] The beneficial effects of this invention are as follows: 1. This invention fully considers the strong nonlinearity and thermal hysteresis characteristics of chocolate materials during thermal extrusion printing. It constructs an inverse mapping neural network with time-series data of time, viscosity, and shear rate as input and target controlled temperature as output. Furthermore, through RFO algorithm hyperparameter optimization, it overcomes the shortcomings of low efficiency and difficulty in adapting to rheological drift caused by manual experience-based parameter tuning, improving the model's adaptability and generalization ability under different batches, shelf lives, and extrusion conditions.

[0017] 2. This invention constructs a high-precision prediction model more suitable for 3D printing of chocolate materials by adding a temperature change smoothing penalty term to the fitness function to constrain temperature fluctuations between adjacent steps. Deploying the optimized model to the printer's real-time controller effectively achieves high-precision, low-fluctuation, and adaptive real-time temperature control during the chocolate 3D printing process. Attached Figure Description

[0018] Figure 1 This is a schematic diagram of the prediction method of the present invention.

[0019] Figure 2 This is a schematic diagram of the reverse mapping model process in the prediction method of this invention.

[0020] Figure 3 (a) is a schematic diagram of the predicted temperature at the corresponding viscosity according to the present invention; (b) is a schematic diagram of the prediction results of the training set; and (c) is a schematic diagram of the prediction results of the test set. Detailed Implementation

[0021] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the invention as detailed in the appended claims.

[0022] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. Unless otherwise defined, the technical or scientific terms used in this application should be understood in their ordinary sense by one of ordinary skill in the art to which this invention pertains. The words “a” or “one” and similar terms used in this application specification and claims do not indicate a limitation of quantity, but rather indicate the presence of at least one. “A plurality” means two or more. The words “comprising” or “including” and similar terms mean that the element or object preceding “comprising” or “including” covers the element or object listed following “comprising” or “including” and its equivalents, and does not exclude other elements or objects. The words “connected” or “linked” and similar terms are not limited to physical or mechanical connections and can include electrical connections, whether direct or indirect. The words “above” and / or “below” and similar terms are for ease of description only and are not limited to a location or spatial orientation. The singular forms “a,” “the,” and “the” used in this application specification and appended claims are also intended to include the plural forms, unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0023] The technical concept of this invention includes: In the process of thermo-extrusion 3D printing, chocolate materials exhibit complex rheological properties, including strong nonlinearity, thermal hysteresis, and crystallization aging, in relation to viscosity, temperature, shear rate, and time. This makes it difficult to establish accurate inverse temperature prediction models. Traditional constitutive equations cannot accurately fit the aforementioned multi-factor coupling relationships. While existing deep learning models (such as Transformer and BiLSTM) possess nonlinear mapping capabilities, their prediction performance heavily relies on manually set hyperparameters (such as the number of self-attention heads, the number of hidden layer nodes, the learning rate, and the regularization coefficient), making it difficult to adapt to the rheological drift under different formulations, shelf lives, and extrusion conditions. Furthermore, conventional time-series prediction models only aim to minimize prediction errors and do not consider the smoothness constraints of temperature output between adjacent time points, which can easily lead to chocolate extrusion blockage. In addition, existing models mostly adopt offline training modes and lack online adaptive adjustment capabilities.

[0024] This invention proposes a Transformer based on Lüperfox optimization. BiLSTM Hybrid Neural Network Control Method (RFO) Transformer BiLSTM). First, viscosity time-series data of chocolate at different temperatures, shear rates, and shelf lives were collected using a rotational rheometer to construct an inverse mapping model with time, viscosity, and shear rate as inputs and a target control temperature as the output. Second, the Lüpertzian optimization algorithm was used to optimize the Transformer. The BiLSTM network automatically optimizes the number of self-attention heads, hidden layer nodes, learning rate, and L2 regularization coefficient, overcoming the shortcomings of low efficiency and poor adaptability of manual parameter tuning. Specifically, a temperature change smoothing penalty term is introduced into the fitness function, combining viscosity prediction error with weighted suppression of temperature fluctuations at adjacent time points, thereby avoiding extrusion blockage caused by drastic temperature changes. Finally, the optimized model is embedded into the printer's real-time controller, predicting the required temperature based on real-time collected viscosity and shear rate data, achieving high-precision, low-fluctuation, and adaptive temperature control during chocolate 3D printing.

[0025] Therefore, this invention proposes to integrate the Lüper Fox optimization algorithm with the Transformer algorithm with smoothing constraints. BiLSTM hybrid neural network to construct viscosity A temperature inverse mapping model is implemented and deployed in the printer controller to achieve real-time adaptive control of the temperature during chocolate 3D printing, thus solving the problem of the difficulty in accurately modeling viscosity using traditional methods. Problems include temperature relationships, reliance on human experience for hyperparameters, and the prediction of drastic temperature fluctuations.

[0026] This application provides a method for real-time temperature control in chocolate 3D printing, including the following steps: S1. Determine the optimal viscosity of the target chocolate during the 3D printing process through extrusion and printing experiments; S2. Construct a multi-condition orthogonal experiment to collect viscosity data of the target chocolate at different times, temperatures and shear rates to form a sample set. S3. Construct a viscosity-temperature inverse mapping model with time series, viscosity series and shear rate series as inputs and temperature series as output; the viscosity-temperature inverse mapping model is a Transformer-BiLSTM hybrid neural network model with hyperparameter optimization by Lüpertz algorithm; S4. Deploy the trained viscosity-temperature inverse mapping model to the controller of the chocolate 3D printer; S5. During the actual printing process, the current printing time, the optimal viscosity, and the current shear rate are obtained in real time and input into the viscosity-temperature inverse mapping model to dynamically predict and control the heating temperature of the print head.

[0027] This invention fully considers the strong nonlinearity and thermal hysteresis characteristics of chocolate materials during thermal extrusion printing. It constructs an inverse mapping neural network with time-series data of time, viscosity, and shear rate as input and target temperature control as output. Through RFO algorithm hyperparameter optimization, it overcomes the shortcomings of low efficiency and difficulty in adapting to rheological drift in manual parameter tuning, improving the model's adaptability and generalization ability under different batches, shelf lives, and extrusion conditions. By adding a temperature change smoothing penalty term to the fitness function, this invention constrains temperature fluctuations between adjacent steps, constructing a high-precision prediction model more suitable for 3D printing of chocolate materials. Deploying the optimized model on the printer's real-time controller effectively achieves high-precision, low-fluctuation, and adaptive real-time temperature control during chocolate 3D printing.

[0028] The following is in conjunction with the appendix Figures 1 to 3 This application provides a detailed description of a method for real-time temperature control in chocolate 3D printing.

[0029] like Figure 1 As shown in the figure, a method for real-time temperature control in chocolate 3D printing includes the following steps: This embodiment focuses on chocolate with a cocoa butter content of ≥60% and is implemented on a thermal extrusion chocolate 3D printer (nozzle diameter of 0.8mm).

[0030] Step S1: Extrusion, printing, and rheological experiments were conducted on the chocolate to determine the optimal viscosity for 3D printing. The extrusion experiment involved observing the continuity and filament breakage of the chocolate flowing from the nozzle within a temperature range of 30-40℃. The extruded wire diameter was specifically 1-1.3 times the nozzle diameter. The printing experiment involved printing the first layer within the 30-40℃ temperature range without shrinkage, warping, or slippage, and then printing 5-10 layers continuously without collapse. The real-time viscosity of the chocolate slurry was measured and used as the optimal viscosity value for this type of chocolate for 3D printing. After the experiments, the printing temperature was focused at 35-40℃, with a sampling interval of 0.1℃, and rheological experiments on the chocolate material were conducted.

[0031] Step S2: Multi-condition data acquisition for the rheological properties of chocolate. The viscosity of chocolate exhibits a non-linear characteristic to temperature changes within the 35-40℃ range, and the viscosity fluctuates over time and with changes in shear rate. Therefore, the effects of temperature, time, and shear rate on viscosity must be comprehensively considered. Specific independent variable parameters to consider when acquiring viscosity data in rheological experiments include: (1) Temperature, specifically 35-40℃, with a sampling interval of 0.1℃; (2) Time: Within 3 days from the date of chocolate production (shelf life), measured every 2 hours; (3) Shear rate, specifically in the range of 0-1000 s -1 The viscosity values ​​under the above conditions were measured using a rotational rheometer to form sample data.

[0032] Step S3: Constructing a viscosity-temperature inverse mapping model. In actual chocolate 3D printing, the heating temperature needs to be adjusted to maintain the chocolate in a good flow state to meet printing requirements. Therefore, an inverse mapping model was constructed based on a Transformer-BiLSTM neural network, with time, viscosity, and shear rate as inputs and temperature as the output. This network is suitable for relating the current viscosity of the chocolate material to historical temperature changes and to the material transformation throughout the printing process. This neural network processes sequential data such as time, viscosity, and shear rate, and compresses the processed feature sequence into a single vector through an index layer, mapping the temperature output feature. A fully connected layer is then used to regress and predict the temperature value under the corresponding time, shear rate, and viscosity conditions.

[0033] The Transformer-BiLSTM hybrid neural network model specifically includes: The location embedding layer is used to add temporal location information to the input time, viscosity, and shear rate sequences; The first self-attention layer contains a causal mask to ensure that temperature prediction depends only on input data from historical moments. The second self-attention layer, which does not contain a mask, is used to capture the global dependency features of the chocolate material over the entire time span; A bidirectional LSTM layer is used to receive the feature sequence output by the second self-attention layer and output the hidden state of the last time step; A fully connected layer is used to map the hidden state of the last time step to the predicted temperature value.

[0034] In this embodiment, the specific parameters of the constructed Transformer-BiLSTM neural network are shown in Table 1.

[0035] Table 1. Key Parameter Settings for Transformer-BiLSTM

[0036] The specific structure is as follows: The location embedding expression: (1) (2) (3) in, Z Represents the embedding matrix of the input sequence. z i Indicates the firsti The feature vectors at time t, where R represents the set of real numbers. T Indicates the continuous sampling time; d m The number of characteristic sequences is 3 in this embodiment, representing time, shear rate, and viscosity, respectively; time t : Time since the chocolate left the factory, with a time interval of 2 hours; shear rate γ According to the nozzle diameter D and actual extrusion flow q Calculated viscosity η Data is collected in real time by a rotational rheometer.

[0037] The first layer of self-attention ensures that when the viscosity-temperature inverse mapping model predicts the current temperature, it only incorporates historical information (including time, shear rate, and viscosity) and does not borrow input data from future moments. The first layer of self-attention is expressed as follows: (4) (5) (6) in, Q , K , V These represent query, key, and value, respectively. Z Represents the input matrix, W Q , W K , W V These represent the projection matrices of the query, key, and value, respectively. Attention represents the scaling dot product attention in the Transformer, and Concat is the concatenation operation, which is the standard merging method for multi-head attention. W O This represents the output weight matrix in a multi-head attention mechanism. d k This is a scaling factor to prevent the dot product in the model from becoming too large. M The causal masking matrix ensures that the predicted temperature depends only on historical time, shear rate, and viscosity data. h This represents the number of heads in the self-attention mechanism and is one of the hyperparameters to be optimized. It demonstrates the model's ability to simultaneously focus on multiple different types of relationships, such as the immediate effect of shear rate on viscosity and the historical lag relationship between viscosity and temperature. Hyperparameters are parameters that need to be manually set before model training and cannot be directly learned from data.

[0038] First layer of self-attention output Z 1By using causal masking, the viscosity-temperature inverse mapping model can extract features based on historical (time, shear rate, viscosity) sequences to predict subsequent temperatures, thus avoiding the leakage of future information.

[0039] The second self-attention layer has a similar structure to the first layer, but without a mask; that is, it uses scaled dot product self-attention. M A value of 0 is used to capture the global dependencies of the chocolate throughout its shelf life. Z 2 This is a high-dimensional representation that integrates global dependencies and historically lagging information.

[0040] The relationship between chocolate viscosity and temperature changes depends not only on the current temperature but also on temperature changes over a past period. The bidirectional LSTM layer contains forward LSTM hidden states from the starting point to the current position and backward LSTM hidden states from the ending point to the current position. By concatenating the forward and backward LSTM hidden states and analyzing historical and future experimental data, the accuracy of the inverse mapping model is effectively improved. The final output is: (7) (8) in, Indicates from the starting point to the... i The hidden state of the forward LSTM at the given time position. Indicates from the starting point to the... i The hidden state of the forward LSTM at the given time position. h It is a time-step hidden state with a dimension of 2. u , u This represents the number of hidden layer nodes and is one of the hyperparameters to be optimized. It reflects the influence of subtle fluctuations in temperature caused by the coupling of multiple factors such as time, shear rate, and viscosity, as well as the nonlinear changes of these factors. H This represents the hidden state matrix output by the BiLSTM at all time steps. T This indicates consecutive sampling times. Ultimately, only the hidden state of the last time step is taken. h T The temperature is controlled by the predicted target temperature at the next moment through the output of the fully connected layer.

[0041] The hyperparameters of the viscosity-temperature inverse mapping model were optimized using the Lüper Fox Optimization (RFO) algorithm. The hyperparameters to be optimized included the number of self-attention heads, the number of hidden layer nodes, the initial learning rate, and the L2 regularization coefficient. Before the search, the range of hyperparameter values ​​and the RFO algorithm parameters were set, as shown in Tables 2 and 3. The number of self-attention heads reflects the model's ability to simultaneously focus on multiple different types of relationships, such as the immediate impact of shear rate on viscosity and the historical lag relationship between viscosity and temperature. The number of hidden layer nodes reflects the influence of subtle fluctuations in temperature caused by the coupling of multiple factors such as time, shear rate, and viscosity, as well as nonlinear changes in these factors. The initial learning rate is the step size used to update weights during the process of finding the minimum fitness function value. It dynamically changes according to the loss function, which is the sum of squared errors between the actual temperature and the model training temperature. The L2 regularization coefficient is a penalty term added to the loss function to prevent overfitting and controls the weights of the time, shear rate, and viscosity input parameters. It is dynamically determined by the amount of data for these three parameters.

[0042] Table 2. Range of Hyperparameter Values

[0043] Table 3 RFO Algorithm Parameters

[0044] The data is input into the algorithm, and the error feedback calculated by the fitness evaluation function is combined to search for the optimal combination of hyperparameters. The specific prediction steps are as follows: Initialize the fox group positions. Each position vector corresponds to a set of hyperparameter combinations to be optimized, including the number of heads in the self-attention mechanism, the number of hidden layer nodes, the initial learning rate, and the L2 regularization coefficient. Each hyperparameter combination corresponds to a candidate viscosity-temperature inverse mapping model structure. The fitness evaluation function is calculated using the root mean square error (RMSE) and the temperature change smoothing penalty term to evaluate the merits of each parameter value, i.e., to evaluate the prediction performance of each inverse mapping model. The smaller the fitness function value, the better. The process of updating the inverse mapping model structure is an iterative process of hyperparameter combination. The fox's position mentioned below refers to the specific value of the hyperparameter combination. This process simulates the fox's day and night foraging strategy: During the day, they mainly rely on visual hunting and auditory assistance, updating their position through random visual rotation and auditory range. Simulating visual hunting position updates, the hyperparameter update formula is obtained as follows: (9) in, yi k +1 indicates that it is the first... i Group of hyperparameter combinations in the first k The value of +1 iteration, yi k Indicates the i-th hyperparameter combination in the th case. k The value of the next iteration. ybest k This indicates that all hyperparameters are in the first position. k The global optimal value in the next iteration. p and rand It is a random value within the interval [0, 1]. k This indicates the current iteration number. r 0 represents the random step size factor, specifically the product of a random integer between 1 and 5 and a random decimal between 0 and 1. sight Indicates visual parameters, hear This represents auditory parameters.

[0045] The hyperparameter update formula is obtained by simulating the view rotation position update: (10) in, yi rotate Indicates the first i After rotating around the optimal position, the set of hyperparameters... k The value at +1 iteration, β This represents the limit of the random step size, which defaults to 1×10. -10 , randn (1, D ) represents the interval [0, 1] D dimensional random numbers, flag This indicates a parameter that alternates between 0 and 1.

[0046] The hyperparameter update formula for simulating auditory hunting position updates is as follows: (11) The hyperparameter update formula is obtained by simulating ear rotation position updates: (12) At night, they primarily rely on hearing to hunt, aided by vision, and update their position through random visual rotation and auditory range. The hyperparameter update formula for simulating auditory hunting position updates is as follows: (13) The hyperparameter update formula is obtained by simulating ear rotation position updates: (14) Simulating visual hunting position updates, the hyperparameter update formula is obtained as follows: (15) The hyperparameter update formula is obtained by simulating the view rotation position update: (16) In addition to hearing and vision, the Lüper fox uses its sense of smell to locate prey. Simulating the process of updating the hunting location using olfactory sensing, the update formula for the hyperparameter values ​​is obtained as follows: (17) in, r 1. r 2. r 3 and rand It belongs to the [0, 1] random value. smell This represents olfactory parameters.

[0047] In the hunting behavior, the position of each fox (the value of each hyperparameter) is continuously adjusted, while retaining the optimal result, and the fox pack (hyperparameter) will move towards the optimal solution position. The fox pack movement formula is: (18) (19) in, c 0=2 and c 1=2, r , r 1. r 2 and rand All values ​​are random values ​​within the range [0, 1]. a 0=2 and a 1 = 3, lbesti k Indicates the first k During the nth iteration, the 1st i The best historical position of the fox (the first) i Group of hyperparameter combinations from 1 to k (historical best value at the next iteration).

[0048] During the optimization process, to prevent the chocolate from being overly sensitive to temperature fluctuations, causing the temperature control difference between adjacent time intervals to exceed 0.5℃, which could incidentally affect the rheological properties of the extruded fibers and thus impact prediction accuracy, this invention sets a fitness function, specifically designed as follows: (20) in, RMSE temperature This indicates the error value at the current temperature. Temperature t Indicates the first t Temperature value at time, T Indicates the current moment. λ This represents the weighting coefficient, set to 0.1. α The balance coefficient is set to 0.5, indicating that for the model, the root mean square error and the temperature change smoothing penalty term are equally important. Both values ​​can be adjusted according to the chocolate material and printing equipment.

[0049] Each found hyperparameter combination is input into the inverse mapping model. The model is trained and iterated repeatedly until the maximum number of iterations (10) is reached or the optimal fitness change is within the allowable range of 10. -4 Then, a new set of hyperparameters is input into the model for training. The RFO iteration ends under the same condition as above, and the optimal combination of hyperparameters is found.

[0050] Step S4: Model Deployment and Real-Time Prediction. The viscosity-temperature inverse mapping model described above is written into the embedded controller of the chocolate 3D printer. Step S5: The temperature required for heating is dynamically determined in real time by using the current printing time (time interval from the factory), optimal viscosity (obtained from step S1), and shear rate (obtained from formula (3)) collected in real time by the sensor.

[0051] Furthermore, this study compares real-time temperature control methods for chocolate 3D printing with other prediction methods, including Transformer, BiLSTM, and Transformer-BiLSTM. Their detailed descriptions and necessary parameter settings are shown below: Transformer: A sequence model based on a self-attention mechanism. The core configuration of this model is consistent with the Transformer structure in this method, namely, it includes an input layer, positional encoding, a causal encoding-based self-attention layer, and a maskless self-attention layer. Specific parameter settings are shown in Table 4.

[0052] Table 4. Main Parameter Settings for Transformer

[0053] BiLSTM: This model captures contextual dependencies based on forward LSTM and backward LSTM. The structure of this model is consistent with the BiLSTM in this method; specific parameter settings are shown in Table 5.

[0054] Table 5. Key Parameter Settings for BiLSTM

[0055] Transformer-BiLSTM: This model has the same structure as the Transformer-BiLSTM in this method. The specific settings of the four hyperparameters optimized by RFO, namely the number of self-attention mechanism heads, the number of hidden layer nodes, the initial learning rate, and the L2 regularization coefficient, are shown in Table 6.

[0056] Table 6 Hyperparameter Settings

[0057] In comparative experiments, prediction accuracy is considered, including mean squared error (MSE) and coefficient of determination (R²). 2The mean absolute error (MAE) and mean absolute percentage error (MAPE) are calculated. The final prediction accuracy comparison results are shown in Table 7.

[0058] Table 7 Comparison of Prediction Methods

[0059] The comparison results show that the RFO-optimized Transformer-BiLSTM model is significantly better than other models in terms of prediction accuracy, further verifying that the method can effectively improve the fitting ability of the nonlinear rheological relationship of chocolate and provide reliable support for high-precision, low-fluctuation real-time temperature control.

[0060] The present invention also provides a real-time temperature control system for chocolate 3D printing, including a data acquisition module, a model building and optimization module, and a real-time control module.

[0061] The data acquisition module is used to perform the above steps S1 and S2, specifically including: determining the optimal viscosity of the target chocolate during the 3D printing process through extrusion and printing experiments, and collecting viscosity data of the target chocolate at different times, temperatures, and shear rates to form a sample set.

[0062] The model building and optimization module is used to execute step S3 above. Internally, it builds and trains a Transformer-BiLSTM hybrid neural network model with hyperparameters optimized by the Lüperfox optimization algorithm (RFO) as the viscosity-temperature inverse mapping model. This module first trains the initial network structure based on the sample set, and then uses the RFO algorithm to adaptively optimize the number of self-attention heads, the number of hidden layer nodes, the initial learning rate, and the L2 regularization coefficient, guided by a fitness function weighted with a temperature change smoothing penalty term, and finally outputs the optimized inverse mapping model.

[0063] The real-time control module is used to execute the above steps S4 and S5, deploy the trained viscosity-temperature inverse mapping model to the embedded controller of the chocolate 3D printer, and during the actual printing process, based on the real-time collected current printing time (time interval from the factory), the optimal viscosity obtained in step S1, and the shear rate estimated in real time by the nozzle diameter and flow rate, predict the required temperature and control the heating device to dynamically adjust the nozzle temperature to the predicted value.

[0064] It should be understood that the present invention is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. Therefore, the present invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein. The specification and embodiments are to be considered exemplary only, and the true scope and spirit of the invention are indicated by the following claims.

Claims

1. A method for real-time temperature control in chocolate 3D printing, characterized in that, Includes the following steps: S1. Determine the optimal viscosity of the target chocolate during the 3D printing process through extrusion and printing experiments; S2. Construct a multi-condition orthogonal experiment to collect viscosity data of the target chocolate at different times, temperatures and shear rates to form a sample set. S3. Construct a viscosity-temperature inverse mapping model with time series, viscosity series and shear rate series as inputs and temperature series as output; the viscosity-temperature inverse mapping model is a Transformer-BiLSTM hybrid neural network model with hyperparameter optimization by Lüpertz algorithm; S4. Deploy the trained viscosity-temperature inverse mapping model to the controller of the chocolate 3D printer; S5. During the actual printing process, the current printing time, the optimal viscosity, and the current shear rate are obtained in real time and input into the viscosity-temperature inverse mapping model to dynamically predict and control the heating temperature of the print head.

2. The method for real-time temperature control in chocolate 3D printing according to claim 1, characterized in that, The specific criteria for determining the optimal viscosity in step S1 include: in the extrusion experiment, the chocolate paste is continuous and the extrusion line diameter is 1 to 1.3 times the nozzle diameter; in the printing experiment, the first layer has no shrinkage, warping, or slippage, and there is no collapse after printing 5 to 10 layers continuously; when the above criteria are met, the real-time viscosity of the chocolate paste at this time is measured as the optimal viscosity.

3. The method for real-time temperature control in chocolate 3D printing according to claim 1, characterized in that, In step S2: The time range is within the shelf life of the chocolate, and the sampling interval is 2 hours; The temperature range is 35°C to 40°C, and the sampling interval temperature is 0.1°C. The shear rate range covers the shear rate interval corresponding to the extrusion flow during chocolate printing.

4. The method for real-time temperature control in chocolate 3D printing according to claim 1, characterized in that, In step S3, the Transformer-BiLSTM hybrid neural network model includes: The location embedding layer is used to add temporal location information to the input time, viscosity, and shear rate sequences; The first self-attention layer contains a causal mask to ensure that temperature prediction depends only on input data from historical moments. The second self-attention layer, which does not contain a mask, is used to capture the global dependency features of the chocolate material over the entire time span; A bidirectional LSTM layer is used to receive the feature sequence output by the second self-attention layer and output the hidden state at the last time step; A fully connected layer is used to map the hidden state of the last time step to the predicted temperature value.

5. The method for real-time temperature control in chocolate 3D printing according to claim 1, characterized in that, The Lüper Fox optimization algorithm described in step S3 is used to adaptively optimize the number of self-attention heads, the number of hidden layer nodes, the initial learning rate, and the L2 regularization coefficient in the Transformer-BiLSTM hybrid neural network model.

6. The method for real-time temperature control in chocolate 3D printing according to claim 5, characterized in that, The Lüper Fox optimization algorithm uses a weighted sum as the fitness function for optimization; the weighted sum is composed of a temperature prediction error term and a temperature change smoothing penalty term; the temperature change smoothing penalty term is used to suppress drastic fluctuations in the predicted temperature at adjacent time points.

7. The method for real-time temperature control in chocolate 3D printing according to claim 6, characterized in that, The temperature change smoothing penalty term is defined as follows: in, λ Indicates the weighting coefficient. α For balance coefficient, Temperature t Indicates the first t Temperature value at time, T Indicates the current moment; The fitness function is a weighted sum of the root mean square error of temperature prediction and the temperature change smoothing penalty term, expressed by the formula: in, RMSE temperature This indicates the error value at the current temperature.

8. A real-time temperature control system for chocolate 3D printing, characterized in that, include: The data acquisition module is used to execute steps S1 and S2 to obtain the optimal viscosity of the target chocolate and construct a sample set; The model building and optimization module is used to execute step S3, build and train the Transformer-BiLSTM hybrid neural network model optimized by the Lüperfox optimization algorithm, as a viscosity-temperature inverse mapping model; The real-time control module is used to execute steps S4 and S5, deploy the model to the printer controller, and predict and control the printing temperature based on the real-time collected printing time, optimal viscosity and shear rate.