# Deep Learning-Based Predictive Control of Injection Velocity in Injection Molding Machines

Authors: Zhigang Ren; Yaodong Li; Zongze Wu; Shengli Xie
Journal: Advances in Polymer Technology
 (2022)

---

## Abstract

Rapid and reliable optimal control of injection molding machines (IMMs) is critical for the effective production of injection-molded goods, especially in the situation of restricted computer resources of embedded equipment in IMMs. In this paper, an optimal tracking injection velocity control problem arising in a typical IMM is studied. An effective hybrid intelligent control approach with less computing resources for real-time implementation based on the deep learning (DL) method to mimic the classical model predictive control rule is developed to deal with the tracking control of the injection speed. The proposed method utilizes the gated recurrent unit neural network to learn and predict the optimal time series control process data produced by the traditional model predictive controller. The benefits of this approach over the conventional optimization method are illustrated through simulation results, which show that the convergent DL-based controller can effectively avoid the complex calculation in the control process of IMMs and meet the requirements of more robustness and resist environmental uncertainty to a certain level and can be potentially implemented in embedded hardware much more efficiently and conveniently with a smaller memory footprint and faster computation time.


---

## Body

## 1. Introduction

Plastic products have become an integral element of all industries and our everyday lives all over the world due to their outstanding flexibility, good durability, low cost, and other advantages [1]. In the field of discrete manufacturing, IMMs are professional operating equipment used to produce plastic components and other polymers. Nearly 70% of plastic products are produced by IMMs, which has become an important field of aerospace, national defense, electronics, and photoelectric communications. They provide important equipment support for high-end manufacturing such as aerospace, power electronics, clean energy, and chip production.The injection molding process in IMMs is a complex processing technology to make resin materials into plastic products. In this process, the parameter setting of IMMs is very important and closely related to the final product. Any improper changes of the parameter will affect the final quality of the product and produce various defects [1–3]. The injection molding process generally includes six stages: mold clamping, injection, pressure holding, plasticization, cooling, and mold opening. Injection molding is a cyclic process that each process includes above all stages. The simplified structure of a typical IMM is shown in Figure 1. Plastic granules are fed into the IMM through the hopper and melted by friction heating through a heating belt in the barrel. When the molten resin is uniformly heated to the appropriate temperature and fills the material area in the injection unit, the injection and filling can be started. The servo valve causes the reciprocating screw in the injection barrel to move swiftly, allowing the resin material to be injected via the nozzle into the closed metal mold. The screw is then kept at constant pressure, and more molten resin is injected into the mold to cover the gap left by the resin’s cooling and shrinkage. When the resin has cooled and completely solidified, the pressure held on the screw is removed. The components are released from the mold with the push of the demolding mechanism and fall into the collecting box once the mold is opened. This process is not only a cyclic process but also a complex parameter change process. For the production process of injection-molded parts, how to achieve precise control of system variables in each production stage is an important prerequisite for ensuring product quality. At different stages, there are also different requirements for parameters of the IMM. As the high-end manufacturing industry puts forward higher and higher requirements for the quality of plastic products, the traditional IMM control technology is gradually unable to meet the requirements in terms of accuracy and efficiency, especially the traditional PID-based control strategies, which have high requirements on the technology of the engineers, and is not easy to resolve problems in production as quickly as possible.Figure 1
A typical simplified structure of an injection molding machine.In recent years, there have been many related researches on control technologies in the field of the injection molding process [3–12]. For example, Tan et al. proposed an adaptive control approach for controlling injection speed changes throughout the injection molding process [4]. The strategy shows better performance than the traditional PID control strategy, which can adaptively adjust the mathematical model to deal with parameter changes during the sudden changes in speed. Gao et al. proposed an iterative learning control theory-based robust IMM control approach with flawless performance for systems with unknown initiation and disturbances [5]. Hopmann et al. proposed an iterative learning control system in which the reference tracking of the cavity pressure can be improved over several cycles and recurring disturbances can be automatically corrected to improve component quality even further [7]. With the development of more and more related researches, MPC-based approaches have also been widely employed in the injection molding process control [13–19]. Dubay used a self-optimizing MPC strategy to control the melt temperature in injection molding [17]. Furthermore, Reiter et al. proposed an MPC-based control method based on the IMM physical gray box model and realized the cavity pressure control of the IMM [18]. Hopmann et al. proposed an MPC strategy based on the self-optimizing injection molding process to control the cavity pressure of the IMM and the adaptive adjustment of process parameters [19]. MPC is a mature technology and has become the standard approach for implementing constrained, multivariable control in the process industries today [20]. However, there are still some problems that limit the applications of MPC, especially in the real-time control of complex systems. In the actual control process, due to the complex model or complex constraints, the calculation of MPC is sometimes time-consuming and it is difficult to realize real-time control or have high requirements for equipment. The MPC implementation for IMM systems with limited onboard processing capability, high sampling rates, and strong dynamics is still a difficult task [21], especially in the related embedded devices in the IMM equipment.With the quick growth of artificial intelligence theories such as deep learning (DL) and machine learning (ML) [22–33], deep neural networks (DNNs) have shown great abilities in various fields [34–37]. In addition to computer vision and natural language processing, DL has broad applications in the control area, particularly in the field of high control accuracy, where some great results have emerged through the combination of DL and control approaches [23, 25, 30, 31, 38]. The powerful learning ability of DNNs can often reproduce complex control processes well, simplify the application of the control theory, and enable it to be quickly deployed in complex models. Existing researches show that DL has better effects on the effective representation and approximation of predictive control laws [39–41]. In this paper, we study how to combine DL with traditional MPC to produce a high-performance predictive controller that is simple in design and more time efficient, while providing the concept of constraint satisfaction to ensure safety. The main purpose is to overcome the shortcomings of traditional MPC in solving efficiency and make full use of the advantages of deep learning networks to realize the design of a data-driven real-time optimal controller. To this end, we propose a DL-based predictive controller which can be applied to the optimal speed curve tracking control problem in a typical IMM system. A gated recurrent unit (GRU) network is designed to study the predictive control process of the controller, so as to replace the original model predictive controller and avoid the complex calculation and save running time brought by the traditional optimization process. The constructed GRU-based neural network module can play the same role as the original MPC controller by learning a large amount of time sequence data, allowing the GRU neural network module to follow changes in the target output and perform optimal control as a result. Furthermore, the problem of long computation time caused by repetitive recursive calculation and rolling optimization in the original model predictive control can be effectively avoided by using the GRU network module, allowing for real-time optimal control of injection molding machines with various tracking output targets. Experimental results also show that our designed DL-based predictive controller is able to accurately approximate the control law with a small memory footprint, very simple implementation, and low computational complexity. In the field of injection molding, particularly in the field of IMM control, this strategy can be quickly deployed in the embedded controller of the IMM without high requirements for equipment hardware performance and has a good application prospect.The rest of this paper is organized as follows. In Section2, we introduce the problem description and constraints of injection speed control of an IMM. In Section 3, we propose a DL-based MPC for the injection molding velocity control. In Section 4, numerical experimental results are taken to verify the feasibility of the proposed method. Finally, we conclude this paper in Section 5.


