Chicken house temperature prediction algorithm based on TCN-Transformer

By applying the temperature prediction algorithm and PID control module based on TCN-Transformer in the chicken coop, the problems of low temperature prediction accuracy and slow response speed of the chicken coop are solved, and more accurate and fast temperature control is achieved, and the growth environment of broilers is optimized.

CN119719990APending Publication Date: 2025-03-28TIANJIN AGRICULTURE COLLEGE +1
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202411956662.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-29
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

In the prior art, the chicken house temperature prediction accuracy is low and the response speed is slow, making it difficult to cope with complex environmental changes.

Method used

The chicken coop temperature prediction algorithm based on TCN-Transformer is used to collect chicken coop environment data, perform data processing and normalization processing, and input it into the TCN and Transformer models for prediction. Combined with the PID control module and the feedback adjustment module, the equipment working state is dynamically adjusted to optimize temperature control.

Benefits of technology

It improves the accuracy and response speed of chicken house temperature prediction, can better cope with complex environmental changes, optimize the growth environment of broiler chickens, and improve production efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119719990A_ABST
    Figure CN119719990A_ABST
Patent Text Reader

Abstract

According to the chicken coop temperature prediction algorithm based on the TCN-Transform, the temperature, the humidity and the ventilation quantity in the chicken coop are automatically adjusted in a mode of combining real-time monitoring and a prediction model, so that the growth environment of broiler chickens is optimized; a sensor is used for collecting internal and external environment data of a henhouse, and in combination with a prediction model based on TCN and Transformer, a future temperature change trend is estimated; a PID controller is adopted, the ventilation requirement is calculated in real time according to the target temperature, the current temperature, the predicted temperature and the outdoor temperature, the starting number and starting time of fans are output so that it can be ensured that the temperature of the henhouse can be kept within the target range all the time, PID control parameters are dynamically adjusted through the growth data of chickens, and the ventilation strategy is optimized so that the requirements of different growth stages can be met. By using the chicken coop temperature prediction algorithm based on TCN-Transformer, the prediction precision and the reaction speed can be improved, dynamic adjustment is performed according to the actual chicken coop environment, and the production benefits of a farm are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of chicken house temperature prediction, and in particular relates to a chicken house temperature prediction algorithm based on TCN-Transformer. Background Art

[0002] In modern agriculture, environmental control of chicken houses is an important part of ensuring the healthy growth and production efficiency of chickens. Temperature control and prediction of chicken houses are very critical links in modern breeding industry. Especially for large-scale farms, a reasonable temperature control system can significantly improve the production efficiency and health of chickens. In order to achieve precise temperature management, the relevant background technology involves multiple fields, mainly including environmental monitoring, data acquisition, automatic control, data analysis and prediction, etc. Traditional temperature control systems usually rely on manual experience and simple rules and feedback control methods, and have problems such as low prediction accuracy and slow response speed. It is difficult to cope with complex environmental changes and various influencing factors, and cannot adapt to the needs of modern breeding industry for precise management. With the development of deep learning technology, especially its application in the field of time series prediction, new ideas and methods are provided for the accurate prediction of chicken house temperature. Therefore, it is of great practical significance to develop an intelligent algorithm that can accurately predict the temperature of chicken houses. Summary of the invention

[0003] The present invention relates to a chicken house temperature prediction algorithm based on TCN-Transformer, so as to at least solve the problems of low accuracy, slow response speed and difficulty in coping with complex environmental changes in the chicken house temperature prediction in the related art.

[0004] In order to achieve the above objectives, the present invention provides the following technical solutions:

[0005] A chicken house temperature prediction algorithm based on TCN-Transformer, the steps are as follows, including:

[0006] S01. Collect chicken house environmental data;

[0007] S02, performing data processing on the collected chicken house environment data to obtain the data to be measured, wherein the data processing method is to first calculate the arithmetic mean and then perform normalization processing;

[0008] S03, inputting the data to be measured into the chicken house temperature prediction model for prediction to obtain the predicted temperature, wherein the temperature prediction model uses TCN and Transformer as the basic network;

[0009] S04, input the predicted temperature into the PID control module, the PID control module performs difference calculation on the predicted temperature and the daily target temperature to obtain the predicted temperature deviation, performs difference calculation on the real-time temperature and the daily target temperature to obtain the real-time temperature deviation, performs weighted processing on the two deviation values, and adjusts the working state of the equipment in the chicken house in combination with the initial control parameters;

[0010] S05. The daily weight gain, feed consumption and feed-to-meat ratio data of the broilers are input into the feedback adjustment module. The feedback adjustment module calculates the control parameters based on the daily weight gain, feed consumption and feed-to-meat ratio data of the broilers, and outputs them to the PID control module for dynamic adjustment of the equipment working state.

[0011] Furthermore, the data processing step is:

[0012] S11, the environmental data collected by each environmental sensor in the chicken house is used to form a data set arranged in time series, and the missing values ​​and abnormal values ​​in the data are replaced according to the linear trend of the adjacent points, and the data set is output;

[0013] S12, obtaining the internal temperature data collected by each sensor in the chicken house in the data set, calculating and processing the temperature data inside the chicken house at the same time by taking the arithmetic mean, obtaining the average temperature inside the chicken house, and outputting the average temperature value inside the chicken house;

[0014] S13, obtaining the internal humidity data collected by each sensor in the chicken house in the data set, calculating and processing the humidity data inside the chicken house at the same time by taking the arithmetic mean, obtaining the average humidity inside the chicken house, and outputting the average humidity value inside the chicken house;

