Balance control method and system for amplitude and flow of regulating valve for chemical plant

Through the bidirectional Seq-Bi-GRU recurrent neural network and encoder-decoder architecture, combined with the ECA attention mechanism, the problem of inequality of the neural network model combined with the PID controller is solved, and the multi-branch traffic is achieved Efficient and flexible control of the control system.

CN119310831APending Publication Date: 2025-01-14SUZHOU KEBANG AUTOMATIC CONTROL VALVE IND CO LTD

Patent Information

Application Number
CN202411854746.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-17
Publication Date
2025-01-14

AI Technical Summary

Technical Problem

In the prior art, the neural network model combined with the PID controller has the problem of integral saturation and the problem of inequality input and output sequences in the multi-branch flow control system, which limits the flexibility and adaptability of the system.

Method used

Using a bidirectional Seq-Bi-GRU recurrent neural network combined with the encoder-decoder architecture and ECA attention mechanism, the error threshold and saturation threshold are dynamically calculated, and the prediction error is optimized through the least squares method, supporting the inequality of input and output sequences, and introducing prediction Compensation mechanism to improve control accuracy.

Benefits of technology

It effectively avoids integral saturation, improves the performance of the PID controller and the adaptability of the system, and enhances the robustness and adaptability of complex multi-branch flow control systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119310831A_ABST
    Figure CN119310831A_ABST
Patent Text Reader

Abstract

The invention discloses a balance control method and system for amplitude and flow of a regulating valve for a chemical plant. The invention relates to the technical field of regulating valves. Calculating an error E between the target value O and the feedback value F: E = O-F; then, each PID controller i calculates an initial electric signal ei (t); each PID controller activates a bidirectional Seq-Bi-GRU recurrent neural network, executes a regression task based on the data set D of historical errors and the error E as input, and outputs an error threshold T1 for each PID controller, which is used for judging whether to activate the integral action of the PID controller or not; by introducing the bidirectional Seq-Bi-GRU recurrent neural network, the error threshold T1 and the saturation threshold T2 can be dynamically calculated based on the historical error data set and the current error. According to the dynamic adjusting mechanism, the integral action of the PID controller can be flexibly activated or closed according to the actual situation, and the integral saturation phenomenon of the multi-branch flow conveying system is effectively avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of regulating valves, and in particular to multi-branch flow control of regulating valves, and more particularly to a method and system for balancing amplitude and flow of regulating valves used in chemical plants. Background Art

[0002] Multi-branch flow control technology, particularly in applications such as chemical plant gas distribution systems and multi-branch pressure regulating stations, creates a complex network consisting of several parallel branches, each of which is interdependent and dynamically interconnected. This systemic nature dictates that flow fluctuations in a single branch inevitably trigger a chain reaction of flow and amplitude fluctuations in the remaining branches, highlighting the importance of precisely controlling the flow and amplitude of each branch to meet predetermined delivery targets.

[0003] If there is a lack of an effective control mechanism, not only will individual branches be overloaded, leading to equipment damage and overall system failure (i.e., system imbalance), but long-term unbalanced working conditions may also accelerate system aging and shorten the overall service life. To address this technical problem, many existing technologies have proposed different solutions:

[0004] (1) CN201810138603.6 discloses a multi-way valve device with intelligent flow control (publication date ), by presetting the elastic force curve, the displacement of the main valve core in the main valve body is controlled, reducing external interference factors; CN202210811284.7 discloses a digital multi-way valve working interface with intelligent control (publication date ), by reading the pressure sensor and subtracting it, the pressure difference is obtained and the valve core opening is calculated according to the flow calculation formula or table, and then the feedback system is closed to obtain the precise displacement point of the valve core;

[0005] Both of the above-mentioned existing technologies belong to closed-loop control strategies. Although they enhance the stability of the system, their static characteristics limit flexibility and adaptability when facing dynamically changing environmental conditions.

[0006] (2) The literature "Wei Liejiang, Zhao Baocai, Sun Hui, et al. Flow-pressure composite control method of independent throttle valve based on BP neural network [J]. Hydraulics and Pneumatics, 2023, 47(08): 58-65." The flow-pressure composite control strategy based on BP neural network PID can approximate the characteristics of any nonlinear function by using the BP neural network algorithm, and adjust the parameter value of the PID controller in real time to control the valve core opening. The literature "Zhang Wentao, Zhao Dongya, Zhang Shuzhan. Research on DE-RBF neural network adaptive control method of pressure-driven auxiliary agent flow [C] / / Process Control Professional Committee of the Chinese Automation Society, Chinese Automation Society. Proceedings of the 35th China Process Control Conference. China University of Petroleum (East China) Shidashan Energy New Energy College; 2024: 1." The flow control method (DE-RBF-PID control) that combines differential evolution (DE) algorithm with RBF neural network PID control parameter adaptive tuning adjusts the parameter value of the PID controller in real time to control the valve core opening;

[0007] Both of the above-mentioned neural network models can perform corresponding prediction tasks based on the actual detected dependent variables (the flow rate and amplitude of each pipeline in the multi-branch flow transmission system) to control the independent variables (the opening of each regulating valve in the multi-branch flow transmission system). However, both methods can predict and adjust the independent variables through real-time monitoring of the dependent variables, but both face the problem of integral saturation of the PID controller, that is, when the output reaches the limit, it is easy to cause system overshoot and distortion (this is a common problem of PID controller algorithms).

[0008] Furthermore, BP or RBF neural network models do not support the problem of unequal lengths of input and output sequences, which can lead to insufficient model training or inaccurate predictions, thus affecting the accuracy and robustness of control effects. This limitation limits the effectiveness and flexibility of the model when dealing with complex, time-varying, multi-branch flow control systems.

[0009] Therefore, a method and system for balancing the amplitude and flow rate of regulating valves used in chemical plants are proposed. Summary of the Invention

[0010] In view of this, the embodiments of the present invention are intended to provide a method and system for balancing the amplitude and flow rate of a regulating valve for a chemical plant, so as to solve or alleviate the technical problems existing in the prior art, namely:

[0011] (1) How to solve the problem of integral saturation caused by combining traditional neural network models with PID controllers;

[0012] (2) How to make the neural network model combined with the PID controller support the situation where the input and output sequences are of unequal length.

[0013] The technical solution of the present invention is achieved as follows:

[0014] First, the balance control method of the amplitude and flow of the regulating valve used in chemical plants:

[0015] (I) Overview:

[0016] The present invention aims to solve the above-mentioned technical problems. By combining traditional PID control with advanced neural network algorithms, dynamic optimization of PID controller parameters is achieved. Based on the bidirectional Seq-Bi-GRU recurrent neural network characterized by the present invention, the error threshold T1 and saturation threshold T2 are dynamically calculated based on historical error data and current error through an encoder-decoder architecture and an ECA attention mechanism. These two thresholds are used to determine whether to activate the integral action of the PID controller and to prevent integral saturation, respectively. The output of the neural network is also optimized by a prediction compensation mechanism, minimizing the residual sum of squares by the least squares method, and using historical prediction errors to improve the accuracy of the current prediction. Finally, based on the calculated threshold, the output electrical signal of the PID controller is constrained and optimized to improve the control performance. By integrating classical control theory with modern intelligent algorithms, intelligent adjustment of PID controller parameters is achieved, and the adaptability and robustness of the control system are improved.

[0017] (2) Technical solution:

[0018] To achieve the above technical objectives, assume that each pipeline or pipeline group has a corresponding discretized PID controller i, read the target value O=[f,a] (where f is the ideal flow value and a is the ideal amplitude value) of the pipeline as the ideal flow and ideal amplitude, and the feedback value F=[f',a'] (where f' is the actual flow value and a' is the actual amplitude value) of the pipeline actual flow and actual amplitude as the input of the PID controller, and then perform the following steps S1 to S3.

[0019] 2.1 Step S1, electrical signal calculation:

[0020] In step S1, the first task is to quantify the difference between the target value O and the feedback value F. First, the error E between the target value O and the feedback value F is calculated: E = |OF|, which reflects the degree of deviation between the current system state and the target state. Then, the discretized PID controller i corresponding to each pipeline calculates the initial electrical signal e for controlling the opening of the regulating valve. i (t):

[0021] ;

[0022] Among them, K p is the proportionality coefficient, K i is the integration coefficient, K d is the differential coefficient. Represents the cumulative sum of errors from time k=0 to the current time t. Ep Represents the error at the previous time step.

[0023] The above-described discretized PID controller incorporates time discretization considerations, ensuring the effective implementation of the control strategy in the digital system. Through step S1, each PID controller i can accurately calculate the electrical signal used to adjust the pipeline flow and amplitude based on real-time feedback and target settings, laying a solid foundation for subsequent control actions.

[0024] 2.2 Step S2, neural network operation:

[0025] Each PID controller activates a bidirectional Seq-Bi-GRU recurrent neural network, which performs a regression task based on the historical error dataset D and error E as input, and outputs an error threshold T1 for each PID controller i to determine whether to activate the integral action, as well as a saturation threshold T2 for preventing integral saturation (achieved by adjusting the step value S of the integral term).