## 2. Problem Formulation

This section mainly provides a brief introduction on mathematical model of ram velocity, initial state, constraints, and cost function in IMM. We formulate the control task of ram velocity as a dynamic optimal control problem.


### 2.1. Mathematical Modeling

As a complex control process, resin temperature, cavity pressure, and ram velocity are the key process control parameters that are closely related to the final quality of plastic products [42]. Therefore, many mathematical models describing the changes in these parameters have also been proposed and one of important research directions is the velocity control. During this process, the molten plastic is injected and filled into the mold cavity at a certain speed driven by the control signal. The screw speed control is a process that changes with time, and the injection velocity profile has several zones, as shown in Figure 2. In different zones, the ram speed needs to reach the corresponding value to ensure that the parts meet the production requirements [43]. When the speed curve is set unreasonable, it may cause defects in the plastic parts.Figure 2
Injection velocity profile during the injection molding.Because the value of injection velocity needs to change with the change of reference trajectory, the control accuracy of the controller is required to be higher. In this paper, we adopt the following fourth-order transfer function model [44] as our control model which is given by relating the valve opening to the injection ram velocity:
(1)Gs=ps+s1s+s2s+s32+s42,where p, s1, s2, s3, and s4 are configuration parameters that can be set according to different IMM systems. By transforming the above transfer function and discretizing the state equation with the zero-order preservation method, the dynamic model of the studied IMM system can be represented as the following discrete-time state equations:
(2)xk+1=Axk+Buk+Dξk,yk=Cxk,where A∈ℝnx×nx, B∈ℝnx×nu, C∈ℝny×nx, and D∈ℝnx×nξ are parameter matrices of the ram speed model in the IMM. xk∈ℝnx×1 is the state vector, yk∈ℝny×1 is the IMM injection speed measured by the sensor, uk∈ℝnu×1 is the controlling variable which is proportional to the input signal of the servo valve, ξk∈ℝnξ×1 is an uncorrelated random sequence representing the process noise, and k is the control time. In this paper, ξk is a Gaussian noise sequence with zero mean and random variance in the range of ϵ,σ2. In practice for the IMM, the future noise is difficult to predict; thus, we take the following discrete-time model as the control object:
(3)xk+1=Axk+Buk+Kξ^k,yk=Cxk,where ξ^k is introduced to describe the model errors along the time horizon k and K is the Kalman filter gain. In sampling time k, we take the error ξ^k=yk−Cxk. As indicated in [13], if the mathematical model is stable, the observer gain K could be regarded as D. The control objective of the model is to calculate a control trajectory u so that the controlled ram speed y follows the predetermined trajectory yref as much as possible and minimizes the error between them.


### 2.2. Initial State and Constraints

In the actual control process, the initial state of the injection molding is generally slightly different. Most of these differences are caused by external disturbances or noise. To simplify the calculation, we assume that there is no noise before the system works. The initial states in IMM at starting timek=0 are denoted as follows:
(4)S0=x0,y0,u0,where all the initial values of S0 are set 0. In the IMM, the ram velocity yk and the controlling variable uk are limited by the machine. Due to the actual physical limitation, yk and uk in equations (2) and (3) should satisfy the following bound constraints:
(5)0≤yk≤ymax,0≤uk≤umax,where ymax and umax are the given maximum constants of ram velocity and control variable. During the injection molding process, uk and yk need to meet the above constraints and change within this interval. Through combining the mathematical model (3) and constraints (5), then, we can apply the MPC method to ram speed control in IMM.


### 2.3. Objective Index