[0015] S14, obtaining the internal wind speed data collected by each sensor in the chicken house in the data set, calculating and processing the wind speed data inside the chicken house at the same time by taking the arithmetic mean, obtaining the average wind speed inside the chicken house, and outputting the average wind speed value inside the chicken house;

[0016] S15, obtaining the CO2 concentration data collected by each sensor in the chicken house in the data set, calculating and processing the CO2 concentration data at the same time in the chicken house by taking the arithmetic mean, obtaining the average carbon dioxide concentration inside the chicken house, and outputting the average CO2 concentration value inside the chicken house;

[0017] S16, obtaining the average temperature value inside the chicken house, the average humidity value inside the chicken house, the average wind speed value inside the chicken house and the average CO2 concentration value inside the chicken house, and normalizing these data to obtain and output the normalized processing result.

[0018] Furthermore, the temperature prediction model includes a TCN part and a Transformer part;

[0019] The temperature prediction model includes a TCN part and a Transformer part;

[0020] The TCN part includes a first input layer, a residual block layer and a first flattening layer;

[0021] The Transformer part includes a second input layer, a multi-head attention mechanism, a normalization layer, and a second flattening layer;

[0022] The TCN part and the Transformer part are connected through a connection layer, and the connection layer concatenates the outputs of the first flattening layer and the second flattening layer on a specific axis to form a feature tensor, and the feature vector contains information of all input tensors;

[0023] The feature vector is converted into a final prediction value through a fully connected layer, which connects the information of all input tensors, performs linear transformation, introduces nonlinear features, and obtains the final prediction value.

[0024] Furthermore, the residual block layer includes a one-dimensional convolution layer, a batch normalization layer and an activation layer.

[0025] The one-dimensional convolution layer extracts key information from the time series data through the convolution kernel and outputs it to the batch normalization layer.

[0026] The batch normalization layer receives the key information in the time series data and normalizes the key information in the time series data to obtain normalized information, and inputs the normalized information into the activation layer.

[0027] The activation layer receives the normalized information, and uses the ReLU activation function to convert the normalized information into a multidimensional array, and outputs the multidimensional array to the first flattening layer.

[0028] Furthermore, the prediction method of the temperature prediction model is that the TCN sub-network extracts local dependency features in the time series through a multi-layer convolutional network, and the Transformer sub-network captures the global relationship in the time series through a multi-head self-attention mechanism. The model predicts and outputs the temperature prediction value 5 minutes later, adopts an early stopping strategy to prevent the model from overfitting, and uses 5-fold cross validation to evaluate the model.

[0029] Furthermore, the calculation processing method is to take the arithmetic mean after removing missing values ​​and outliers, and the normalization processing method is to scale the values ​​of the acquired data to a fixed interval to obtain the scaled data, input the scaled data into the temperature prediction model, obtain the temperature prediction value after a period of time, and calculate it with the daily target temperature set in the chicken house to obtain the predicted temperature deviation.

[0030] Furthermore, the TCN uses causal convolution to ensure that the output of the current time step depends only on the data of the current and previous time steps without affecting future time steps; the characteristic of the causal convolution is that the value of the previous layer at time t only depends on the value of the next layer at time t and before.

[0031] Furthermore, the adjusting the working state of the equipment in the chicken house includes:

[0032] S21, calculating the collected real-time temperature and the target temperature set in the chicken house to obtain a real-time temperature deviation;

[0033] S22, performing a difference calculation between the predicted temperature and the daily target temperature to obtain a predicted temperature deviation, and performing a difference calculation between the real-time temperature and the daily target temperature to obtain a real-time temperature deviation;

[0034] S23, weighting the two deviation values, balancing the deviation between the control parameter and the deviation value through proportional control, integral control and differential control, introducing the error change rate to prevent overshoot, calculating the control amount after the deviation is balanced through proportional control, integral control and differential control, and obtaining the expected ventilation volume;

[0035] S24, the PID control module converts the expected ventilation volume into the required number of fans to be turned on and the duration of the fans to be turned on according to the expected ventilation volume, the volume of the chicken house, the number of fans and the air change volume per hour of a single fan;

[0036] S25, turning on the fans for ventilation according to the required number of fans and the turning-on time.

[0037] Furthermore, the control parameters dynamically adjust the proportional coefficient, integral coefficient and differential coefficient in the PID control module by calculating the growth stage and weight gain, feed consumption and feed-to-meat ratio of the broiler chickens.

[0038] Furthermore, the following modules are included:

[0039] A real-time monitoring module, which is used to collect real-time environmental data inside and outside the chicken house;

[0040] A temperature prediction module, which is used to predict the temperature in the chicken house based on time series data and historical environmental data;

[0041] A PID control module, the PID control module is used to receive the predicted temperature data of the temperature prediction module and the real-time temperature data of the real-time monitoring module, and generate a ventilation control output signal to control the ventilation equipment in the chicken house;

[0042] A fan control module, the fan control module is used to receive the ventilation control output signal of the PID control module, and control the number and opening time of the fan according to the ventilation control output signal, so as to control the temperature in the chicken house within a preset target temperature range;

[0043] A feedback adjustment module is used to dynamically adjust the parameters of the PID control module based on the production performance data of the broilers in the chicken house, so that the ventilation control output can adapt to the growth needs of the broilers in the chicken house.