[0026] The so-called bidirectional Seq-Bi-GRU recurrent neural network introduces the Seq2Seq model to the traditional bidirectional Bi-GRU recurrent neural network. The characteristic of this model is that it can split the input and output sequences into independent encoding and decoding layers for processing, allowing the model to flexibly cope with situations where the input and output sequence lengths are inconsistent. At the same time, the "bidirectional Bi-GRU recurrent neural network" included in the bidirectional Seq-Bi-GRU recurrent neural network, by virtue of its ability to simultaneously capture both forward and reverse dependencies in time series data, significantly improves the accuracy and robustness of the model when processing dynamic data, and enhances the accuracy and robustness of the model's dynamic calculation error threshold T1 and saturation threshold T2.

[0027] The above-mentioned method for executing the bidirectional Seq-Bi-GRU recurrent neural network includes the following steps S200 to S202:

[0028] 2.2.1 Step S200, execute the encoder:

[0029] The encoder receives an input sequence S = {D, E}, where D is a dataset of historical errors and E is the error calculated by the current PID controller. The encoder's core task is to deeply explore the temporal dependencies in the input sequence S through a bidirectional Bi-GRU network and ultimately output a hidden state sequence H containing rich features. The method includes:

[0030] S2000, initialize the forward hidden state and the backward hidden state , that is, setting both to zero vectors. This initialization step provides a starting point for subsequent Bi-GRU calculations: ;

[0031] S2001, forming a hidden state sequence H: extracting the dependency relationship in the input sequence S from both the forward and backward directions through the bidirectional Bi-GRU network; the specific operation method is as follows: for each element s in the input sequence S t , do the following:

[0032] S20010, forward Bi-GRU update:

[0033] (1) Calculate the forward update gate The activation value of

[0034] (2) Calculate the forward reset gate The activation value of

[0035] (3) Calculate the forward candidate hidden state ;

[0036] (4) Update the forward hidden state ;

[0037] S20011, backward Bi-GRU update:

[0038] Similarly, for each element s in the input sequence S t , the update process of the backward Bi-GRU is as follows:

[0039] (1) Calculate the backward update gate The activation value of

[0040] (2) Calculate the backward reset gate The activation value of

[0041] (3) Calculate the backward candidate hidden state ;

[0042] (4) Update the backward hidden state ;

[0043] S20012, after the forward and backward Bi-GRU updates, the hidden state of each time step can be obtained. The hidden state sequence H finally output by the encoder is:

[0044] ;

[0045] in, represents the i-th hidden state in the input sequence S, is the forward hidden state, is the backward hidden state.

[0046] 2.2.2 Step S201: Start the ECA attention mechanism (Encoder-Decoder Attention):

[0047] During the decoding process, in order to enable the decoder to more effectively utilize the information output by the encoder, this paper introduces the ECA (Encoder-Decoder Attention) attention mechanism. This mechanism allows the decoder to dynamically pay attention to all the hidden states of the encoder output when generating each output, and generates an intermediate vector C that is closely related to the current encoder decoding step by weighted summation of these hidden states. This intermediate vector C not only contains the global information of the encoder hidden state sequence H, but also places special emphasis on the information related to the current decoder state s. i−1 The most relevant part, the specific method is:

[0048] For the i-th time step of the decoder, we first calculate the encoder hidden state sequence H={h1,h2,...,h| S Each hidden state h in |} j The attention weight α ij These attention weights α ij reflects the degree of attention paid by the current decoding step to each hidden state of the encoder. Then, using these attention weights α ij Perform weighted summation on the hidden states to obtain the intermediate vector C i (i=1,2,...,S, where S represents the length of the input sequence S): ;

[0049] Among them, the attention weight α ij Calculated by the softmax function: ;

[0050] Among them, e ij It represents the degree of attention paid by the decoder to the jth hidden state of the encoder at the i-th time step, which is also the energy function of the attention mechanism.

[0051] 2.2.3 Step S202, Decoder Processing:

[0052] In the decoding stage, combined with the intermediate vector C and the hidden state of the previous time step and , and the prediction result y of the decoder at the previous time step t−1 , through the bidirectional Bi-GRU network to gradually generate the prediction result y t =[T1, T2]. The following are the detailed steps of the process:

[0053] S2020, calculate the input x of the current time stept :The prediction result y of the previous time step t−1 Splice with the intermediate vector C to form the input x of the current time step t :x t =[y t-1 ;C];

[0054] S2021, calculate the hidden state h of the current time step through the Bi-GRU network t ,include:

[0055] S20210, Forward GRU Calculation: Use the forward GRU to calculate the forward hidden state of the current time step. Including calculating the update gate , Reset Gate , candidate hidden states , and the final forward hidden state ;

[0056] S20211, Backward GRU calculation: Similarly, use the backward GRU to calculate the backward hidden state of the current time step. Including the update gate of the backward GRU , Reset Gate , candidate hidden states and the final hidden state ; Note that this step uses the hidden state h of the next time step t+1 (In actual calculations, this needs to be obtained through a reverse process);

[0057] S20212, concatenate the final hidden states of the forward and backward GRU to form the final hidden state h of the current time step t : ;

[0058] S2022, calculate input o t : Using a learnable weight matrix W o and the bias vector b o , the final hidden state h t Mapped to the input o of the output layer t :o t =W o h t +b o ;

[0059] S2023, apply the sigmoid activation function σ to get the predicted output : ;

[0060] S2024, calculate the error threshold T1 and the saturation threshold T2:

[0061] ;

[0062] ;

[0063] Where t1 and t2 are intermediate variables for calculating the error threshold T1 and the saturation threshold T2, which are obtained through linear transformation. T1' and T2' are the initial error threshold and the initial saturation threshold, respectively.

[0064] S20240, execute the prediction compensation mechanism: that is, for the initial error threshold T1' and the initial saturation threshold T2' calculated for the current prediction task, minimize the residual square sum S by the least square method to obtain the error feedback coefficient β i , and the historical prediction error of certain data is reviewed to compensate. The compensated error threshold T1 and saturation threshold T2 are formed; the error feedback coefficient β i It can help the neural network "remember" and "correct" past prediction errors, thereby improving the accuracy of current predictions.

[0065] S20241, calculate the residual sum of squares S: the actual value y composed of the previous n error thresholds T1 and saturation thresholds T2 i The historical data points, and the predicted value composed of the first n initial error threshold T1' and initial saturation threshold T2' Calculate the residual sum of squares S for the historical data points: ;

[0066] S20242, obtain the error feedback coefficient β i : In order to use historical forecast errors to improve current forecasts, the error feedback coefficient β is introduced i This coefficient is solved by the least square method to make the predicted value after compensation closer to the actual value. Let ϵ i =y i −y i 'For the historical forecast error, build a linear model to represent the forecast value after compensation: ;

[0067] in, is the predicted value after compensation, a i−1 is the prediction error of the previous data point. In order to solve β i , substitute the above model into the expression of residual sum of squares, and i Take the derivative and set it equal to 0 to find the β that minimizes the residual sum of squares S i The minimum β is obtained. i After the value is obtained, it can be used to obtain the compensated error threshold T1 and saturation threshold T2:

[0068] T1=T1'+β iΔT1';

[0069] T2=T2'+β i ΔT2';

[0070] Where ΔT1' and ΔT2' are adjustments related to historical forecast errors. In this way, the system can remember and correct past forecast errors, thereby improving the accuracy of current forecasts.

[0071] 2.3 Step S3, introduce constraints:

[0072] Based on the error threshold T1 and the saturation threshold T2, the following constraints are introduced into the discretized PID controller, and the final electrical signal e is updated. i (t)'. The initial electrical signal e i (t) Updated to the final electrical signal e for controlling the opening of the regulating valve i (t)', that is, the original PID controller form is updated to:

[0073] ;

[0074] Where I is a flag that indicates whether the PID integral action (i.e., integral term) is activated. When |e(t)| ≥ T1, the integral action is activated and I is set to 1; otherwise, the integral action is not activated and I is set to 0. When the absolute value of the error signal is greater than or equal to the saturation threshold T2, the step value V is set to a fixed value ΔV fixation , to prevent integral saturation; otherwise, accumulation is performed according to the normal accumulation step value ΔV; through this method, the accumulation step value of the integral term can be dynamically adjusted according to the size of the error signal to prevent integral saturation and improve the performance of the PID controller.

[0075] (3) Mechanism for resolving technical issues:

[0076] 3.1 How to solve the problem of integral saturation caused by traditional neural network model combined with PID controller:

[0077] Integral windup is a common problem when traditional neural network models are combined with PID controllers. This problem occurs primarily because the integral term accumulates when error persists, causing the controller output to exceed limits. This solution, however, utilizes a bidirectional Seq-Bi-GRU recurrent neural network to dynamically calculate the error threshold T1 and saturation threshold T2 based on a historical error dataset and the current error. Error threshold T1 determines whether to activate the PID controller's integral action. The integral action is activated when the absolute value of the error is greater than or equal to T1. Saturation threshold T2 prevents integral windup. When the absolute value of the error is greater than or equal to T2, the integral term's cumulative step value is set to a fixed value to limit its growth. In the PID controller's integral term, the cumulative step value is dynamically adjusted based on the magnitude of the error signal. When the absolute value of the error is less than the saturation threshold T2, the integral term is accumulated at the normal step value. When the absolute value of the error is greater than or equal to the saturation threshold T2, the cumulative step value is set to a smaller fixed value to prevent integral windup.

[0078] 3.2 How to make the neural network model combined with the PID controller support the situation where the input and output sequences are of unequal lengths:

[0079] When combining traditional PID controllers with neural networks, the input and output sequences are usually required to be of equal length. However, this solution supports input and output sequences of unequal lengths by introducing a Seq2Seq model and a bidirectional Bi-GRU recurrent neural network:

[0080] The Seq2Seq model splits input and output processing into two layers: the encoding layer and the decoding layer, thus supporting unequal input and output lengths. In the encoding layer, a bidirectional Bi-GRU network extracts dependencies within the input sequence, forming a hidden state sequence. In the decoding layer, the hidden state sequence is combined with the decoder output from the previous time step to gradually generate predictions.

[0081] The bidirectional Bi-GRU network simultaneously captures both forward and backward dependencies in time series data, improving the accuracy and robustness of the model's dynamic calculation of the error threshold T1 and saturation threshold T2. In the encoder, the forward Bi-GRU and backward Bi-GRU extract dependencies from the input sequence from the forward and backward directions, respectively, to form hidden states. In the decoder, the forward and backward hidden states are combined to gradually generate predictions through the Bi-GRU network.

[0082] Through the above mechanism, this solution not only solves the integral saturation problem caused by the traditional neural network model combined with the PID controller, but also supports input and output sequences of unequal lengths. This combination makes the control system more flexible and efficient, and can adapt to a wider range of application scenarios.

[0083] Secondly, the balance control system of the amplitude and flow of regulating valves used in chemical plants:

[0084] The system includes a multi-branch flow delivery system with at least one pipeline, and a regulating valve is connected between each pipeline and the gas source; the improvement of this solution is:

[0085] The system further comprises a PLC controller, a servo motor controlled by the PLC controller, a worm gear transmission mechanism driven by the servo motor for controlling the opening of the regulating valve, and a controller for executing the balancing control method as described above, wherein the controller converts the final electrical signal e i (t)' is input into the PLC controller to control the servo motor.

[0086] The worm gear transmission mechanism converts the rotation of the servo motor into the linear motion of the lead screw, thereby controlling the valve opening of the regulating valve, and finally feedbacks and compares the flow rate obtained by the control to form a closed-loop control.

[0087] Compared with the prior art, the present invention has the following beneficial effects:

[0088] 1. Dynamic Adjustment and Control Optimization: This invention introduces a bidirectional Seq-Bi-GRU recurrent neural network to dynamically calculate the error threshold T1 and saturation threshold T2 based on historical error data sets and current errors. This dynamic adjustment mechanism allows the integral action of the PID controller to be flexibly activated or deactivated based on actual conditions, effectively avoiding integral saturation in multi-branch flow transmission systems.

[0089] At the same time, by dynamically adjusting the accumulated step value of the integral term, the present invention further improves the performance of the PID controller, making the control system more stable and efficient when dealing with different working conditions.

[0090] Second, support for unequal-length input and output sequences: Traditional PID controllers combined with neural networks require equal-length input and output sequences, limiting the flexibility and applicability of multi-branch flow delivery systems. However, this invention, by introducing a Seq2Seq model and a bidirectional Bi-GRU recurrent neural network, supports unequal-length input and output sequences. This enables the multi-branch flow delivery system to handle more complex and diverse input signals, improving its adaptability and robustness.

[0091] III. Prediction Accuracy and Compensation Mechanism: This invention also introduces a prediction compensation mechanism. By minimizing the sum of squared residuals using the least squares method, an error feedback coefficient is derived and compensation is performed using historical prediction errors. This mechanism significantly improves prediction accuracy, enabling multi-branch flow delivery systems to respond more quickly and accurately to unknown or sudden operating conditions.

[0092] Fourth, improving control system performance: By comprehensively considering the effects of error thresholds and saturation thresholds, this invention optimizes the control of multi-branch flow delivery systems by introducing constraints to update the electrical signals of the discretized PID controller. This optimization not only improves the stability and response speed of the control system, but also reduces control error and energy consumption. BRIEF DESCRIPTION OF THE DRAWINGS

[0093] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following is a brief introduction to the drawings required for use in the embodiments or technical descriptions. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0094] Figure 1 Schematic diagram of the method flow of the present invention;

[0095] Figure 2 Schematic diagram of the neural network architecture of step S2 of the present invention;

[0096] Figure 3 It is a schematic diagram of the system composition of the present invention;

[0097] Figure 4 This is an overall layout diagram of multi-branch flow control in embodiment 1 of the present invention;

[0098] Figure 5 Schematic diagram of the GRU structure of embodiment 1 of the present invention;

[0099] Figure 6 Schematic diagram of finite element simulation of a test example of the present invention;

[0100] Figure 7 A comparison diagram of valve core displacement step response of a test example of the present invention;

[0101] Figure 8 This is a comparison chart of the valve core sinusoidal wave following of the test example of the present invention. DETAILED DESCRIPTION

[0102] To make the above-mentioned objects, features, and advantages of the present invention more clearly understood, the following detailed description of the specific embodiments of the present invention is given in conjunction with the accompanying drawings. Many specific details are set forth in the following description to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways than those described herein, and those skilled in the art can make similar improvements without violating the scope of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.

[0103] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Reference can be made to the common and similar parts between the various embodiments. The devices disclosed in the embodiments are described briefly because they correspond to the methods disclosed in the embodiments. For relevant details, refer to the method description.

[0104] Example 1: Figure 1 As shown, this example discloses a method for balancing the amplitude and flow of a regulating valve used in a chemical plant. This method is based on the combination of a neural network and a PID controller, and aims to solve the integral saturation problem in traditional control systems. At the same time, it supports the situation where the input and output sequences are of unequal length, and realizes the intelligent control of the pipeline amplitude and flow by the regulating valve. This example refers to the experimental layout method in section "2.1" in the document "Li Zedong, Meng Xiangyin, Peng Jie, et al. Simulation of multi-branch flow remote control based on neural network PID [J]. Computers and Digital Engineering, 2023, 51(02): 320-324+354." and optimizes and expands it to meet the specific needs of chemical plants.

[0105] like Figure 4 As shown, the layout primarily consists of three pipelines or groups of pipelines, each equipped with a discrete PID controller (labeled PID1, PID2, and PID3). These controllers are responsible for receiving target and feedback values, calculating the error, and adjusting the control valve state based on the calculated results to achieve the goal of controlling amplitude and flow.

[0106] Assume that the ideal flow rate and amplitude target values ​​for a pipeline or pipeline group are O = [f, a], where f is the ideal flow rate and a is the ideal amplitude. These target values ​​are pre-set based on the actual needs of the chemical production process. Sensors measure the actual flow rate and amplitude in the pipeline in real time, generating feedback values ​​F = [f′, a′], where f′ is the actual flow rate and a′ is the actual amplitude.

[0107] When the multi-branch flow delivery system is operating, the balancing control method provided in this example is simultaneously started, and the following steps S1 to S3 are executed in each working cycle or cycle.

[0108] In this embodiment, regarding step S1, electrical signal calculation: In step S1, the first task is to quantify the difference between the target value O and the feedback value F; first calculate the error E between the target value O and the feedback value F: E = |OF|, which reflects the degree of deviation between the current system state and the target state. Then, the discretized PID controller i corresponding to each pipeline calculates the initial electrical signal e i (t):

[0109] ;

[0110] Among them, K p is the proportionality coefficient, K i is the integration coefficient, K d is the differential coefficient; It represents the cumulative sum of errors from time 0 to the current time t, reflecting the historical accumulation of errors; E p Indicates the value of the error E at the previous time step, which is used to calculate the rate of change of the error.

[0111] The above-described discretized PID controller incorporates time discretization considerations, ensuring the effective implementation of the control strategy within the digital system. Through step S1, each PID controller i accurately calculates the electrical signals used to adjust pipeline flow and amplitude based on real-time feedback and target settings, laying a solid foundation for subsequent control actions. Furthermore, the discretized PID controller formula adapts to the characteristics of digital systems, ensuring the effective implementation of the control strategy. Through calculations at each time step, real-time adjustment of pipeline flow and amplitude is achieved.

[0112] In this embodiment, please refer to Figure 2 Regarding step S2, neural network operation: Each PID controller activates a bidirectional Seq-Bi-GRU recurrent neural network. This choice is based on its ability to flexibly handle inconsistent input and output sequence lengths and simultaneously capture both forward and reverse dependencies in time series data, improving the accuracy and robustness of the model when processing dynamic data. The network performs regression based on the historical error dataset D and the current error E as input. Its output includes two key thresholds:

[0113] (1) Error threshold T1: used to determine whether to activate the integral action. When the error exceeds T1, the integral term starts to work to eliminate the static error;

[0114] (2) Saturation threshold T2: used to prevent integral saturation. When the error accumulation reaches or exceeds T2, the integral action is slowed down by adjusting the step value S of the integral term to avoid the occurrence of integral saturation.

[0115] The bidirectional Seq-Bi-GRU recurrent neural network combines the features of the Seq2Seq model and the bidirectional Bi-GRU recurrent neural network. The Seq2Seq model can split the input and output sequences into independent encoding and decoding layers for processing, allowing the model to flexibly deal with inconsistent input and output sequence lengths, allowing the control system to adapt to different operating conditions and interference factors, thereby improving its flexibility and adaptability. The bidirectional Bi-GRU recurrent neural network can simultaneously capture both forward and reverse dependencies in time series data, improving the model's accuracy and robustness when processing dynamic data. By dynamically calculating the threshold through the neural network and adjusting the integral action of the PID controller, intelligent control of the regulating valve amplitude and flow rate is achieved, improving the efficiency and safety of the chemical production process.

[0116] The above-mentioned method for executing the bidirectional Seq-Bi-GRU recurrent neural network includes the following steps S200 to S202:

[0117] Specifically, in step S200, the encoder is executed: the core task of the encoder is to deeply explore the temporal dependencies in the input sequence S through the bidirectional Bi-GRU network, and finally output a hidden state sequence H containing rich features.

[0118] Receive input sequence S={D,E}, where D is a dataset of historical errors:

[0119] D=[{(F11,A11),(F21,A21),CV1},{(F12,A12),(F22,A22),CV1},...,{(FM N ,AM N ),(FM+1 N ,AM+1 N ),CV N}];

[0120] Among them, {(FI i ,AI i ),(FI+1 i ,AI+1 i ),CV i} is the i-th sample in the historical error data set D, N is the number of samples, and M is the pipeline number index; (FI i ,AI i ),(FI+1 i ,AI+1 i ) are two adjacent (connected) pipelines (where FI i and FI+1 i is the flow history value of two adjacent pipelines, AI i and AI+1 iis the amplitude history value of two adjacent pipelines), CV i is the coupling weight corresponding to the two adjacent pipelines (see the connection weight described in "3.2" of the reference of this embodiment for details). E is the error calculated in the current PID controller; the method includes:

[0121] S2000, initialize the forward hidden state and the backward hidden state , that is, setting both to zero vectors. This initialization step provides a starting point for subsequent Bi-GRU calculations: ;

[0122] S2001, forming a hidden state sequence H: extracting the dependency relationship in the input sequence S from both the forward and backward directions through the bidirectional Bi-GRU network; the specific operation method is as follows: for each element s in the input sequence S t , do the following:

[0123] S20010, please refer to Figure 5 , the forward Bi-GRU update methods include:

[0124] (1) Calculate the forward update gate The activation value of is used to control the update degree of the forward hidden state:

[0125] ;

[0126] Among them, σ represents the sigmoid activation function, W z is the weight matrix, b z is the bias vector, [·;·] represents the vector concatenation operation, is the hidden state vector; s t is the input vector.

[0127] (2) Calculate the forward reset gate The activation value of is used to control the degree of reset of the forward hidden state:

[0128] ;

[0129] Among them, W r and b r are the weight matrix and bias vector of the reset gate respectively;

[0130] (3) Calculate the forward candidate hidden state , are possible updates to the forward hidden state:

[0131] ;

[0132] Among them, tanh is the hyperbolic tangent activation function, Wh and b h are the weight matrix and bias vector of the candidate hidden state, respectively, and ⊙ represents the element-wise multiplication operator;

[0133] (4) Update the forward hidden state , is the result of the encoder forward propagation:

[0134] ;

[0135] S20011, Backward Bi-GRU Update: Similarly, for each element s in the input sequence S t , the update process of the backward Bi-GRU is as follows:

[0136] (1) Calculate the backward update gate The activation value of is used to control the degree of update of the backward hidden state:

[0137] ;

[0138] (2) Calculate the backward reset gate The activation value of is used to control the degree of reset of the backward hidden state:

[0139] ;

[0140] (3) Calculate the backward candidate hidden state , are possible updated values ​​of the backward hidden state:

[0141] ;

[0142] (4) Update the backward hidden state , is the result of the encoder backpropagation:

[0143] ;

[0144] S20012, after the forward and backward Bi-GRU updates, the hidden state of each time step can be obtained. The hidden state sequence H finally output by the encoder is:

[0145] ;

[0146] It can be understood that the bidirectional Bi-GRU network can deeply explore the temporal dependencies in the input sequence S, providing accurate information for subsequent threshold calculation and control actions. The hidden state sequence H output by the encoder contains rich features from the input sequence S, which helps the neural network more accurately calculate the error threshold T1 and saturation threshold T2. Due to the characteristics of the Seq2Seq model, the encoder can flexibly handle situations where the input and output sequence lengths are inconsistent, allowing the control system to adapt to different operating conditions and interference factors. By accurately calculating the error threshold T1 and saturation threshold T2 and adjusting the integral action of the PID controller, the stability and response speed of the control system can be improved, thereby achieving intelligent control of the regulating valve amplitude and flow.

[0147] To optimize the integration of the neural network model and the PID controller and address the integral windup problem, we introduced the Encoder-Decoder Attention (ECA) mechanism. This mechanism plays a key role in the decoding process, enabling the decoder to more effectively utilize the information output by the encoder.