In this paper, our main goal is to control the ram velocity of the IMM system as quickly as possible to converge to the specified target value. In this work, we define the following objective index as the control target:(6)minukJ=∑k=1pyk−yrefkTQyk−yrefk+∑k=1nΔukTRΔuk,where yrefk, yk, and Δuk are the reference tracking output, output of the plant, and control input increment at the discrete time k, respectively. The control input increment satisfies Δuk=uk−uk−1. Q is the weight matrix of y, and R is the weight matrix of Δuk. The precise control of the dynamic model can finally be attained by minimizing the value of the loss function (8), and the ram velocity yk can also quickly converges to the stated target velocity yrefk.


## 2.1. Mathematical Modeling

As a complex control process, resin temperature, cavity pressure, and ram velocity are the key process control parameters that are closely related to the final quality of plastic products [42]. Therefore, many mathematical models describing the changes in these parameters have also been proposed and one of important research directions is the velocity control. During this process, the molten plastic is injected and filled into the mold cavity at a certain speed driven by the control signal. The screw speed control is a process that changes with time, and the injection velocity profile has several zones, as shown in Figure 2. In different zones, the ram speed needs to reach the corresponding value to ensure that the parts meet the production requirements [43]. When the speed curve is set unreasonable, it may cause defects in the plastic parts.Figure 2
Injection velocity profile during the injection molding.Because the value of injection velocity needs to change with the change of reference trajectory, the control accuracy of the controller is required to be higher. In this paper, we adopt the following fourth-order transfer function model [44] as our control model which is given by relating the valve opening to the injection ram velocity:
(1)Gs=ps+s1s+s2s+s32+s42,where p, s1, s2, s3, and s4 are configuration parameters that can be set according to different IMM systems. By transforming the above transfer function and discretizing the state equation with the zero-order preservation method, the dynamic model of the studied IMM system can be represented as the following discrete-time state equations:
(2)xk+1=Axk+Buk+Dξk,yk=Cxk,where A∈ℝnx×nx, B∈ℝnx×nu, C∈ℝny×nx, and D∈ℝnx×nξ are parameter matrices of the ram speed model in the IMM. xk∈ℝnx×1 is the state vector, yk∈ℝny×1 is the IMM injection speed measured by the sensor, uk∈ℝnu×1 is the controlling variable which is proportional to the input signal of the servo valve, ξk∈ℝnξ×1 is an uncorrelated random sequence representing the process noise, and k is the control time. In this paper, ξk is a Gaussian noise sequence with zero mean and random variance in the range of ϵ,σ2. In practice for the IMM, the future noise is difficult to predict; thus, we take the following discrete-time model as the control object:
(3)xk+1=Axk+Buk+Kξ^k,yk=Cxk,where ξ^k is introduced to describe the model errors along the time horizon k and K is the Kalman filter gain. In sampling time k, we take the error ξ^k=yk−Cxk. As indicated in [13], if the mathematical model is stable, the observer gain K could be regarded as D. The control objective of the model is to calculate a control trajectory u so that the controlled ram speed y follows the predetermined trajectory yref as much as possible and minimizes the error between them.


## 2.2. Initial State and Constraints

In the actual control process, the initial state of the injection molding is generally slightly different. Most of these differences are caused by external disturbances or noise. To simplify the calculation, we assume that there is no noise before the system works. The initial states in IMM at starting timek=0 are denoted as follows:
(4)S0=x0,y0,u0,where all the initial values of S0 are set 0. In the IMM, the ram velocity yk and the controlling variable uk are limited by the machine. Due to the actual physical limitation, yk and uk in equations (2) and (3) should satisfy the following bound constraints:
(5)0≤yk≤ymax,0≤uk≤umax,where ymax and umax are the given maximum constants of ram velocity and control variable. During the injection molding process, uk and yk need to meet the above constraints and change within this interval. Through combining the mathematical model (3) and constraints (5), then, we can apply the MPC method to ram speed control in IMM.


## 2.3. Objective Index

In this paper, our main goal is to control the ram velocity of the IMM system as quickly as possible to converge to the specified target value. In this work, we define the following objective index as the control target:(6)minukJ=∑k=1pyk−yrefkTQyk−yrefk+∑k=1nΔukTRΔuk,where yrefk, yk, and Δuk are the reference tracking output, output of the plant, and control input increment at the discrete time k, respectively. The control input increment satisfies Δuk=uk−uk−1. Q is the weight matrix of y, and R is the weight matrix of Δuk. The precise control of the dynamic model can finally be attained by minimizing the value of the loss function (8), and the ram velocity yk can also quickly converges to the stated target velocity yrefk.


## 3. Deep Learning-Based Predictive Control

In this section, we will introduce our proposed control strategy in three parts: model predictive control, dataset construction, and deep learning architecture design and optimization. First, we will introduce how to use MPC to solve the speed control problem. Second, we will introduce our design idea of the DL network and optimization strategies. Finally, we will introduce how to build an MPC-based dataset and connect the above two parts to form a closed loop.


### 3.1. Model Predictive Control