[0044] The present invention provides a chicken house temperature prediction algorithm based on TCN-Transformer, which aims to automatically adjust the temperature, humidity and ventilation volume in the chicken house to optimize the growth environment of broilers by combining real-time monitoring with a prediction model. Multi-sensors are used to collect environmental data inside and outside the chicken house, and combined with a prediction model based on TCN and Transformer, the future temperature change trend is estimated. A PID controller is used to calculate the ventilation demand in real time according to the target temperature, current temperature, predicted temperature and outdoor temperature, and output the number and opening time of the fan to ensure that the chicken house temperature is always maintained within the target range. The PID control parameters are dynamically adjusted using the growth data of the chicken, and the ventilation strategy is optimized to meet the needs of different growth stages. The intelligent and automated control of the breeding process is realized, and the breeders are helped to realize the intelligent control of temperature, which can improve the accuracy of prediction and the speed of response, and dynamically adjust the actual chicken house environment to improve production efficiency. It provides strong technical support for environmental control and intelligent breeding, and has broad application prospects and significant economic benefits. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0046] in:

[0047] Figure 1 This is the flow chart of the chicken house temperature prediction algorithm based on TCN-Transformer;

[0048] Figure 2 This is the structure diagram of the chicken house temperature prediction algorithm based on TCN-Transformer;

[0049] Figure 3 This is the module flow chart of the chicken house temperature prediction algorithm based on TCN-Transformer;

[0050] Figure 4 This is the module structure diagram of the chicken house temperature prediction algorithm based on TCN-Transformer;

[0051] Figure 5 This is the structural diagram of TCN causal convolution;

[0052] Figure 6 This is the structural diagram of TCN dilated convolution;

[0053] Figure 7 This is the structural diagram of the combination of TCN causal convolution and dilated convolution;

[0054] Figure 8 It is the structural diagram of the TCN residual module;

[0055] Fig. 9 This is the basic structure diagram of the TCN network;

[0056] Fig.10 It is the structural diagram of the TCN target sequence;

[0057] Fig.11 This is the basic structure diagram of Transformer;

[0058] Fig.12 It is the Transformer attention mechanism structure. DETAILED DESCRIPTION

[0059] In order to enable those skilled in the art to better understand the technical solutions in the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of this application.

[0060] In order to solve the problems of low accuracy, slow response speed and difficulty in coping with complex environmental changes in the relevant technology of chicken house temperature prediction, it is necessary to first design a chicken house temperature prediction algorithm. The algorithm completes the function of predicting the chicken house temperature by collecting chicken house environmental information. Based on this, the embodiment of the present disclosure provides a chicken house temperature prediction algorithm based on TCN-Transformer, see Figure 1 , the method comprising,

[0061] S01. Collect chicken house environmental data;

[0062] The collected data collected real-time internal and external environmental data of a chicken house at a Smart broiler farm in Pingyuan County, Dezhou City, Shandong Province over a period of 36 days through environmental sensors inside the chicken house and an outdoor weather station. The data included 12 variables including external temperature, humidity, wind speed, internal humidity, wind speed, CO2 concentration, etc., with a total of approximately 30,000 records. The collected data was cleaned, and outliers and missing values ​​were processed to ensure the integrity and accuracy of the data.

[0063] S02. Process the collected chicken house environment data to obtain the data to be tested. The data processing method is to first calculate the arithmetic mean and then perform normalization processing to facilitate model training.

[0064] S03, inputting the data to be measured into the chicken house temperature prediction model for prediction to obtain the predicted temperature, wherein the temperature prediction model uses TCN and Transformer as the basic network;

[0065] Construct a chicken house temperature prediction model based on TCN and Transformer. By combining the two architectures of TCN (Temporal Convolutional Network) and Transformer, this model can effectively capture the complex temporal relationship and global trend of temperature changes in broiler chicken houses. The temperature of the chicken house may be affected by natural temperature changes in multiple periods of a day, and some abnormal weather or sudden failures can cause short-term sharp fluctuations. The model can extract key influencing factors from complex environmental data and accurately predict the temperature, allowing farmers to respond in advance and reduce the adverse effects of extreme temperatures on chickens. The prediction model based on TCN and Transformer can also accurately estimate temperature trends in advance, helping chicken houses to better plan energy use. Through this intelligent regulation, energy consumption and breeding costs can be effectively reduced, the internal environment of the chicken house can be ensured to be stable, and ultimately the growth rate and health level of broilers can be improved.

[0066] The model includes a TCN subnetwork and a Transformer subnetwork, which process the input time series data in parallel. The cross-validation method is used to verify the model and evaluate the prediction accuracy and robustness of the model. The temperature in the chicken house is affected by many factors, such as humidity, wind speed, CO2 concentration, etc. The model based on TCN and Transformer can process multi-dimensional environmental data and establish a complex temperature-environmental parameter relationship model. Compared with the traditional single factor prediction method, this model can more comprehensively understand the impact of environmental parameters on temperature and provide a more comprehensive temperature prediction and control solution. The features of the model input include 13 features in total, including external temperature, external humidity, wind speed, ventilation status, etc. The model uses 12 time steps, that is, the data of the first 60 minutes to predict the temperature in the house in the next time step.

[0067] Save the model training parameters, deploy the trained model to the chicken house environmental control system, input the new moment data into the prediction model, and predict the chicken house temperature in real time. The temperature in the broiler house is affected by many factors, such as external temperature, humidity, wind speed, ventilation conditions, etc. The TCN module can handle the short-term and local dependencies brought by these factors well, while the Transformer module can capture long-term global trends and complex dependencies. Splicing the outputs of the two can comprehensively handle the short-term fluctuations and long-term trends of the environmental data in the house, thereby providing more accurate predictions.