[0148] Specifically, step S201 starts the ECA attention mechanism (Encoder-Decoder Attention): During the decoding process, the ECA attention mechanism allows the decoder to dynamically pay attention to all hidden states of the encoder output when generating each output, and generates an intermediate vector C that is closely related to the current encoder decoding step by weighted summation of these hidden states. This intermediate vector not only contains the global information of the encoder hidden state sequence H (including the system's past state information, which is crucial for predicting future states and controlling the regulating valve), but also places special emphasis on the current state of the decoder s i−1 The most relevant part. The specific method is:

[0149] S2010, perform weighted summation on the hidden state sequence H output by the encoder: For the i-th time step of the decoder, first calculate the encoder hidden state sequence H={h1,h2,...,h| S Each hidden state h in |} j The attention weight α ij These attention weights α ij reflects the degree of attention paid by the current decoding step to each hidden state of the encoder. Then, using these attention weights α ij Perform weighted summation on the hidden states to obtain the intermediate vector C i (i=1,2,...,S): ;

[0150] Specifically, the attention weight α ijCalculated by the softmax function: ;

[0151] Among them, e ij It represents the degree of attention paid by the decoder to the jth hidden state of the encoder at the i-th time step, which is the energy function of the attention mechanism. This energy function e ij According to the hidden state s of the decoder in the previous time step i−1 and the encoder hidden state h j The correlation between the two can be calculated (such as a single-layer neural network), which can also be calculated using the method of Example 3. By introducing the ECA attention mechanism, the decoder can more accurately capture the encoder information related to the current output, thereby improving the performance of the overall model.

[0152] It is understandable that by introducing the ECA attention mechanism, the decoder can more accurately capture the encoder information related to the current output. This helps the model to more accurately predict future states during the decoding process, thereby improving the performance of the overall model; in traditional PID controllers, the integral term may lead to saturation due to long-term error accumulation. However, in the present invention, due to the existence of the ECA attention mechanism, the model can process historical error information more intelligently and avoid the occurrence of integral saturation problems, because the ECA attention mechanism allows the decoder to dynamically pay attention to all hidden states of the encoder output when generating each output. This enables the model to handle situations where the input and output sequences are of unequal length, improving the flexibility and applicability of the model.

[0153] Specifically, step S202, decoder processing: In the decoding stage, combined with the intermediate vector C and the hidden state of the previous time step and , and the prediction result y of the decoder at the previous time step t−1 , through the bidirectional Bi-GRU network to gradually generate the prediction result y t =[T1, T2]. The following are the detailed steps of the process:

[0154] S2020, calculate the input x of the current time step t :The prediction result y of the previous time step t−1 Splice with the intermediate vector C to form the input x of the current time step t :x t =[y t-1 ;C];The purpose of this step is to combine historical information and the current state as input to the current time step so that the decoder can use this information to generate more accurate predictions.

[0155] S2021, calculate the hidden state h of the current time step through the Bi-GRU network t ,include:

[0156] S20210, Forward GRU Calculation: Use the forward GRU to calculate the forward hidden state of the current time step. Including calculating the update gate , Reset Gate , candidate hidden states , and the final forward hidden state :

[0157] ;

[0158] ;

[0159] ;

[0160] ;

[0161] The forward GRU controls the flow of information through update gates and reset gates to capture the forward dependencies in the sequence.

[0162] S20211, Backward GRU calculation: Similarly, use the backward GRU to calculate the backward hidden state of the current time step. Including the update gate of the backward GRU , Reset Gate , candidate hidden states and the final hidden state ; Note that this step uses the hidden state h of the next time step t+1 (In actual calculation, it is necessary to obtain it through a reverse process):

[0163] ;

[0164] ;

[0165] ;

[0166] ;

[0167] The backward GRU captures the backward dependencies in the sequence and, combined with the forward GRU, can more comprehensively understand the contextual information in the sequence.

[0168] S20212, concatenate the final hidden states of the forward and backward GRU to form the final hidden state h of the current time step t : ;

[0169] Among them, W xz 、Whz 、W xr 、W hr 、W xh and W hh are six different weight matrices. z 、b r and b h is the bias vector. By concatenating the forward and backward hidden states, the decoder can utilize both forward and backward information to improve prediction accuracy.

[0170] S2022, calculate input o t : Using a learnable weight matrix W o and the bias vector b o , the final hidden state h t Mapped to the input o of the output layer t :o t =W o h t +b o ; This step converts the hidden state into the input of the output layer, preparing for the subsequent activation function and threshold calculation.

[0171] S2023, apply the sigmoid activation function σ to get the predicted output : ; The sigmoid activation function maps the input value to between (0,1) and is used to generate probability or normalized output value.

[0172] S2024, calculate the error threshold T1 and the saturation threshold T2:

[0173] ;

[0174] ;

[0175] Here, t1 and t2 are intermediate variables used to calculate the error threshold T1 and saturation threshold T2, respectively. They are obtained through linear transformation. T1' and T2' are the initial error threshold and initial saturation threshold, respectively. This step calculates the initial values ​​of the error threshold and saturation threshold, which are used in the subsequent prediction compensation mechanism.

[0176] S20240, execute prediction compensation mechanism: that is, for the initial error threshold T1' and initial saturation threshold T2' calculated for the current prediction task, introduce the least squares method to minimize the residual sum of squares S through R language, C language, MATLAB or other commonly used mathematical tools, and the error feedback coefficient β can be obtained. i , and the historical prediction error of certain data is reviewed to compensate. The compensated error threshold T1 and saturation threshold T2 are formed; the error feedback coefficient β iIt can help the neural network "remember" and "correct" past prediction errors, thereby improving the accuracy of current predictions.

[0177] S20241, calculate the residual sum of squares S: the actual value y composed of the previous n error thresholds T1 and saturation thresholds T2 i The historical data points, and the predicted value composed of the first n initial error threshold T1' and initial saturation threshold T2' Calculate the residual sum of squares S for the historical data points: .

[0178] S20242, obtain the error feedback coefficient β i : In order to use historical forecast errors to improve current forecasts, the error feedback coefficient β is introduced i This coefficient is solved by the least square method to make the predicted value after compensation closer to the actual value. Let ϵ i =y i −y i 'For the historical forecast error, build a linear model to represent the forecast value after compensation: ;

[0179] in,' is the predicted value after compensation, a i−1 is the prediction error of the previous data point. In order to solve β i , substitute the above model into the expression of residual sum of squares, and i Take the derivative and set it equal to 0 to find the β that minimizes the residual sum of squares S i The minimum β is obtained. i After the value is obtained, it can be used to obtain the compensated error threshold T1 and saturation threshold T2:

[0180] T1=T1'+β i ΔT1';

[0181] T2=T2'+β i ΔT2';

[0182] Here, ΔT1' and ΔT2' are adjustments related to historical forecast errors (e.g., preset step values). This allows the system to remember and correct past forecast errors, thereby improving the accuracy of current forecasts. The forecast compensation mechanism minimizes the sum of squared residuals using the least squares method, leveraging historical forecast errors to refine current forecasts and thus improve forecast accuracy. This helps address the potential windup issue when combining neural network models with PID controllers and enables the model to support situations where the input and output sequences are of unequal length.

[0183] It can be understood that the bidirectional Bi-GRU network captures the forward and backward dependencies in the sequence, and the prediction compensation mechanism uses historical prediction errors to improve the current prediction, significantly improving the accuracy of the prediction. The prediction compensation mechanism helps to alleviate the integral windup problem that may arise when the neural network model is combined with the PID controller by adjusting the error threshold and saturation threshold. Because the Bi-GRU network can process sequences of arbitrary lengths and the prediction compensation mechanism does not rely on fixed input and output lengths, this method can support situations where the input and output sequences are of unequal lengths. Moreover, by accurately predicting the error threshold and saturation threshold, this method can more intelligently control the regulating valves of the chemical plant, thereby more effectively balancing the amplitude and flow of the pipeline.

[0184] Furthermore, the MATLAB execution program of the bidirectional Seq-Bi-GRU recurrent neural network provided in steps S200 to S202 is as follows:

[0185] % Step S200: Execute the encoder (Encoder);

[0186] % The dimension of the hidden state is h_dim;

[0187] h_dim = 128; % dimension;

[0188] S = {D, E}; % Input sequence;

[0189] |S| = length(S); % Input sequence length;

[0190] % Initialize forward and backward hidden states;

[0191] h_0_forward = zeros(h_dim, 1);

[0192] h_end_backward = zeros(h_dim, 1);

[0193] % Initialization of weight matrix and bias vector;

[0194] Wz = randn(h_dim, h_dim + input_dim); % input_dim is the dimension of the input data;

[0195] Wr = randn(h_dim, h_dim + input_dim);

[0196] Wh = randn(h_dim, h_dim + input_dim);

[0197] bz = randn(h_dim, 1);

[0198] br = randn(h_dim, 1);

[0199] bh = randn(h_dim, 1);

[0200] % Initialize the hidden state sequence H;

[0201] H = zeros(h_dim * 2, |S|);

[0202] % Forward Bi-GRU update;

[0203] for t = 1:|S|;

[0204] st = S{t}; % current input;

[0205] [zt, rt, ht_hat, ht] = bi_gru_forward(st, h_0_forward, Wz, Wr,Wh, bz, br, bh);

[0206] H(:, t) = [ht; zeros(h_dim, 1)]; % Temporarily store only the forward hidden state;

[0207] h_0_forward = ht; % Update the forward hidden state;

[0208] % Backward Bi-GRU update;

[0209] for t = |S|:-1:1;

[0210] st = S{t}; % current input;

[0211] [zt, rt, ht_hat, ht] = bi_gru_backward(st, h_end_backward, Wz,Wr, Wh, bz, br, bh);

[0212] H(h_dim + 1:end, t) = ht; % store the backward hidden state;

[0213] h_end_backward = ht; % Update the backward hidden state;

[0214] % bi_gru_forward and bi_gru_backward functions are implemented as follows;

[0215] function [zt, rt, ht_hat, ht] = bi_gru_forward(st, ht_1, Wz, Wr, Wh,bz, br, bh);

[0216] % concatenate input and hidden state;

[0217] xt = [st; ht_1];

[0218] % Update gate and reset gate;

[0219] zt = sigmoid(Wz * xt + bz);

[0220] rt = sigmoid(Wr * xt + br);

[0221] % candidate hidden states;

[0222] ht_hat = tanh(Wh * [st; rt .* ht_1] + bh);

[0223] % Final hidden state;

[0224] ht = (1 - zt) .* ht_1 + zt .* ht_hat;

[0225] function [zt, rt, ht_hat, ht] = bi_gru_backward(st, ht_1, Wz, Wr, Wh,bz, br, bh);

[0226] % Note: ht_1 here is actually the hidden state of the next time step;

[0227] % concatenate input and hidden state;

[0228] xt = [st; ht_1];

[0229] % Update gate and reset gate;

[0230] zt = sigmoid(Wz * xt + bz);

[0231] rt = sigmoid(Wr * xt + br);

[0232] % candidate hidden states;

[0233] ht_hat = tanh(Wh * [st; rt .* ht_1] + bh);

[0234] % Final hidden state;

[0235] ht = (1 - zt) .* ht_1 + zt .* ht_hat;

[0236] % Step S201: Start the ECA attention mechanism;

[0237] alpha = zeros(|S|, |S|);

[0238] % Calculate the attention weight and intermediate vector C;

[0239] for i = 1:|S|;

[0240] % Energy function e_ij;

[0241] e = H(:, i)' * H(:, :);

[0242] alpha(i, :) = softmax(e); % The softmax function converts e into a probability distribution;

[0243] C(:, i) = H * alpha(i, :)'; % Weighted sum to obtain the intermediate vector C_i;

[0244] % softmax function implementation;

[0245] function y = softmax(x);

[0246] e_x = exp(x - max(x, [], 2));

[0247] y = e_x . / sum(e_x, 2);

[0248] % Step S202: Decoder processing;

[0249] h_decoder_prev = zeros(h_dim * 2, 1);

[0250] % Initialize the output sequence;

[0251] Y = [];

[0252] % The decoder generates prediction results step by step;

[0253] for t = 1:|S|;

[0254] % Calculate the input for the current time step;

[0255] xt = [Y(:, end); C(:, t)]; % Let Y(:, end) be the prediction result of the previous time step;

[0256] % Calculate the hidden state of the current time step through the Bi-GRU network;

[0257] [zt_forward, rt_forward, ht_hat_forward, ht_forward] = bi_gru_forward(xt, h_decoder_prev(1:h_dim), Wz, Wr, Wh, bz, br, bh);

[0258] [zt_backward, rt_backward, ht_hat_backward, ht_backward] = bi_gru_backward(xt, h_decoder_prev(h_dim + 1:end), Wz, Wr, Wh, bz, br, bh);

[0259] ht_decoder = [ht_forward; ht_backward];

[0260] % Calculate the input of the output layer;

[0261] ot = W_o * ht_decoder + b_o; % W_o and b_o are the weight matrix and bias vector of the output layer

[0262] % Apply the sigmoid activation function to get the predicted output;

[0263] y_hat = sigmoid(ot);

[0264] %Store prediction results;

[0265] Y = [Y, y_hat];

[0266] % Update the decoder's hidden state;

[0267] h_decoder_prev = ht_decoder;

[0268] end

[0269] % Calculate the error threshold T1 and saturation threshold T2;

[0270] W_t1 = randn(1, h_dim * 2);

[0271] b_t1 = randn(1, 1);

[0272] W_t2 = randn(1, h_dim * 2);

[0273] b_t2 = randn(1, 1);

[0274] T1_prime = W_t1 * h_decoder_prev + b_t1;

[0275] T2_prime = W_t2 * h_decoder_prev + b_t2;

[0276] % Execute the prediction compensation mechanism;

[0277] historical_errors = ...; % Historical forecast errors;

[0278] actual_values ​​= ...; % actual values;

[0279] % Calculate the residual sum of squares S;

[0280] S = sum((actual_values ​​- historical_errors).^2);

[0281] % Get the error feedback coefficient beta;

[0282] beta = (sum(actual_values ​​.* historical_errors) - mean(actual_values)* sum(historical_errors)) / ...;

[0283] (sum(historical_errors.^2) - mean(historical_errors) * sum(historical_errors));

[0284] % Error threshold T1 and saturation threshold T2 after compensation;

[0285] T1 = T1_prime + beta * (T1_prime - mean(historical_errors)); % compensation method;

[0286] T2 = T2_prime + beta * (T2_prime - mean(historical_errors));

[0287] % Output the final result;

[0288] disp('Predicted T1:'); disp(T1);

[0289] disp('Predicted T2:'); disp(T2);

[0290] In this embodiment, regarding step S3, a constraint is introduced: based on the error threshold T1 and the saturation threshold T2, the following constraint terms are introduced into the discretized PID controller, and then the final electrical signal e is updated. i (t)'. The initial electrical signal e i (t) Updated to the final electrical signal e for controlling the opening of the regulating valve i (t)', that is, the original PID controller form is updated to:

[0291] ;

[0292] Among them, I is a flag bit used to indicate whether the PID integral action is activated. When |e(t)|≥T1, the integral action is activated and I is set to 1; otherwise, the integral action is not activated and I is set to 0. When the absolute value of the error signal is greater than or equal to the saturation threshold T2, the step value V is set to a fixed value ΔS fixation , to prevent integral saturation; otherwise, accumulation is performed according to the normal accumulation step value ΔV; through this method, the accumulation step value of the integral term can be dynamically adjusted according to the size of the error signal to prevent integral saturation and improve the performance of the PID controller.

[0293] It can be understood that by setting the saturation threshold T2 and fixing the integral term's step value to ΔSfixation when the error is large, the rapid growth of the integral term is effectively limited, thus preventing the occurrence of integral saturation. Dynamically adjusting the integral term's cumulative step value based on the size of the error signal allows the PID controller to more flexibly adjust its output when faced with errors of varying sizes, improving the controller's response speed and accuracy. By introducing the error threshold T1 and saturation threshold T2, the integral action of the PID controller is more finely controlled, helping to reduce system overshoot and oscillation and enhancing system stability.

[0294] Furthermore, the Python execution program of the above step S3 is as follows:

[0295] #PLC communication class;

[0296] class PLCCommunication:

[0297] def __init__(self, ip, port, bitrate):

[0298] # Initialize PLC communication parameters;

[0299] self.ip = ip;

[0300] self.port = port;

[0301] self.bitrate = bitrate;

[0302] # Assuming the connection is established;

[0303] self.connected = True;

[0304] def send_control_signal(self, signal):

[0305] # Send control signal to PLC;

[0306] print(f"Sending control signal: {signal}");

[0307] return True;

[0308] def receive_feedback_signal(self):

[0309] # Receive feedback signal from PLC;

[0310] feedback = np.random.random();

[0311] print(f"Received feedback signal: {feedback}");

[0312] return feedback;

[0313] #PID controller class;

[0314] class PIDController:

[0315] def __init__(self, kp, ki, kd, T1, T2, delta_S, delta_S_fixation):

[0316] self.kp = kp;

[0317] self.ki = ki;

[0318] self.kd = kd;

[0319] self.T1 = T1;

[0320] self.T2 = T2;

[0321] self.delta_S = delta_S;

[0322] self.delta_S_fixation = delta_S_fixation;

[0323] self.integral_active = 0;

[0324] self.S = 0;

[0325] self.previous_error = 0;

[0326] def compute_control_signal(self, setpoint, feedback):

[0327] # Calculate error;

[0328] error = setpoint - feedback;

[0329] # Determine whether the integral action is activated;

[0330] if abs(error) >= self.T1:

[0331] self.integral_active = 1;

[0332] else:

[0333] self.integral_active = 0;

[0334] # Whether to update the integral item;

[0335] if self.integral_active:

[0336] if abs(error) >= self.T2:

[0337] self.S += self.delta_S_fixation

[0338] else:

[0339] self.S += self.delta_S;

[0340] # Calculate the differential term;

[0341] derivative = error - self.previous_error;

[0342] # Calculate control signal;

[0343] control_signal = self.kp * error + self.ki * self.S + self.kd* derivative;

[0344] # Update the previous error;

[0345] self.previous_error = error;

[0346] return control_signal;

[0347] # Main program;

[0348] def main():

[0349] #PLC communication parameters;

[0350] plc_ip = "192.168.0.10";

[0351] plc_port = 502;

[0352] plc_bitrate = 9600 ;

[0353] #PID controller parameters;

[0354] kp = 1.0;

[0355] ki = 0.1;

[0356] kd = 0.01;

[0357] T1 = 0.5 ;

[0358] T2 = 1.0 ;

[0359] delta_S = 0.01;

[0360] delta_S_fixation = 0.1;

[0361] # Initialize PLC communication and PID controller;

[0362] plc = PLCCommunication(plc_ip, plc_port, plc_bitrate);

[0363] pid = PIDController(kp, ki, kd, T1, T2, delta_S, delta_S_fixation);

[0364] # set point;

[0365] setpoint = 1.0;

[0366] # Control loop;

[0367] while True;:

[0368] # Receive feedback signal from PLC;

[0369] feedback = plc.receive_feedback_signal();

[0370] # Calculate control signal;

[0371] control_signal = pid.compute_control_signal(setpoint,feedback);

[0372] # Send control signal to PLC;

[0373] plc.send_control_signal(control_signal)

[0374] # Wait for the next control cycle;

[0375] time.sleep(0.1);

[0376] if __name__ == "__main__":

[0377] main();

[0378] Example 2: This example discloses a training method for the bidirectional Seq-Bi-GRU recurrent neural network of Example 1, including:

[0379] P1. Collect and divide the dataset D:

[0380] D=[{(F11,A11),(F21,A21),CV1},{(F12,A12),(F22,A22),CV1},...,{(FM N ,AM N ),(FM+1 N ,AM+1 N ),CV N}];

[0381] Among them, {(FI i ,AI i ),(FI+1 i ,AI+1 i ),CV i} is the i-th sample in the historical error data set D, N is the number of samples, and M is the pipeline number index; (FI i ,AI i ),(FI+1 i ,AI+1 i ) are two adjacent (connected) pipelines (where FI i and FI+1 i is the flow history value of two adjacent pipelines, AI i and AI+1 i is the amplitude history value of two adjacent pipelines), CV i is the coupling weight corresponding to the two adjacent pipelines;

[0382] Divide the preprocessed dataset into training set D train and the test set D test ;

[0383] P2. Set training parameters: including learning rate, batch size, number of iterations, and Adam optimizer.

[0384] P3. Training model: using training set D train Train the model and update the model parameters (weight matrix W z 、W r 、W h 、W xz 、W hz 、W xr 、W hr 、W xh and Whh , and bias b z 、b r and b h ) to minimize the MAPE value between the predicted value and the actual value, and perform parameter tuning and model structure adjustment as needed.

[0385] P4. Model evaluation and deployment: Repeat forward propagation, loss calculation, and backpropagation, and continuously iterate the training process until the stopping condition is met (the maximum number of iterations is reached or the loss function value is less than the threshold).

[0386] The MATLAB program for the above training method is as follows:

[0387] % Load data into MATLAB;

[0388] N = 100; % sample size;

[0389] M = 10; % Number of pipeline number indexes;

[0390] % Initialize the data set D;

[0391] D = struct();

[0392] for i = 1:N

[0393] % Initialize data for each sample;

[0394] D(i).FIi = rand(M, 1); % Flow history values ​​of adjacent pipelines;

[0395] D(i).AIi = rand(M, 1); % Historical amplitude values ​​of adjacent pipelines;

[0396] D(i).FI_next = rand(M, 1); % The flow history value of the next adjacent pipeline;

[0397] D(i).AI_next = rand(M, 1); % The amplitude history value of the next adjacent pipeline;

[0398] D(i).CVi = rand(1); % coupling weight;

[0399] % Divide the training set and test set (use the first 80% as the training set and the last 20% as the test set)

[0400] train_ratio = 0.8;

[0401] Dtrain = D(1:round(train_ratio*N));

[0402] Dtest = D(round(train_ratio*N)+1:end);

[0403] options = trainingOptions('adam', ...

[0404] 'MaxEpochs', 100, ... % Maximum number of iterations;

[0405] 'MiniBatchSize', 32, ... % batch size;

[0406] 'InitialLearnRate', 0.001, ... % learning rate;

[0407] 'Verbose', false, ... % Do not display the training process in the command window;

[0408] 'Plots', 'training-progress' ... % Display the training progress graph; );

[0410] inputSize = size(D(1).FIi, 1); % The number of input features (i.e. the number of pipelines);

[0411] hiddenSize = 50; % Number of hidden layer units (adjustable);

[0412] % define the model;

[0413] layers = [

[0414] sequenceInputLayer(inputSize);

[0415] gruLayer(hiddenSize, 'OutputMode', 'sequence') % forward GRU;

[0416] gruLayer(hiddenSize, 'OutputMode', 'sequence', 'Direction', 'reverse') % Reverse GRU (note the direction setting here);

[0417] fullyConnectedLayer(1) % output layer;

[0418] regressionLayer % Use regression layer for training; ];

[0420] % training model;

[0421] net = trainNetwork(Dtrain, ... % training data;

[0422] layers, ...;

[0423] options);

[0424] % Initialize MAPE value;

[0425] MAPE = 0;

[0426] count = 0;

[0427] % Traverse the test set to make predictions and calculate MAPE;

[0428] for i = 1:length(Dtest);

[0429] % Use the model to make predictions;

[0430] pred = predict(net, Dtest_input); % Dtest_input is the test input in the appropriate format;

[0431] % Calculate the MAPE value;

[0432] MAPE = MAPE + abs((pred - Dtest(i).CVi_actual) / Dtest(i).CVi_actual);

[0433] count = count + 1;

[0434] % Calculate the average MAPE value;

[0435] MAPE = MAPE / count;

[0436] % Output MAPE value;

[0437] disp(['MAPE: ', num2str(MAPE)]);

[0438] % Save the model;

[0439] save('trainedModel.mat', 'net');

[0440] % Load the model;

[0441] load('trainedModel.mat', 'net');

[0442] Example 3: This example further provides an energy function e in step S201 of Example 1. ij specific implementation strategies.

[0443] Generally speaking, the energy function e ij While this can be assigned using a single-layer or short-duration neural network, the performance of this nested arrangement is highly dependent on the training data. If the training data is insufficient or biased, the neural network may not accurately learn the true distribution of the energy function. Furthermore, for small datasets, the neural network may overfit—that is, too closely match the noise and details in the training data rather than learning the underlying patterns of the data.

[0444] This embodiment provides another assignment strategy. It introduces the DS (Dempster-Shafer) evidence theory algorithm, a mathematical tool for processing uncertain information, to more accurately calculate the attention weight. In the concept of the DS evidence theory algorithm, the basic probability assignment (BPA) represents the degree of confidence in a proposition. For the encoder hidden state h j and the decoder’s hidden state s at the previous time step i−1 We can consider the correlation between them as a proposition and use BPA to express the degree of confidence in the proposition. The process is as follows:

[0445] S2010, let m1(h j ) and m2(s i−1 ) represent the BPA functions of the encoder hidden state and the decoder hidden state respectively (such as two bell-shaped functions of different widths, similar to fuzzy theory / algorithm), to form the proposition:

[0446] (1) Let m1(h j ) is a bell-shaped function centered at μ1 and with standard deviation σ1:

[0447] ;

[0448] (2) Let m2(s i−1 ) is a bell-shaped function centered at μ2 and with standard deviation σ2:

[0449] ;

[0450] It's important to note that while this example uses a normal distribution to represent the BPA function, in actual DS evidence theory, BPA functions don't necessarily require exact normal distributions; they can be any function that satisfies the definition of a BPA function (i.e., non-negative and summing to 1). Furthermore, because DS evidence theory deals with uncertain information, the BPA function allows for imprecise probability distributions, specifically, measures of confidence in a proposition.

[0451] S2011, implement Dempster synthesis rules: ;

[0452] Where A and B are the set representations of two propositions, X and Y are the focal elements of m1 and m2 respectively (i.e., the set to which the BPA function assigns non-zero values). This formula calculates the value of the combined BPA function on A∩B. For this scenario, h j and s i−1 are treated as single propositions (or focal elements) because we are computing correlations between them.

[0453] Therefore, the synthesized BPA function (m(h j , s i−1 )for: ;

[0454] Among them, K is a normalization constant used to ensure that the combined BPA function satisfies (summed over the set A of all possible propositions).

[0455] S2012, logarithmic function f(m(h j , s i−1 ) mapping, forming the energy function e ij (That is, to realize the properties of an activation function): ;

[0456] Where log(·) represents the natural logarithm (or the logarithm of other bases), (m(h j , s i−1 ) is the combined basic probability assignment (BPA) function, which represents the encoder hidden state h j and the decoder’s hidden state s at the previous time step i−1 The degree of confidence in the correlation.

[0457] Here, ε is a small constant used to avoid the logarithmic function in (m(h j , s i−1 ) = 0, the situation is undefined. ε is then set to a very small positive number, such as 1e -9 (0.000123409804).

[0458] As you can understand, DS evidence theory handles uncertainty by introducing basic probability assignment and synthesis rules. In this scenario, it allows us to more accurately assess the correlation between the encoder hidden state and the decoder hidden state. By converting this correlation into an energy value, we can more accurately calculate the attention weights, thereby optimizing the decoding process and improving model performance.

[0459] At the same time, DS evidence theory provides a confidence-based reasoning framework, making the energy function assignment process more transparent and explainable. By analyzing the basic probability assignment (BPA) function and Dempster's composition rule, we can better understand how the energy function is derived. DS evidence theory does not directly rely on a large amount of training data, but instead relies on the confidence assessment of propositions (in this case, the correlation between the encoder hidden state and the decoder hidden state). This reduces the need for large amounts of labeled data. Because DS evidence theory does not rely on complex neural network structures, it is not susceptible to overfitting. It focuses more on the rationality and consistency of the reasoning process. DS evidence theory also has stronger generalization capabilities because it is based on a general reasoning framework rather than a model specific to a particular dataset.

[0460] Example 4: Figure 3 As shown, this example further discloses a balance control system for the amplitude and flow of a regulating valve used in a chemical plant. This system can serve as a hardware carrier for the balance control method described in Example 1:

[0461] The system includes a multi-branch flow delivery system with at least one pipeline, and a regulating valve is connected between each pipeline and the gas source; the improvement of this solution is:

[0462] The system further comprises a PLC controller, a servo motor controlled by the PLC controller, a worm gear transmission mechanism driven by the servo motor for controlling the opening of the regulating valve, and a controller for executing the balancing control method as described above, wherein the controller converts the final electrical signal e i (t)' is input into the PLC controller to control the servo motor.

[0463] The worm gear transmission mechanism converts the rotation of the servo motor into the linear motion of the lead screw, thereby controlling the valve opening of the regulating valve, and finally feedbacks and compares the flow rate obtained by the control to form a closed-loop control.

[0464] Experimental example: This example aims to compare and analyze the performance of the PID controller of the bidirectional Seq-Bi-GRU recurrent neural network used in Example 1 and traditional technology in specific flow control tasks, evaluate the advantages and disadvantages of each controller in terms of valve core displacement step response, sinusoidal wave following ability and stress effect, and provide empirical basis for optimizing flow control strategy.

[0465] (1) Test subjects and equipment:

[0466] Test object: dual-spool independent throttle control valve connected to 80mm inner diameter alloy pipe.

[0467] Equipment configuration: host computer, sensor (for collecting flow, pressure and other data), CAN bus data acquisition system, drive current output device.

[0468] (II) Experimental and control group settings:

[0469] Experimental group: A PID controller using a bidirectional Seq-Bi-GRU recurrent neural network as disclosed in Example 1 was used to accurately predict and regulate flow.

[0470] Control group 1: Based on the literature "Wei Liejiang, Zhao Baocai, Sun Hui, et al. Flow-pressure composite control method of independent throttle valve based on BP neural network [J]. Hydraulics and Pneumatics, 2023, 47(08): 58-65.", a PID controller combined with BP-NN neural network was used.

[0471] Control group 2: using traditional PID controller without neural network assistance.

[0472] (III) Test content and steps:

[0473] 3.1 Test condition setting:

[0474] The valve opens at 0.1 min.

[0475] Within 0.5-0.8 minutes, the valve is required to flow 100 ml of water, with a maximum flow limit of 6 mm / s.

[0476] 3.2 Data collection and comparative analysis:

[0477] (1) Valve core displacement step response test: record and draw the valve core displacement step response curves of the experimental group, control group 1 and control group 2, compare them with the preset process standards, and evaluate the speed and accuracy of flow control of each controller.

[0478] (2) Sine wave following test of valve core: Apply a sine wave signal, collect and compare the following conditions of the three groups of valve cores, and evaluate the dynamic response capability and amplitude control accuracy of each group of controllers under the premise of flow control.

[0479] (3) Finite element stress simulation: Stress analysis was performed on the three groups of valve cores to compare the stress distribution and maximum stress value of the valve cores under different control strategies, and to evaluate the impact of the control strategy on the life of the valve core.

[0480] (IV) Results presentation:

[0481] Figure 6 The stress simulation results are presented, and it is expected that the experimental group performs better in terms of stress distribution and maximum value, indicating that its control strategy helps to reduce valve core wear and extend service life.

[0482] Figure 7 The comparison of the valve core displacement step response is shown. It is expected that the experimental group will perform better than the two control groups, which is reflected in the faster response speed and smaller overshoot.

[0483] Figure 8 The comparison of the valve core's sine wave following is shown. It is expected that the experimental group can follow the preset waveform more closely and the amplitude control is more precise.

[0484] (V) Conclusion

[0485] Based on the above tests and analysis, it is expected that the PID controller using a bidirectional Seq-Bi-GRU recurrent neural network will show significant advantages in terms of speed, accuracy, dynamic response capability and valve core stress optimization of flow control, providing an effective technical approach to further improve the performance of flow control systems.

[0486] For those skilled in the art, it can be further appreciated that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0487] At the same time, those skilled in the art will understand that all or part of the processes in all the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the above-mentioned method embodiments. Any reference to memory, storage, database, or other media provided in this application and used in the embodiments may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct RAMbus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM).

[0488] The above embodiments merely represent implementation methods of the relevant practical applications of the present invention. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the patent. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present invention, all of which fall within the scope of protection of the present invention. Therefore, the scope of protection of the patent for this invention shall be determined by the appended claims.

Claims

1. A method for balancing the amplitude and flow rate of a regulating valve for a chemical plant, comprising reading a target value O as an ideal flow rate and an ideal amplitude of a pipeline, and a feedback value F of an actual flow rate and an actual amplitude of the pipeline, characterized in that: The steps include: S1, calculate the error E between the target value O and the feedback value F, and calculate the initial electrical signal e for controlling the opening of the regulating valve corresponding to the discretized PID controller i of each pipeline i (t); S2, each of the PID controllers i activates a bidirectional Seq-Bi-GRU recurrent neural network, which takes the historical error data set D and the error E as input and performs a regression task, outputting an error threshold T1 for each of the PID controllers i for determining whether to activate the integral action, and a saturation threshold T2 for preventing integral saturation; S3, based on the error threshold T1 and the saturation threshold T2, introduce constraints to the PID controller i, and then update the final electrical signal e for controlling the opening of the regulating valve i (t)'.

2. The balance control method according to claim 1, characterized in that: In S1, the PID controller i is: ; Among them, K p is the proportionality coefficient, K i is the integration coefficient, K d is the differential coefficient; represents the cumulative sum of errors from time k=0 to the current time t, E p Represents the error at the previous time step.

3. The balance control method according to claim 1, characterized in that: In S2, the implementation method of the bidirectional Seq-Bi-GRU recurrent neural network includes: S200, executing the encoder: receiving an input sequence S={D,E}; outputting a hidden state sequence H through a bidirectional Bi-GRU network; S201, start the ECA attention mechanism: generate an intermediate vector C containing the global information of the hidden state sequence H; S202, decoder processing: combining the intermediate vector C and the hidden state of the previous time step and , and the prediction result y of the decoder at the previous time step t−1 , and the prediction result y is also generated through the bidirectional Bi-GRU network t =[T1, T2].

4. The balance control method according to claim 3, characterized in that: In the S200, the method for generating the hidden state sequence H includes: S2000, initialize the forward hidden state and the backward hidden state ; S2001, through the bidirectional Bi-GRU network, the dependency relationship in the input sequence S is extracted from the forward and backward directions, and the hidden state sequence H is formed. The process is as follows: S20010, for each element s in the input sequence S t , perform the forward Bi-GRU update: calculate the forward update gate Activation value of ; Calculate the forward reset gate Activation value of ; Calculate the forward candidate hidden state ; Update the forward hidden state ; S20011, for each element s in the input sequence S t , perform backward Bi-GRU update: calculate the backward update gate Activation value of ; Calculate the backward reset gate Activation value of ; Calculate the backward candidate hidden state ; Update the backward hidden state ; S20012, forming the hidden state sequence H.

5. The balance control method according to claim 3, characterized in that: In S201, the intermediate vector C is generated by calculating the hidden state sequence H={h1,h2,...,h| S Each hidden state h in |} j The attention weight α ij , get the intermediate vector C i : .

6. The balance control method according to claim 3, characterized in that: In the S202, the execution steps of the decoder include: S2020, the prediction result y of the previous time step t−1 It is concatenated with the intermediate vector C to form the input x of the current time step. t ; S2021, calculate the hidden state h of the current time step through the bidirectional Bi-GRU network t ; S2022, using the weight matrix W o and the bias vector b o The final hidden state h t Mapped to the input o of the output layer t :o t =W o h t +b o ; S2023, apply the sigmoid activation function σ to get the predicted output : ; S2024, calculate the error threshold T1 and the saturation threshold T2: ; ; Among them, t1 and t2 are intermediate variables; T1' and T2' are the initial error threshold and the initial saturation threshold respectively.

7. The balance control method according to claim 6, characterized in that: In S2021, the implementation method of the Bi-GRU network includes: S20210, use the forward GRU to calculate the forward hidden state of the current time step; including calculating the update gate , Reset Gate , candidate hidden states , and the final forward hidden state ; S20211, use backward GRU to calculate the backward hidden state of the current time step; including the update gate of backward GRU , Reset Gate , candidate hidden states and the final hidden state ; S20212, concatenate the final hidden states of the forward and backward GRUs to form the final hidden state h of the current time step t : ; Where [·;·] represents the vector concatenation operation.

8. The balance control method according to claim 6, characterized in that: In the step S2024, the following pre-compensation mechanism is also included: backtracking the actual value y composed of the previous n error thresholds T1 and the saturation thresholds T2 i The historical data points, and the predicted values ​​composed of the first n initial error threshold T1' and the initial saturation threshold T2' The historical data points are then used to calculate the residual sum of squares S: ; Assume ϵ i =y i −y i ' is the historical forecast error, and the following linear model is constructed to represent the forecast value after compensation : ; Among them, a i−1 is the prediction error of the previous data point; get the minimum β i After the compensation, the error threshold T1 and the saturation threshold T2 are calculated: T1=T1'+β i ΔT1'; T2=T2'+β i ΔT2'; Among them, ΔT1' and ΔT2' are adjustment amounts.

9. The balance control method according to claim 8, characterized in that: In S3, the method of introducing the constraint term is: updating the PID controller to the following form: ; Among them, I is a flag bit used to indicate whether the PID integral action is activated; V is the step value, ΔV fixation is a fixed value, and ΔV is the accumulated step value.

10. A system for executing the balancing control method according to any one of claims 1 to 9, comprising at least one multi-branch flow delivery system of a pipeline, wherein a regulating valve is connected between each pipeline and a gas source, and characterized in that: The control system also includes a PLC controller, a servo motor controlled by the PLC controller, a worm gear transmission mechanism driven by the servo motor for controlling the valve opening of the regulating valve, and a controller for executing the balance control method as described above, wherein the controller converts the final electrical signal e i (t)' is input into the PLC controller to control the servo motor.

Citation Information

Patent Citations

  • Multi-branch flow calibration cooperative control method and control system

    CN114637189A

  • Medical universal telescopic drill bit, control method and application of medical universal telescopic drill bit

    CN118787461A

  • Energy consumption monitoring method and system for green building based on Internet of Things

    CN119128388A

  • Quasi-recurrent neural network based encoder-decoder model

    IN201917021505A

  • Lithium-battery temperature field spatio-temporal modeling method based on EMD-lstm

    WO2024227376A1

Cited By

  • Dynamic control method and system for servo motor

    CN121348750A