MPC is a dynamic optimization approach for determining the optimal control input and output trajectory. The optimality of the prediction vector can be achieved by solving optimization problems in the prediction and control time domains in a cyclical manner. The QP problem is a popular standard type in the MPC. In Figure3, we illustrate the schematic of the control process in the IMM based on the MPC strategy. By inputting a given reference value yref to the MPC controller, the controller optimally calculates the optimal control value uk at the next moment in combination with the current state variables. The key idea of linear MPC is to predict the trajectory of parameters in prediction horizon through the combination of the current state vector and the mathematical model. Based on MPC, the dynamic model (3) can be reformulated as follows:
(7)k+1=Axk+Buk+Kξ^k,xk+2=A2xk+ABuk+Buk+1+AKξ^k+Kξ^k+1,⋮xk+p=Apxk+Ap−1Buk+Ap−2Buk+1+⋯+Buk+p−1+Ap−1Kξ^k+Ap−2Kξ^k+1+⋯+Kξ^k+p−1,where p denotes the prediction horizon and n denotes the control horizon.Figure 3
Schematic of the control process in IMM based on MPC.Combining all the above formulas, we can get the following optimal control problem with constraints for the ram velocity control in IMMs as follows:(8)minukJ=∑k=1pyk−yrefkTQyk−yrefk+∑k=1nΔukTRΔuk,s.t.xk+1=Axk+Buk+Kξ^k,yk=Cxk,Δuk=uk−uk−1,0≤yk≤ymax,0≤uk≤umax,k=1,⋯,n.The MPC-based control sequenceuk,⋯,uk+n−1 over the predict horizon can be solved by solving the QP problem of the above optimization problem.Although MPC has many advantages compared to traditional control methods, such as higher control accuracy, faster response speed, and better control effects, which are based on a large number of optimized calculations, as the industrial control process becomes more and more complex, the complexity of the model used in MPC is also getting higher and higher, which undoubtedly increases the computational burden of the control process. This problem is particularly obvious in low computing performance devices such as embedded devices. A large number of matrix operations and memory usage in the MPC calculation process are unaffordable for the embedded devices widely used in the industry, so real-time control is hard to guarantee. This difficulty can be efficiently overcome with the advancement of deep learning. The DL-based MPC controller can greatly reduce the consumption of computing resources while achieving the MPC control function and realize the real-time control while ensuring the control accuracy and robustness. To address this problem in the injection molding prediction control process, we propose a DL-based MPC method to realize the real-time rapid control of the ram velocity.


### 3.2. Deep Learning

DL is a subset of a broader class of machine learning techniques that can be used to efficiently represent highly varying functions and help to extract abstract nonlinear features from data. It has gained popularity in recent years because of its success in resolving difficult problems that were previously unsolvable in the field of artificial intelligence [34, 36, 45, 46]. Many impressive applications have used DL architectures such as convolutional neural networks, deep belief networks, and deep reinforcement learning for supervised as well as unsupervised learning. Using the capabilities of the DL multilayer deep architecture, large labeled datasets can be learned and evaluated. DNNs with numerous layers of nonlinear hidden units and a big output layer can now be taught more successfully owing to advances in machine learning techniques and computer technology.In this paper, we combine the DL technique with the traditional MPC to produce high-performance predictive controllers that are simple in design and time efficient, while providing the concept of constraint satisfaction to ensure safety. We construct a GRU neural network to learn the optimal time series control process data produced by the traditional model predictive controller and replace the original model predictive controller, avoiding the complex calculations associated with the traditional optimization process and shortening the optimization solution calculation time. The real-time online control of an injection molding machine is thus achieved, based on assuring stability, robustness, and real time.


### 3.3. Deep Learning-Based Architecture Design and Optimization

In this section, we now propose a DL-based architecture design framework and investigate the impact of various network configurations in detail. The overall flowchart of our proposed DL-based MPC control strategy for the IMM is shown in Figure4, which mainly consists of two parts: offline controller design and training, online controller verification, and application. The former is mainly composed of four parts. We first select the control model, design the MPC controller for the mathematical model, and realize the closed-loop MPC control process simulation according to the MPC control theory. In the process of simulation, the state vector of the control process is collected and an offline dataset is formed, which is used for the subsequent training and tuning of the controller. The latter is to apply the trained controller to the model to verify and analyze its performance. Compared with the MPC controller, the DL-based controller is simpler in structure. The prediction results can be obtained through the forward calculation of the network during the control process, avoiding tedious optimization calculations.Figure 4
The flowchart of DL-based real-time MPC for IMM.In the framework of DL-based MPC strategy, the most important to-be-designed part is the DL neural network to learn the controller. To this end, we construct a GRU-based neural network to learn the optimal time series control process data produced by the traditional model predictive controller. The DL-based architecture design is mainly composed of the GRU module, sequence-to-sequence (Seq2Seq) module, and attention module, as shown in Figure5. The module consists of encoder and decoder parts, which are responsible for data acquisition and predicted output, respectively. As indicated in [47–49], the Seq2Seq architecture learns to encode variable-length sequences into fixed-length vector representations and to decode fixed-length vector representations back into variable-length sequences. In deep learning, especially in natural language processing, Seq2Seq networks are often used to solve tasks such as machine translation. In addition, the structure of Seq2Seq performs well in solving problems such as time series prediction [45] and sequence trajectory prediction [50]. This structure allows us to predict the next changes in the model by combining data from multiple past sampling times.Figure 5
DL-based architecture design.The encoder-decoder learning structure is composed of the GRU which is a popular scheme for learning dependency features of series data. The GRU is an LSTM variant with gating units that control information flow inside the unit but no discrete memory cells. For the learning of time series datasets with a huge amount of data, time series neural networks such as RNN and LSTM often have excellent performance [51, 52]. In comparison to LSTM, the GRU involves less calculation, making it easier for the controller to accomplish real-time control. he GRU consists of an update gate zk and a reset gate rk:
(9)hk=1−zk⊙hk−1+zk⊙h~k,h~k=tanhWhxk+Uhrk⊙hk−1,zk=σWzxk+Uzhk−1,rk=σWrxk+Urhk−1,where hk is the activation of the GRU unit at time k, h~k is the candidate activation, e is an element-wise multiplication, and σ is a logistic sigmoid function. Wh, Uh, Wz, Uz, Wr, and Ur are the GRU parameters which are all updated at each training step and stored. To compute the current output yk and the next activation hk, the GRU unit uses the previous activation hk−1 and the current state xk. To avoid vanishing gradients, the update gate zk determines how frequently the unit changes its activation or content. The reset gate rk forces the unit to read the first symbol in an input sequence, thus erasing the previously computed state.In our experiments, the total number of the network inputs is set as56, including the vector S=x,y,yref,uT of the past 6 sampling time, start, and end flags. The output of the GRU network is the predictive control calculation result, which relates to the control input of the next step. To enhance the performance of the network, the attention module is added to the Seq2Seq model. The module can help the network pay more attention to important information in the network input, thereby improving the network’s prediction accuracy. The mathematical formula of attention mechanism can be formulated as
(10)AttentionY,H=softmaxWVtanhWKSt−1,H,where Y and H are the predicted output and hidden state of the encoder, respectively. WK and WV are weight matrices which can be viewed as multiple single-layer neural networks.The mean square error (MSE) is chosen as the GRU neural network’s loss function, and its mathematical formulation is as follows:(11)Lossu^,uref=1n∑i=1nu∧i−urefi2,where n indicates the batch size in each training epoch, u^ is the predictive control of the network, and uref is the true optimal control according to the IMM control input which is obtain by MPC. The depth of the network structure is proportional to the network’s training pace. Although a deeper network structure can produce higher convergence results, the time required for training and forward computation increases proportionally and the shallow network performs worse. The architecture of the encoder is 6 hidden layers and that of decoder is 3 hidden layers. The decoder is followed by a single-layer neural network which outputs the prediction results.