[0068] S04, input the predicted temperature into the PID control module, the PID control module performs difference calculation on the predicted temperature and the daily target temperature to obtain the predicted temperature deviation, performs difference calculation on the real-time temperature and the daily target temperature to obtain the real-time temperature deviation, performs weighted processing on the two deviation values, and adjusts the working state of the equipment in the chicken house in combination with the initial control parameters;

[0069] S05. The daily weight gain, feed consumption and feed-to-meat ratio data of the broilers are input into the feedback adjustment module. The feedback adjustment module calculates the control parameters based on the daily weight gain, feed consumption and feed-to-meat ratio data of the broilers, and outputs them to the PID control module for dynamic adjustment of the equipment working state.

[0070] The chicken house ambient temperature data includes real-time monitoring and collection of real-time environmental data inside and outside the chicken house and control data of ventilation equipment, and calculating the arithmetic mean of the temperature of each monitoring point in the chicken house to obtain the real-time temperature of the chicken house. At the same time, the real-time temperature is compared with the daily target temperature set in the chicken house. Calculate and get the real-time temperature deviation .

[0071] The processed environmental parameters of each monitoring point are calculated by arithmetic mean to obtain the real-time environmental parameter value of the chicken house, and then normalized and used as the input of the temperature prediction module to obtain the temperature prediction result of the chicken house after a period of time. , according to the prediction results, the predicted temperature deviation is obtained .

[0072] The PID control module will real-time temperature deviation and predicted temperature deviation The weighted average of is taken as input to get the comprehensive error The comprehensive error is used as the error input to the PID control module to calculate the PID control output and obtain the output result as the desired ventilation volume. ;

[0073] The fan control module further adjusts the volume of the chicken house 、Number of fans , fan ventilation capacity and Calculate the number of fans turned on and running time ;

[0074] The temperature prediction model includes a TCN part and a Transformer part;

[0075] The TCN part includes a first input layer, a residual block layer and a first flattening layer;

[0076] The Transformer part includes a second input layer, a multi-head attention mechanism, a normalization layer, and a second flattening layer;

[0077] The TCN part and the Transformer part are connected through a connection layer, and the connection layer concatenates the outputs of the first flattening layer and the second flattening layer on a specific axis to form a feature tensor, which contains information of all input tensors;

[0078] The feature vector is converted into a final prediction value through a fully connected layer, which connects the information of all input tensors, performs linear transformation, introduces nonlinear features, and obtains the final prediction value.

[0079] The residual block layer includes a one-dimensional convolution layer, a batch normalization layer and an activation layer.

[0080] The one-dimensional convolution layer extracts key information from the time series data through the convolution kernel and outputs it to the batch normalization layer.

[0081] The batch normalization layer receives the key information in the time series data and normalizes the key information in the time series data to obtain normalized information, and inputs the normalized information into the activation layer.

[0082] The activation layer receives the normalized information, and uses the ReLU activation function to convert the normalized information into a multidimensional array, and outputs the multidimensional array to the first flattening layer.

[0083] The prediction method of the temperature prediction model is that the TCN sub-network extracts local dependency features in the time series through a multi-layer convolutional network, and the Transformer sub-network captures the global relationship in the time series through a multi-head self-attention mechanism. The model predicts and outputs the temperature prediction value 5 minutes later, adopts an early stopping strategy to prevent the model from overfitting, and uses 5-fold cross validation to evaluate the model.

[0084] TCN (Temporal Convolutional Network, TCN) is a deep learning model suitable for processing sequence data. TCN captures dependencies in time series through convolution operations, and uses causal convolution and dilated convolution to ensure that the model can efficiently process sequence data with long time spans. Unlike recurrent neural networks (RNNs), TCN can perform parallel calculations during training and inference, which improves computational efficiency.

[0085] TCN uses causal convolution to ensure that the output of the current time step depends only on the data of the current and previous time steps, and does not affect future time steps. Figure 5 As shown in the figure, the value of the previous layer at time t only depends on the value of the next layer at time t and before. The difference from the traditional convolutional neural network is that the causal convolution cannot see future data. It is a unidirectional structure rather than a bidirectional structure. It is a strict time constraint model, so it is called causal convolution.

[0086] The sequence problem can be transformed into: According to Go to predict .

[0087] In the definition of causal convolution, the filter ,sequence .

[0088] exist The causal convolution at is:

[0089]

[0090] This ensures that the model does not see future information when making predictions, which is consistent with the causality of time series.

[0091] Dilated convolution Figure 6 As shown in the figure, the receptive field of the convolution kernel is expanded by inserting holes between the convolution kernels, so that dependencies over a longer time range can be captured without increasing the computational complexity. The dilation factor determines the degree of expansion of the convolution kernel. Dilated convolution allows for intermittent sampling of the input during convolution, and the sampling rate is controlled by d. The d=1 of the bottom layer means that each point is sampled during input, and the d=2 of the middle layer means that one out of every two points is sampled as input during input. The higher the level, the larger the size of d used. Therefore, dilated convolution makes the size of the effective window grow exponentially with the number of layers. In this way, the convolutional network can obtain a large receptive field with relatively few layers.

[0092] In the definition of dilated convolution, the filter ,sequence .

[0093] exist The dilation rate at which the convolution is equal to d is:

[0094]

[0095] Causal convolution and dilated convolution in TCN architecture Figure 7 As shown, each layer The value at a certain moment depends only on the value at the previous layer at time t-1, which reflects the characteristics of causal convolution; and each layer extracts information from the previous layer in a jumpy manner, and the dilated rate increases exponentially by 2 from layer to layer, which reflects the characteristics of dilated convolution. Due to the use of dilated convolution, padding (usually 0 is added) is required for each layer, and the padding size is (k-1)d.

[0096] Residual connections are introduced in TCN, such as Figure 8 As shown in Figure 2, it can help alleviate the gradient vanishing problem in deep networks and improve the training efficiency and stability of the model. Residual connections make training easier by connecting the input directly to the output, allowing the model to learn the residual (i.e., error).

[0097] The TCN network structure is as follows Fig. 9 As shown, given input_length, kernel_size, dilation_base and the minimum number of layers required to cover the entire history. In order to train the TCN network for prediction, the training set will consist of equal-sized subsequence pairs (input sequence, target sequence) of the given time series, that is, input series = target series.

[0098] The target sequence is Fig.10 As shown, it will be a sequence shifted right by a certain amount output_length relative to its respective input sequence. The target sequence of length input_length contains the last (input_length – output_length) elements of its respective input sequence as its first element, and the output_length element that comes after the last entry of the input sequence as its last element. In terms of prediction, the maximum prediction horizon that the model can predict is equal to output_length. Using the sliding window approach, many overlapping input and target sequences can create a time series.

[0099] Transformer is a neural network architecture based on the attention mechanism, which is widely used in fields such as natural language processing (NLP) and time series prediction. Unlike traditional recurrent neural networks (RNN) and convolutional neural networks (CNN), Transformer can process sequence data in parallel, improving computational efficiency and performance.

[0100] First, each element (usually a word or feature) in the input sequence is embedded into a high-dimensional vector space. This is done by finding the embedding matrix:

[0101] .

[0102] Since Transformer does not have built-in sequential information, position information needs to be added through position encoding.

[0103] The formula for position encoding is as follows:

[0104]

[0105]

[0106] like Fig.11 As shown in the figure, Transformer mainly consists of two parts: encoder and decoder.

[0107] The encoder is composed of multiple identical encoder layers stacked together. Each encoder layer consists of two main sub-layers: Multi-Head Self-Attention Mechanism and Feed-Forward Neural Network. Each sub-layer is followed by a residual connection and layer normalization.

[0108] The decoder is composed of multiple identical decoding layers stacked together. Each decoding layer includes three main sub-layers: Masked Multi-Head Self-Attention, Encoder-Decoder Attention, and Feed-Forward Neural Network. Each sub-layer is followed by a residual connection and layer normalization.

[0109] The structure of the self-attention mechanism is as follows Fig.12 As shown in the figure, by calculating the correlation between each element in the input sequence and other elements, the long-range dependencies in the sequence are captured. , the self-attention mechanism calculates each element The attention weights are:

[0110]

[0111] in, , and Represent the query, key, and value matrices respectively. is the dimension of the key.

[0112] The multi-head attention mechanism captures information from different subspaces by computing multiple different self-attention mechanisms in parallel:

[0113] .

[0114] Among them, each head is an independent self-attention mechanism, is the output weight matrix.

[0115] The feedforward neural network consists of two fully connected layers:

[0116]

[0117] The final output of the decoder is mapped to the probability distribution of the vocabulary through a fully connected layer to generate the final output sequence.

[0118] In this model, the TCN (Temporal Convolutional Network) module captures the temporal dependencies in the input sequence through multiple residual blocks. Each residual block expands the receptive field through dilated convolution, which can effectively handle the dependencies in long sequence data. The batch normalization and ReLU activation function after the convolution layer further optimize the convergence speed of the model and enhance the nonlinear expression ability of the model. The TCN output after processing by several residual blocks is flattened into a one-dimensional vector through the flattening layer. This part of the vector contains rich time series dependency information; the Transformer module mainly captures the global features in the sequence through the multi-head self-attention mechanism. The data of each time step can interact with the data of other time steps in the sequence, which is different from the local dependency of convolution. Therefore, the Transformer can handle global dependency and stride dependency well. This part skips the original input and the attention output through the Add operation, and then normalizes it through LayerNormalization to ensure the stable propagation of information and enhance the generalization ability of the model. Finally, the output of the attention module is flattened into a one-dimensional vector through the flattening layer.

[0119] The concatenation layer is used to concatenate multiple input tensors on a specific axis to form a feature vector. This feature vector contains information about all input tensors. The TCN module and the Transformer module are each good at extracting different types of temporal features. TCN mainly extracts local temporal dependencies, while Transformer focuses more on global and long-distance dependencies. In this model, the concatenation layer is used to connect the output features of the Temporal Convolutional Network (TCN) and the Transformer model. These two parts extract different features of time series data respectively. Through concatenation, these features can be combined to form a feature vector containing more information, allowing the model to make predictions based on capturing both local and global features. When the model has both local and global features, it can understand the input data more comprehensively, thereby improving the model's ability to capture complex temporal relationships. Especially in scenarios such as temperature prediction, it is necessary not only to pay attention to short-term changes in temperature over time (processed by TCN), but also to identify long-term trends and overall changes (processed by Transformer). This dual mechanism helps improve the generalization ability and prediction accuracy of the model.

[0120] The fully connected layer (also called a dense layer) is one of the basic layers in a neural network. It connects each unit of the input to each unit of the output, performs a linear transformation, and then introduces nonlinear features through activation functions. In this model, the fully connected layer is used to convert the feature vector to the final prediction value. The fully connected layer has only one output neuron, which is responsible for predicting a single target value (the temperature of the chicken house). The concatenated output is converted to the final prediction value through the fully connected layer. This step plays the role of mapping the result of combining two different features, mapping the concatenated high-dimensional features back to the target output space.