### 3.4. Construction of Datasets

After designing the learning neural network, we need to consider how to build an efficient dataset to train and test our designed DL-based control network. In DL, the training of neural networks mainly relies on large amounts of data. Before designing the DL network and training the controller, we first need to collect data and cover the whole process of ram velocity and all the dynamics should be taken into account. There is a potential correlation between data and data at different sampling times during the injection molding process. In practice, the data that we obtain through the collector is time series data, which contains the mathematical relationship between different parameters. By evaluating the gathered data and determining the internal relationship between the input and output changes over time, we can develop a model to learn and predict the future value of the time series.In order to efficiently train the designed DL-based MPC controller, we get the data from 360 distinct runs, each of which lasts 1 second and includes 200 steps, resulting in 72000 data pairs. All the runs are under the same initial conditions but different in reference outputyrefk and Gaussian noise ξk. Each data pair includes state vector xk, output vector yk, reference output vector yrefk, and the predict control input vector uk+1 in the sampling time k. The hybrid approach should be able to train the planned network to follow the control rule generated by MPC and attain the required final predictive value, as we hope. The recursive online calculation method is no longer required once we have trained a sufficient number of the GRU for various guiding tasks, with the optimization phase being replaced by a GRU-trained controller.Furthermore, in order to enable the trained network to converge to a stable value faster and avoid the bad local optimal solution during the training process, we carry out a min-max normalization (12) technique for the collected data as follows:
(12)Xmin−max=X−XminXmax−Xmin.The min-max normalization can compress the dimension of the raw data to between 0 and 1, thereby enhancing the identifiability of the data and improving the prediction accuracy of the network. It can be seen in Figure6 that the distribution of various unprocessed data is different, and the range of data size is not concentrated, so that the training process network will be more inclined to fit parameters with larger values. The data preprocessing method provided by min-max normalization can solve this problem well. Figure 7 shows the results of network training using raw and min-max data. The experimental results show that this method can make the network converge to stability more quickly.Figure 6
The distribution of dataset. (a–c) The distribution of original data and (d–f) the distribution of normalized data.
(a)(b)(c)(d)(e)(f)Figure 7
Raw and min-max data for network training.
(a)(b)


## 3.1. Model Predictive Control

MPC is a dynamic optimization approach for determining the optimal control input and output trajectory. The optimality of the prediction vector can be achieved by solving optimization problems in the prediction and control time domains in a cyclical manner. The QP problem is a popular standard type in the MPC. In Figure3, we illustrate the schematic of the control process in the IMM based on the MPC strategy. By inputting a given reference value yref to the MPC controller, the controller optimally calculates the optimal control value uk at the next moment in combination with the current state variables. The key idea of linear MPC is to predict the trajectory of parameters in prediction horizon through the combination of the current state vector and the mathematical model. Based on MPC, the dynamic model (3) can be reformulated as follows:
(7)k+1=Axk+Buk+Kξ^k,xk+2=A2xk+ABuk+Buk+1+AKξ^k+Kξ^k+1,⋮xk+p=Apxk+Ap−1Buk+Ap−2Buk+1+⋯+Buk+p−1+Ap−1Kξ^k+Ap−2Kξ^k+1+⋯+Kξ^k+p−1,where p denotes the prediction horizon and n denotes the control horizon.Figure 3
Schematic of the control process in IMM based on MPC.Combining all the above formulas, we can get the following optimal control problem with constraints for the ram velocity control in IMMs as follows:(8)minukJ=∑k=1pyk−yrefkTQyk−yrefk+∑k=1nΔukTRΔuk,s.t.xk+1=Axk+Buk+Kξ^k,yk=Cxk,Δuk=uk−uk−1,0≤yk≤ymax,0≤uk≤umax,k=1,⋯,n.The MPC-based control sequenceuk,⋯,uk+n−1 over the predict horizon can be solved by solving the QP problem of the above optimization problem.Although MPC has many advantages compared to traditional control methods, such as higher control accuracy, faster response speed, and better control effects, which are based on a large number of optimized calculations, as the industrial control process becomes more and more complex, the complexity of the model used in MPC is also getting higher and higher, which undoubtedly increases the computational burden of the control process. This problem is particularly obvious in low computing performance devices such as embedded devices. A large number of matrix operations and memory usage in the MPC calculation process are unaffordable for the embedded devices widely used in the industry, so real-time control is hard to guarantee. This difficulty can be efficiently overcome with the advancement of deep learning. The DL-based MPC controller can greatly reduce the consumption of computing resources while achieving the MPC control function and realize the real-time control while ensuring the control accuracy and robustness. To address this problem in the injection molding prediction control process, we propose a DL-based MPC method to realize the real-time rapid control of the ram velocity.


## 3.2. Deep Learning

DL is a subset of a broader class of machine learning techniques that can be used to efficiently represent highly varying functions and help to extract abstract nonlinear features from data. It has gained popularity in recent years because of its success in resolving difficult problems that were previously unsolvable in the field of artificial intelligence [34, 36, 45, 46]. Many impressive applications have used DL architectures such as convolutional neural networks, deep belief networks, and deep reinforcement learning for supervised as well as unsupervised learning. Using the capabilities of the DL multilayer deep architecture, large labeled datasets can be learned and evaluated. DNNs with numerous layers of nonlinear hidden units and a big output layer can now be taught more successfully owing to advances in machine learning techniques and computer technology.In this paper, we combine the DL technique with the traditional MPC to produce high-performance predictive controllers that are simple in design and time efficient, while providing the concept of constraint satisfaction to ensure safety. We construct a GRU neural network to learn the optimal time series control process data produced by the traditional model predictive controller and replace the original model predictive controller, avoiding the complex calculations associated with the traditional optimization process and shortening the optimization solution calculation time. The real-time online control of an injection molding machine is thus achieved, based on assuring stability, robustness, and real time.


## 3.3. Deep Learning-Based Architecture Design and Optimization

In this section, we now propose a DL-based architecture design framework and investigate the impact of various network configurations in detail. The overall flowchart of our proposed DL-based MPC control strategy for the IMM is shown in Figure4, which mainly consists of two parts: offline controller design and training, online controller verification, and application. The former is mainly composed of four parts. We first select the control model, design the MPC controller for the mathematical model, and realize the closed-loop MPC control process simulation according to the MPC control theory. In the process of simulation, the state vector of the control process is collected and an offline dataset is formed, which is used for the subsequent training and tuning of the controller. The latter is to apply the trained controller to the model to verify and analyze its performance. Compared with the MPC controller, the DL-based controller is simpler in structure. The prediction results can be obtained through the forward calculation of the network during the control process, avoiding tedious optimization calculations.Figure 4
The flowchart of DL-based real-time MPC for IMM.In the framework of DL-based MPC strategy, the most important to-be-designed part is the DL neural network to learn the controller. To this end, we construct a GRU-based neural network to learn the optimal time series control process data produced by the traditional model predictive controller. The DL-based architecture design is mainly composed of the GRU module, sequence-to-sequence (Seq2Seq) module, and attention module, as shown in Figure5. The module consists of encoder and decoder parts, which are responsible for data acquisition and predicted output, respectively. As indicated in [47–49], the Seq2Seq architecture learns to encode variable-length sequences into fixed-length vector representations and to decode fixed-length vector representations back into variable-length sequences. In deep learning, especially in natural language processing, Seq2Seq networks are often used to solve tasks such as machine translation. In addition, the structure of Seq2Seq performs well in solving problems such as time series prediction [45] and sequence trajectory prediction [50]. This structure allows us to predict the next changes in the model by combining data from multiple past sampling times.Figure 5
DL-based architecture design.The encoder-decoder learning structure is composed of the GRU which is a popular scheme for learning dependency features of series data. The GRU is an LSTM variant with gating units that control information flow inside the unit but no discrete memory cells. For the learning of time series datasets with a huge amount of data, time series neural networks such as RNN and LSTM often have excellent performance [51, 52]. In comparison to LSTM, the GRU involves less calculation, making it easier for the controller to accomplish real-time control. he GRU consists of an update gate zk and a reset gate rk:
(9)hk=1−zk⊙hk−1+zk⊙h~k,h~k=tanhWhxk+Uhrk⊙hk−1,zk=σWzxk+Uzhk−1,rk=σWrxk+Urhk−1,where hk is the activation of the GRU unit at time k, h~k is the candidate activation, e is an element-wise multiplication, and σ is a logistic sigmoid function. Wh, Uh, Wz, Uz, Wr, and Ur are the GRU parameters which are all updated at each training step and stored. To compute the current output yk and the next activation hk, the GRU unit uses the previous activation hk−1 and the current state xk. To avoid vanishing gradients, the update gate zk determines how frequently the unit changes its activation or content. The reset gate rk forces the unit to read the first symbol in an input sequence, thus erasing the previously computed state.In our experiments, the total number of the network inputs is set as56, including the vector S=x,y,yref,uT of the past 6 sampling time, start, and end flags. The output of the GRU network is the predictive control calculation result, which relates to the control input of the next step. To enhance the performance of the network, the attention module is added to the Seq2Seq model. The module can help the network pay more attention to important information in the network input, thereby improving the network’s prediction accuracy. The mathematical formula of attention mechanism can be formulated as
(10)AttentionY,H=softmaxWVtanhWKSt−1,H,where Y and H are the predicted output and hidden state of the encoder, respectively. WK and WV are weight matrices which can be viewed as multiple single-layer neural networks.The mean square error (MSE) is chosen as the GRU neural network’s loss function, and its mathematical formulation is as follows:(11)Lossu^,uref=1n∑i=1nu∧i−urefi2,where n indicates the batch size in each training epoch, u^ is the predictive control of the network, and uref is the true optimal control according to the IMM control input which is obtain by MPC. The depth of the network structure is proportional to the network’s training pace. Although a deeper network structure can produce higher convergence results, the time required for training and forward computation increases proportionally and the shallow network performs worse. The architecture of the encoder is 6 hidden layers and that of decoder is 3 hidden layers. The decoder is followed by a single-layer neural network which outputs the prediction results.