[0121] The steps of data processing are:

[0122] S11, the environmental data collected by each environmental sensor in the chicken house is used to form a data set arranged in time series, and the missing values ​​and abnormal values ​​in the data are replaced according to the linear trend of the adjacent points, and the data set is output;

[0123] S12, obtaining the internal temperature data collected by each sensor in the chicken house in the data set, calculating and processing the temperature data inside the chicken house at the same time by taking the arithmetic mean, obtaining the average temperature inside the chicken house, and outputting the average temperature value inside the chicken house;

[0124] S13, obtaining the internal humidity data collected by each sensor in the chicken house in the data set, calculating and processing the humidity data inside the chicken house at the same time by taking the arithmetic mean, obtaining the average humidity inside the chicken house, and outputting the average humidity value inside the chicken house;

[0125] S14, obtaining the internal wind speed data collected by each sensor in the chicken house in the data set, calculating and processing the wind speed data inside the chicken house at the same time by taking the arithmetic mean, obtaining the average wind speed inside the chicken house, and outputting the average wind speed value inside the chicken house;

[0126] S15, obtaining the CO2 concentration data collected by each sensor in the chicken house in the data set, calculating and processing the CO2 concentration data at the same time in the chicken house by taking the arithmetic mean, obtaining the average carbon dioxide concentration inside the chicken house, and outputting the average CO2 concentration value inside the chicken house;

[0127] S16, obtaining the average temperature value inside the chicken house, the average humidity value inside the chicken house, the average wind speed value inside the chicken house and the average CO2 concentration value inside the chicken house, and normalizing these data to obtain and output the normalized processing result.

[0128] The real-time monitoring module is used to monitor and collect real-time environmental data inside and outside the chicken house and control data of ventilation equipment, including external temperature, external humidity, external wind speed, air pressure and house temperature, house humidity, house wind speed, house carbon dioxide concentration, current negative pressure, target temperature, ventilation level, ventilation volume, number of fans turned on, etc., and monitor the temperature of each monitoring point in the chicken house. Calculate the real-time temperature of the chicken house , the calculation formula is:

[0129]

[0130] At the same time, the real-time temperature is compared with the daily target temperature set in the chicken house. Calculate and get the real-time temperature deviation , the calculation formula is:

[0131]

[0132] The calculation processing method is to take the arithmetic mean after removing missing values ​​and outliers, and the normalization processing method is to scale the values ​​of the acquired data to a fixed interval to obtain the scaled data, input the scaled data into the temperature prediction model, obtain the temperature prediction value after a period of time, and calculate it with the daily target temperature set in the chicken house to obtain the predicted temperature deviation.

[0133] The specific solution is to process all the internal temperatures of the chicken houses into an average temperature inside the chicken houses, process all the internal humidity of the chicken houses into an average humidity inside the chicken houses, process all the internal wind speeds of the chicken houses into an average wind speed inside the chicken houses, and process all the internal carbon dioxide concentrations of the chicken houses into an average carbon dioxide concentration inside the chicken houses. The processing method is to remove missing values ​​and outliers and take the arithmetic mean. The external temperature of the chicken house, the external humidity of the chicken house, the external wind speed of the chicken house, the external air pressure of the chicken house, and the processed average temperature inside the chicken house, the average humidity inside the chicken house, the average wind speed inside the chicken house, the average carbon dioxide concentration inside the chicken house, the current negative pressure inside the chicken house, the target temperature inside the chicken house, the fan status, etc. are normalized using MinMaxScaler. All input features and target variables are normalized, and the values ​​of each feature and target variable are scaled to a fixed interval, usually [0, 1]. The normalization formula is:

[0134]

[0135] in, is the original data, and are the minimum and maximum values ​​of the feature respectively. The normalized value The normalized environmental parameter values ​​are input into the temperature prediction model to obtain the temperature prediction value after a period of time. and the daily target temperature set in the house Calculate and get the real-time temperature deviation , the calculation formula is:

[0136]

[0137] The TCN uses causal convolution to ensure that the output of the current time step depends only on the data of the current and previous time steps, and does not affect future time steps. The characteristic of the causal convolution is that the value of the previous layer at time t only depends on the value of the next layer at time t and before.

[0138] The process of adjusting the working state of the device includes:

[0139] S21, calculating the collected real-time temperature and the target temperature set in the chicken house to obtain a real-time temperature deviation;

[0140] S22, performing a difference calculation between the predicted temperature and the daily target temperature to obtain a predicted temperature deviation, and performing a difference calculation between the real-time temperature and the daily target temperature to obtain a real-time temperature deviation;

[0141] S23, weighting the two deviation values, balancing the deviation between the control parameter and the deviation value through proportional control, integral control and differential control, introducing the error change rate to prevent overshoot, calculating the control amount after the deviation is balanced through proportional control, integral control and differential control, and obtaining the expected ventilation volume;

[0142] The specific method is that the PID control module will real-time temperature deviation and predicted temperature deviation The weighted average of is taken as input to get the comprehensive error , the calculation formula is:

[0143]

[0144] in, is a weight parameter used to balance the impact of real-time data and predicted data.

[0145] The comprehensive error Input the error into the PID control module, calculate the PID control output, and get the output result As the expected ventilation rate, the calculation formula is:

[0146]

[0147] in, It is proportional control, used to quickly respond to temperature errors; For integral control, the error is accumulated to eliminate the deviation; For differential control, the error change rate is used to prevent overshoot. The formulas are:

[0148]

[0149]

[0150]

[0151] S24, the PID control module converts the expected ventilation volume into the required number of fans to be turned on and the duration of the fans to be turned on according to the expected ventilation volume, the volume of the chicken house, the number of fans and the air change volume per hour of a single fan;

[0152] S25, turning on the fans for ventilation according to the required number of fans and the turning-on time.

[0153] The specific method is that the fan control module further obtains the

[0154] As the total target ventilation rate, in m³ / h, combined with the house volume 、Number of fans , fan air change per hour Calculate the number of fans required to be turned on in real time , the calculation formula is:

[0155]

[0156] The upper limit is taken because the number of fans must be an integer. If the maximum ventilation capacity of all fans is exceeded, all fans will be turned on. On this basis, the actual time required for the fans to be turned on is calculated. , so that the ventilation volume meets the control requirements, the calculation formula is:

[0157]

[0158] The control parameters dynamically adjust the proportional coefficient, integral coefficient and differential coefficient in the PID control module by calculating the growth stage and weight gain, feed consumption and feed-to-meat ratio of the broiler.

[0159] The specific method is to input the daily weight gain, feed consumption and feed-to-meat ratio data of broilers into the feedback adjustment module of ventilation control, and automatically adjust the PID controller according to the changes in growth data. , , Parameters, so that ventilation more effectively supports the growth needs of broilers. The adjustment formula is:

[0160]

[0161]

[0162]

[0163] in, , , are the initial parameters of the PID controller, , , is the adjustment factor, , , It is a dynamic adjustment factor based on weight gain, feed consumption and feed-to-meat ratio in the broiler breeding stage, which is specifically expressed as a multiple linear regression equation:

[0164]

[0165]

[0166]

[0167] Among them, age is the age in days. The growth curve of chickens changes with age, and the weight of broilers has different growth patterns in different breeding stages. They are the temperature and humidity of the chicken house. Changes in environmental temperature and humidity have a significant impact on the appetite, digestion and metabolism of broilers, which in turn affects feed intake and weight gain; Good ventilation can maintain a suitable body temperature for chickens, thereby ensuring normal feeding and weight gain of broilers.

[0168] The chicken house temperature prediction algorithm based on TCN-Transformer includes the following modules:

[0169] A real-time monitoring module, which is used to collect real-time environmental data inside and outside the chicken house;

[0170] A temperature prediction module, which is used to predict the temperature in the chicken house based on time series data and historical environmental data;

[0171] A PID control module, the PID control module is used to receive the predicted temperature data of the temperature prediction module and the real-time temperature data of the real-time monitoring module, and generate a ventilation control output signal to control the ventilation equipment in the chicken house;

[0172] A fan control module, the fan control module is used to receive the ventilation control output signal of the PID control module, and control the number and opening time of the fan according to the ventilation control output signal, so as to control the temperature in the chicken house within a preset target temperature range;

[0173] A feedback adjustment module is used to dynamically adjust the parameters of the PID control module based on the production performance data of the broilers in the chicken house, so that the ventilation control output can adapt to the growth needs of the broilers in the chicken house.

[0174] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0175] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A chicken house temperature prediction algorithm based on TCN-Transformer, characterized in that: The steps are as follows, including, S01. Collect chicken house environmental data; S02, performing data processing on the collected chicken house environment data to obtain data to be tested, wherein the data processing method is to replace missing values ​​and abnormal values ​​in the data, then calculate the arithmetic mean and perform normalization processing; S03, inputting the data to be measured into the chicken house temperature prediction model for prediction to obtain the predicted temperature, wherein the temperature prediction model uses TCN and Transformer as the basic network; S04, input the predicted temperature into the PID control module, the PID control module performs difference calculation on the predicted temperature and the daily target temperature to obtain the predicted temperature deviation, performs difference calculation on the real-time temperature and the daily target temperature to obtain the real-time temperature deviation, performs weighted processing on the two deviation values, and adjusts the working state of the equipment in the chicken house in combination with the initial control parameters; S05. The daily weight gain, feed consumption and feed-to-meat ratio data of the broilers are input into the feedback adjustment module. The feedback adjustment module calculates the control parameters based on the daily weight gain, feed consumption and feed-to-meat ratio data of the broilers, and outputs them to the PID control module for dynamic adjustment of the equipment working state.

2. The chicken house temperature prediction algorithm based on TCN-Transformer according to claim 1 is characterized in that: The steps of data processing are: S11, the environmental data collected by each environmental sensor in the chicken house is used to form a data set arranged in time series, and the missing values ​​and abnormal values ​​in the data are replaced according to the linear trend of the adjacent points, and the data set is output; S12, obtaining the internal temperature data collected by each sensor in the chicken house in the data set, calculating and processing the temperature data inside the chicken house at the same time by taking the arithmetic mean, obtaining the average temperature inside the chicken house, and outputting the average temperature value inside the chicken house; S13, obtaining the internal humidity data collected by each sensor in the chicken house in the data set, calculating and processing the humidity data inside the chicken house at the same time by taking the arithmetic mean, obtaining the average humidity inside the chicken house, and outputting the average humidity value inside the chicken house; S14, obtaining the internal wind speed data collected by each sensor in the chicken house in the data set, calculating and processing the wind speed data inside the chicken house at the same time by taking the arithmetic mean, obtaining the average wind speed inside the chicken house, and outputting the average wind speed value inside the chicken house; S15, obtaining the CO2 concentration data collected by each sensor in the chicken house in the data set, calculating and processing the CO2 concentration data at the same time in the chicken house by taking the arithmetic mean, obtaining the average carbon dioxide concentration inside the chicken house, and outputting the average CO2 concentration value inside the chicken house; S16, obtaining the average temperature value inside the chicken house, the average humidity value inside the chicken house, the average wind speed value inside the chicken house and the average CO2 concentration value inside the chicken house, and normalizing these data to obtain and output the normalized processing result.

3. The chicken house temperature prediction algorithm based on TCN-Transformer according to claim 2 is characterized in that: The temperature prediction model includes a TCN part and a Transformer part; The TCN part includes a first input layer, a residual block layer and a first flattening layer; The Transformer part includes a second input layer, a multi-head attention mechanism, a normalization layer, and a second flattening layer; The TCN part and the Transformer part are connected by a connection layer, and the connection layer concatenates the output tensors of the first flattening layer and the second flattening layer on a specific axis to form a feature vector, and the feature vector contains information of all input tensors; The feature vector is converted into a final prediction value through a fully connected layer, which connects the information of all input tensors, performs linear transformation, introduces nonlinear features, and obtains the final prediction value.

4. The chicken house temperature prediction algorithm based on TCN-Transformer according to claim 3 is characterized in that: The residual block layer includes a one-dimensional convolution layer, a batch normalization layer and an activation layer. The one-dimensional convolution layer extracts key information from the time series data through the convolution kernel and outputs it to the batch normalization layer. The batch normalization layer receives the key information in the time series data and normalizes the key information in the time series data to obtain normalized information, and inputs the normalized information into the activation layer. The activation layer receives the normalized information, and uses the ReLU activation function to convert the normalized information into a multidimensional array, and outputs the multidimensional array to the first flattening layer.

5. The chicken house temperature prediction algorithm based on TCN-Transformer according to claim 4 is characterized in that: The prediction method of the temperature prediction model is that the TCN sub-network extracts local dependency features in the time series through a multi-layer convolutional network, and the Transformer sub-network captures the global relationship in the time series through a multi-head self-attention mechanism. The model predicts and outputs the temperature prediction value 5 minutes later, adopts an early stopping strategy to prevent the model from overfitting, and uses 5-fold cross validation to evaluate the model.

6. The chicken house temperature prediction algorithm based on TCN-Transformer according to claim 5 is characterized in that: The calculation processing method is to take the arithmetic mean after removing missing values ​​and outliers, and the normalization processing method is to scale the values ​​of the acquired data to a fixed interval to obtain the scaled data, input the scaled data into the temperature prediction model, obtain the temperature prediction value after a period of time, and calculate it with the daily target temperature set in the chicken house to obtain the predicted temperature deviation.

7. The chicken house temperature prediction algorithm based on TCN-Transformer according to claim 6 is characterized in that: The TCN uses causal convolution to ensure that the output of the current time step depends only on the data of the current and previous time steps without affecting future time steps; the characteristic of the causal convolution is that the value of the previous layer at time t only depends on the value of the next layer at time t and before.

8. The chicken house temperature prediction algorithm based on TCN-Transformer according to claim 7 is characterized in that: The adjusting the working state of the equipment in the chicken house includes: S21, calculating the collected real-time temperature and the target temperature set in the chicken house to obtain a real-time temperature deviation; S22, performing a difference calculation between the predicted temperature and the daily target temperature to obtain a predicted temperature deviation, and performing a difference calculation between the real-time temperature and the daily target temperature to obtain a real-time temperature deviation; S23, weighting the two deviation values, balancing the deviation between the control parameter and the deviation value through proportional control, integral control and differential control, introducing the error change rate to prevent overshoot, calculating the control amount after the deviation is balanced through proportional control, integral control and differential control, and obtaining the expected ventilation volume; S24, the PID control module converts the expected ventilation volume into the required number of fans to be turned on and the duration of the fans to be turned on according to the expected ventilation volume, the volume of the chicken house, the number of fans and the air change volume per hour of a single fan; S25, turning on the fans for ventilation according to the required number of fans and the turning-on time.

9. The chicken house temperature prediction algorithm based on TCN-Transformer according to claim 8 is characterized in that: The control parameters dynamically adjust the proportional coefficient, integral coefficient and differential coefficient in the PID control module by calculating the growth stage and weight gain, feed consumption and feed-to-meat ratio of the broiler.

10. The chicken house temperature prediction algorithm based on TCN-Transformer according to any one of claims 1 to 9, characterized in that: Includes the following modules, A real-time monitoring module, which is used to collect real-time environmental data inside and outside the chicken house; A temperature prediction module, which is used to predict the temperature in the chicken house based on time series data and historical environmental data; A PID control module, the PID control module is used to receive the predicted temperature data of the temperature prediction module and the real-time temperature data of the real-time monitoring module, and generate a ventilation control output signal to control the ventilation equipment in the chicken house; A fan control module, the fan control module is used to receive the ventilation control output signal of the PID control module, and control the number and opening time of the fan according to the ventilation control output signal, so as to control the temperature in the chicken house within a preset target temperature range; A feedback adjustment module is used to dynamically adjust the parameters of the PID control module based on the production performance data of the broilers in the chicken house, so that the ventilation control output can adapt to the growth needs of the broilers in the chicken house.

Citation Information

Cited By

  • Maneuvering target intelligent tracking method based on self-attention mechanism and physical constraint

    CN120065200A

  • AI-based granary three-dimensional ventilation precise temperature control method and system

    CN121072894A

  • An ai-based precise temperature control method and system for three-dimensional ventilation of a granary

    CN121072894B