## 3.4. Construction of Datasets

After designing the learning neural network, we need to consider how to build an efficient dataset to train and test our designed DL-based control network. In DL, the training of neural networks mainly relies on large amounts of data. Before designing the DL network and training the controller, we first need to collect data and cover the whole process of ram velocity and all the dynamics should be taken into account. There is a potential correlation between data and data at different sampling times during the injection molding process. In practice, the data that we obtain through the collector is time series data, which contains the mathematical relationship between different parameters. By evaluating the gathered data and determining the internal relationship between the input and output changes over time, we can develop a model to learn and predict the future value of the time series.In order to efficiently train the designed DL-based MPC controller, we get the data from 360 distinct runs, each of which lasts 1 second and includes 200 steps, resulting in 72000 data pairs. All the runs are under the same initial conditions but different in reference outputyrefk and Gaussian noise ξk. Each data pair includes state vector xk, output vector yk, reference output vector yrefk, and the predict control input vector uk+1 in the sampling time k. The hybrid approach should be able to train the planned network to follow the control rule generated by MPC and attain the required final predictive value, as we hope. The recursive online calculation method is no longer required once we have trained a sufficient number of the GRU for various guiding tasks, with the optimization phase being replaced by a GRU-trained controller.Furthermore, in order to enable the trained network to converge to a stable value faster and avoid the bad local optimal solution during the training process, we carry out a min-max normalization (12) technique for the collected data as follows:
(12)Xmin−max=X−XminXmax−Xmin.The min-max normalization can compress the dimension of the raw data to between 0 and 1, thereby enhancing the identifiability of the data and improving the prediction accuracy of the network. It can be seen in Figure6 that the distribution of various unprocessed data is different, and the range of data size is not concentrated, so that the training process network will be more inclined to fit parameters with larger values. The data preprocessing method provided by min-max normalization can solve this problem well. Figure 7 shows the results of network training using raw and min-max data. The experimental results show that this method can make the network converge to stability more quickly.Figure 6
The distribution of dataset. (a–c) The distribution of original data and (d–f) the distribution of normalized data.
(a)(b)(c)(d)(e)(f)Figure 7
Raw and min-max data for network training.
(a)(b)


## 4. Numerical Experiments

The simulation and experimental findings are reported in this part to validate the efficacy of our suggested DL-based control approach. The simulations are run using MATLAB/PyTorch systems, which are powered by an Intel Core i7-8700 processor and 16 GB of RAM. We use 90% of the collected dataset for training and the remaining 10% as the validation set. In our experiments, the encoder and decoder are composed of 6 GRU units and 3 GRU units, respectively, and the hidden state of seq2seq is 5 dimensions. The learning rate and batch size are0.001 and 64, respectively. The Adam algorithm is used for the neural network optimization, while the ReLU function is used as the activation function. In Figure 8, we show the effect of ReLU, Sigmoid, and tanh functions in the network structure. The results show that the ReLU-based network can converge faster than other commonly used activation functions. Figure 9 shows the training and evaluation errors for the network in 100 epochs, and the errors between them are very small that no overfitting occurs. The network parameters with the lowest MSE during training and verification will be preserved as the best once each round of training is finished and compared to the prior results. Table 1 shows the best results of the training after 100 epochs. The training and verification MSE of the final trained network are basically the same and less than 10−3.Figure 8
Effect of different activation functions on the network.
(a)(b)Figure 9
Training and validation loss in 100 epochs.
(a)(b)Table 1
Training statistics.
ScenarioAmount of dataMSETraining648004.19×10−6Validation72005.88×10−6In our experimental simulations, we acquire the simulation running process of different approaches under the same conditions by utilizing different controllers to control the IMM model. In order to further compare the performance of different controllers, we also designed the injection molding simulations based on the widely adopted PID controller. Figure8 shows the results for 200 steps using an MPC controller, the proposed DL-based controller, and PID controller. As shown in Figure 10, Figure 10(a) is the trajectory of model prediction input u calculated by MPC, DL-based controller, and PID controller and Figure 10(b) is the trajectory of noise ξ, reference yref, and plant output y corresponding different controllers of u. When the noise ξ is 0, the DL-based controller perfectly reproduces the control process of the MPC controller and PID-based controller. For further comparison, we also generate two sets of running results Figures 10(c)–10(f) under different noise conditions, which have the same conditions but different in noises which variances Z=0.1,0.5. The results show that the proposed DL-based controller can achieve more comparable performance than the MPC and PID controllers at each sample time. The ram speed y curves under the network and MPC techniques are nearly identical, implying that when the reference yref changes, the GRU network makes the best decision. Even in the comparison with the PID method, the deep learning method still shows the same or better performance than PID. Moreover, the proposed method does not need to adjust the control parameters. Even in the presence of external interference, the DL-based MPC controller can still track the reference well and the effect is basically the same as that of the MPC controller. However, limited by the MPC strategy that we used, when the reference ram velocity reaches the maximum value with noise, the control curve will fluctuate greatly in order to make the controlled speed change within the constrained range as much as possible.Figure 10
The control process of different controllers under the same conditions. (a–f) The predictive inputu and plant output y under the control of MPC, designed network, and PID from 0 to 1 s. (a, c, and e) The trajectories of u, and (b, d, and f) the trajectories of the reference output yref, noise ξ, and plant output y.
(a)(b)(c)(d)(e)(f)Figure11 shows the control process of ram velocity in noiseless and noisy conditions under the constraints. When y is close to the boundary constraint, the network is prone to receive noise interference and frequent fluctuations. Limited by the training data of the model, the training of the network may have the problem of overfitting. We have also taken some measures to address this problem. The first is to expand the coverage of training data to ensure that it can cover most IMM changes. Secondly, one of the important reasons for overfitting is often the high complexity and depth of the model. Compressing the size of the model and reducing the complexity of the network can generally alleviate this problem. Finally, we can reduce the training times of the network and select the best model weight in 100 iterations.Figure 11
Constrained control process. (a, b) The trajectories of controlu and output y when the reference yref touches the constraint boundary without noise, while (c, d) are the corresponding trajectories under the noise ξ.
(a)(b)(c)(d)Table2 illustrates the average tracking error of the two controllers over the course of 30 simulation runs, demonstrating that they have almost identical control capabilities under identical initial conditions and random disturbances. We take the curve of the MPC controller control output as a reference and calculate the average tracking error between the curve under the designed controller and the reference. A very small error is obtained for the proposed DL-based MPC. The computation time for each iteration is considerably decreased from 4.677 ms to 1.691 ms, and the MSE loss is near zero, as shown in Table 2. This finding demonstrates that the DL-based MPC controller has predictive control capabilities comparable to the MPC controller. The current system state predicts the optimal value of the control input at the next moment. The errors mainly appear in the zones that the ram velocity changes. It can be concluded that the controller that we designed basically has the same control performance and robustness as the MPC controller and it consumes less time. In addition, we also made a comparative experiment on the network that contains the attention mechanism and the network that does not contain this mechanism. Under the same conditions, the training MSE of the GRU network without an attention mechanism is 0.000388 and the run time is 1.02 ms. Obviously, compared to the increase in time consumption, the attention mechanism greatly improves the prediction accuracy of the network. The mechanism not only greatly improves the performance of deep neural networks for text or images but is also effective for data-driven control tasks. The key advantage of this DL-based method over the typical MPC-based IMM control method is that it is very simple to construct and calculate, with the highest time consumption coming from the forwarding calculation of the designed network. This unquestionably reduces the control process’s computation time and lowers the MPC method’s equipment threshold.Table 2
Average tracking error and run time results of proposed DL-MPC and MPC.
ControllerTracking errorRun time (ms)MPC04.677DL-based MPC0.0061.691


## 5. Conclusions

This paper proposes an effective control strategy with minimal computational efforts for real-time implementation based on the DL technique to approximate the classic MPC strategy to deal with the optimal tracking control of the injection speed in a typical IMM. The system operating data obtained by the classic MPC strategy of the injection speed for the IMM are collected and then used to train the designed network. The trained learning-based controller can output corresponding predictive control results according to the real-time sampled states of the IMM system. Numerical simulation results show that the proposed method is feasible and requires less computational time than the traditional predictive control method. While ensuring the accuracy of predictive control, this method can complete the complex control task of the IMM system well and output the predictive control results quickly, which meets the real-time requirement. With a considerably lower memory footprint and faster calculation time, it can be also implemented in embedded hardware much more efficiently and simply.In the following work, we will continue to study the DL-based predictive control methods and further improve the experimental methods in this paper, such as considering the impact of the dataset size on the network learning efficiency, comparing the effects of different activation functions and standardized methods, etc. In addition, the proposed method will be applied to more complex injection molding systems combined with such as network compression, network pruning, and other methods, to achieve more efficient real-time predictive control. Note that although the method proposed in this paper mainly focuses on numerical simulation and realization, it is a first and a pretty preliminary attempt at the intelligent control of the injection molding process manufacturing area. In addition, the numerical method and experiment presented in this paper also have a positive role in guiding the subsequent practical experiments. We are also now building a real experimental platform and are trying to implement the proposed strategy for lab-on-chip, and the experimental work is still in progress.



---

*Source: 7662264-2022-11-15.xml*