Dynamic prediction method for yield of planting and breeding feces
By using a dynamic prediction model based on multi-source data fusion and LSTM+attention mechanism, combined with a real-time correction mechanism, the problem of dynamic trend prediction of manure production in poultry and livestock farms was solved. This enabled forward-looking prediction of future manure production and synergistic optimization of resource utilization, improving the accuracy and stability of the prediction results.
Patent Information
- Application Number
- CN202511496049.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-20
- Publication Date
- 2025-11-14
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing technologies for analyzing manure production in livestock farms mostly rely on static statistical methods, which cannot achieve dynamic trend prediction. This leads to a lag in the allocation of manure collection and treatment resources. Furthermore, the data collection dimensions are limited, lacking multi-source data fusion and real-time correction, making it difficult to adapt to changes in the farming environment and affecting the accuracy of prediction results and the efficiency of resource utilization.
A dynamic prediction model is constructed by using multi-source data acquisition and preprocessing, LSTM neural network combined with attention mechanism, and parameters are optimized through real-time correction mechanism to achieve forward-looking prediction of future manure production. Combined with edge computing and secure data transmission, a complete decision-making closed loop from prediction to resource allocation is formed.
It enables dynamic trend prediction of livestock manure production, improves the real-time performance and accuracy of prediction results, enhances the overall efficiency of manure resource utilization, and ensures stable operation of the model in complex farming environments.
Smart Images

Figure CN120950847A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of agricultural information technology, and particularly to a dynamic prediction method for the yield of breeding manure and sewage. Background Art
[0002] In the agricultural model of integrated farming and breeding, the resource utilization of livestock and poultry manure and sewage is an important link to achieve agricultural circular economy, and the accurate analysis and prediction of the manure and sewage yield are the basis for optimizing the processes of manure and sewage collection, treatment and field application. At present, the analysis of the manure production in livestock and poultry farms in the prior art mostly relies on static statistical methods. For example, through the recording of the solid manure yield and quality data within a set time period, combined with fixed thresholds (such as moisture content, livestock and poultry quantity matching degree) for anomaly detection; at the same time, the information management in the process of manure returning to the field mainly focuses on data recording and process traceability, and realizes data traceability through the form filling and review in the links of collection, treatment, detection, application, etc. These technical means meet the basic data management requirements to a certain extent, but neither of them involves the dynamic trend prediction of the manure production, and the data processing is mostly periodic static storage or batch input, making it difficult to reflect the impact of the changes in the breeding environment on the manure production in real time.
[0003] However, the prior art has obvious limitations: on the one hand, static statistics and threshold judgment can only achieve ex post anomaly investigation and cannot make a forward-looking prediction of the future manure production, resulting in a lag in the allocation of resources for manure and sewage collection, transportation and treatment, and prone to problems such as manure accumulation or insufficient treatment capacity; on the other hand, the data acquisition dimension is single, mostly relying on manual input or fixed sensor data, lacking the fusion analysis of multi-source data such as breeding environment, feed conditions, crop fertilizer requirements, etc., and the model does not set a real-time correction mechanism, making it difficult to adapt to dynamic factors such as the growth stage changes of livestock and poultry and feed formula adjustment during the breeding cycle, resulting in a large deviation between the analysis results of the manure production and the actual requirements. In addition, the prior art mostly focuses on the data management of a single link, and does not link the analysis of the manure production with the crop requirements, treatment capacity, etc. of manure returning to the field, and cannot form a coordinated optimization efficiency from prediction to resource allocation, restricting the coordinated optimization efficiency of the breeding and planting cycle. At the same time, some technical solutions lack consideration of engineering deployment and do not solve problems such as real-time data processing and edge environment adaptability, resulting in the difficulty of the technical model to be stably applied in the complex environment of the farm. Summary of the Invention
[0004] Aiming at the above-mentioned disadvantages of the prior art, the purpose of the present invention is to provide a dynamic prediction method for the yield of breeding manure and sewage to solve one or more problems in the prior art.
[0005] To achieve the above purpose, the technical solution of the present invention is as follows:
[0006] A dynamic prediction method for the yield of breeding manure and sewage, comprising the following steps:
[0007] S1. Multi-source data acquisition and preprocessing: Collect real-time data from the farm, historical data on manure return to the field, and external auxiliary data. After data cleaning and feature engineering, obtain 15-20 dimensional feature vectors.
[0008] S2. Construction of dynamic prediction model: The prediction model is constructed based on LSTM neural network and attention mechanism. The LSTM neural network includes 2-3 bidirectional LSTM layers. The number of hidden units in the first layer is 64-128 and the number of hidden units in the second layer is 32-64. The time step of the attention mechanism is 5-10 days.
[0009] S3. Real-time correction: The model parameters are updated every 24-48 hours based on the newly collected data, the prediction error is calculated and the prediction results are corrected, and the average absolute error of the prediction error is controlled within ≤5%.
[0010] Specifically, in step S1, the real-time data of the farm includes basic information on poultry and livestock, environmental parameters, feed data and equipment status, the historical data of manure returning to the field includes the amount of manure collected, the treatment method and the area returned to the field, and the external auxiliary data includes meteorological data and crop fertilizer requirement model parameters.
[0011] Specifically, in step S1, the data cleaning includes outlier removal and missing value processing. Outlier removal adopts the 3σ principle. In the missing value processing, short-term missing values are replaced by linear interpolation, and long-term missing values are replaced by the mean of historical data in the same time period. The feature engineering includes derived feature construction and feature selection. The derived features include feed conversion rate and environmental comfort index. The feature selection uses random forest feature importance screening to select the top 15-20 features.
[0012] Specifically, the Dropout of the LSTM neural network is 0.2-0.4, and the forward hidden state and backward hidden state of the bidirectional LSTM layer are concatenated to obtain the bidirectional hidden state; the attention mechanism includes attention score calculation, weight normalization and context vector generation.
[0013] Specifically, the cell state update of the LSTM neural network includes forget gate, input gate, and output gate control, specifically: the forget gate outputs f t It is calculated using the sigmoid activation function, and the calculation formula is as follows: W f Let b be the forget gate weight matrix. f For the forget gate bias, h t-1 x is the hidden state from the previous moment. t The input feature vector is the sigmoid activation function at the current time step; the input gate outputs i. t and candidate cell status The results are obtained by using sigmoid and tanh activation functions respectively, and the calculation formula is as follows: , W i W C Let b be the input gate weight matrix. i b C Input gate bias; cell state C t via f t Compared to the previous cell state C t-1 The product plus i t and The product is obtained by multiplying the product, and the calculation formula is: , where ⊙ represents element-wise multiplication; the output gate outputs o. t The current hidden state h is calculated using the sigmoid activation function. t via o t With tanh(C t The product of ) is obtained, and the calculation formula is: W o Let b be the output gate weight matrix. o This is used to bias the output gate.
[0014] Specifically, the attention score of the attention mechanism is calculated using an additive model, specifically: Attention Score , where e ti v is the correlation score between the current time t and the historical time step i. a W is a learnable vector. a U a h is a learnable matrix t Hide the current state. The hidden state is bidirectional; attention weight α ti It is obtained by normalization using the softmax function, and the calculation formula is as follows: Where k is the time step index; context vector C t It is obtained by weighting the attention weights and the bidirectional hidden states, and the calculation formula is as follows: .
[0015] Further, in step S3, the model parameters are updated using incremental gradient descent with a learning rate of 0.0005-0.002, which is dynamically adjusted according to the prediction error. The prediction error is calculated using the mean absolute error, and the calculation formula is as follows: Where N = 24 - 48, y t-1 This represents the actual manure production in hour ti. This corresponds to the predicted value; the prediction result is corrected through a correction coefficient λ, and the corrected predicted value is... λ is adjusted according to the growth stage of poultry and livestock, with λ=0.7-0.9 for young livestock and λ=0.2-0.4 for fattening livestock.
[0016] Furthermore, in step S3, the prediction results include short-term prediction and long-term trend prediction. The short-term prediction is the daily manure production and 95% confidence interval for the next 7-10 days, and the long-term trend prediction is the cumulative manure production and peak date for the next 30-60 days.
[0017] Specifically, it also includes model training and evaluation steps: Bayesian optimization is used to search for hyperparameters, and 5-10 fold time series cross-validation is performed. The hyperparameters include an LSTM learning rate of 0.001-0.003 and 50-100 iterations. The evaluation metric includes the coefficient of determination R. 2 and root mean square error, where the coefficient of determination R 2 ≥0.92, root mean square error ≤3%.
[0018] Furthermore, in step S1, the multi-source data is collected and preprocessed through an edge computing device. The edge computing device supports the MQTT protocol and HTTP interface. Data storage adopts a time-series database with a single-bucket storage period of 150-200 days. Data transmission is encrypted using the Secure Sockets Layer protocol, and data access adopts a role-based access control model.
[0019] Compared with the prior art, the beneficial technical effects of the present invention are as follows:
[0020] (i) By combining multi-source data fusion (real-time data from farms, historical data from manure return to fields, and external auxiliary data), dynamic prediction models using LSTM+attention mechanism, and real-time correction mechanisms, the static statistics or data recording of existing technologies are upgraded to dynamic trend prediction, enabling forward-looking prediction of future manure production. This changes the traditional post-event anomaly investigation or passive data recording model and provides a basis for advance planning for the resource utilization of manure.
[0021] (ii) By combining data cleaning (outlier removal and missing value handling), feature engineering (derived feature construction and feature selection) and real-time correction mechanisms, the adaptability of the prediction model to dynamic changes in the aquaculture environment is improved, ensuring the quality of input data and focusing on key influencing factors, so that the prediction results can be optimized in real time according to aquaculture conditions (such as feed adjustment and environmental changes), overcoming the problem of insufficient adaptability caused by existing technologies relying on fixed thresholds or human experience.
[0022] (III) By combining dynamic prediction results with the decision-making logic of manure resource utilization, the prediction of manure production is linked with factors such as crop fertilizer requirements and manure treatment capacity, forming a complete decision support closed loop from prediction to resource allocation. This achieves synergistic optimization of planting and breeding links, which is different from the limitations of existing technologies that only focus on data statistics or recording of a single link, and improves the overall efficiency of manure resource utilization.
[0023] (iv) By combining real-time data processing of edge computing devices, secure data transmission and storage mechanisms and model performance monitoring, an engineering-ready system architecture was constructed to ensure the stable operation of the model in the complex environment of the farm, and to guarantee the real-time performance and security of the data. This solved the problem of lack of engineering deployment that may exist in existing technologies and promoted the transformation of technical solutions from theoretical models to practical applications. Attached Figure Description
[0024] Figure 1 This is a schematic diagram of the operation flow of the prediction method in this invention. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and exemplary descriptions. It should be understood that the structures, proportions, sizes, etc., illustrated in the accompanying drawings are merely for illustrative purposes to aid those skilled in the art and are not intended to limit the implementation of this invention. Therefore, they have no substantial technical significance. Any modifications to the structure, changes in proportions, or adjustments to the size, without affecting the effects and objectives achieved by this invention, should still fall within the scope of the technical content disclosed in this invention.
[0026] Application Overview
[0027] In the field of integrated crop and livestock agriculture, the conventional methods for analyzing and managing livestock manure production mainly fall into two categories: one is based on static statistics of manure production analysis, which involves collecting data on the yield and quality of solid manure from livestock within a set time period, storing it in tabular form, and then retrieving the data at fixed intervals and judging whether the data is abnormal based on preset thresholds (such as moisture content range and livestock quantity matching relationship), thereby achieving basic statistics on manure production and subsequent anomaly investigation; the other is based on data recording and traceability of the manure return process, which involves building an information management system to collect work data from manure collection, treatment, testing, and application, forming tabular records and supporting process review to ensure the traceability of manure return data.
[0028] However, the aforementioned conventional solutions have significant shortcomings: First, static statistical methods can only passively analyze historical data and cannot predict the dynamic trend of future manure production. This leads to a lack of foresight in the allocation of manure collection, transportation, and treatment resources, easily resulting in manure accumulation or idle treatment capacity. Second, data collection is limited to a single dimension, relying heavily on manual input or single sensor data. It does not integrate multi-source data such as breeding environment parameters, feed conditions, and crop fertilizer requirements models, and lacks a real-time correction mechanism, making it difficult to adapt to dynamic factors such as changes in livestock growth stages and environmental fluctuations, resulting in significant discrepancies between analysis results and actual needs. Third, existing technologies mostly focus on data statistics or recording of a single link, failing to link manure production analysis with crop fertilizer requirements for manure return to the field and treatment capacity. This prevents the formation of a complete decision-making loop from prediction to resource allocation, hindering the synergistic optimization efficiency of crop-livestock cycles. In addition, some solutions lack consideration for engineering deployment and fail to address issues such as real-time data processing and adaptability to edge environments, making it difficult for technical models to be stably applied in the complex environment of farms.
[0029] Comprehensive explanation
[0030] Specific Implementation Methods for Dynamic Prediction of Livestock Manure Production
[0031] I. Multi-source data acquisition and preprocessing
[0032] This solution is based on the efficient acquisition and in-depth preprocessing of multi-source data, aiming to provide high-quality input data for subsequent prediction models. The specific process is as follows:
[0033] Data Acquisition: Three types of data are collected simultaneously through intelligent sensing devices deployed on the farm, the manure return management system interface, and third-party data services. Real-time farm data includes basic livestock information (breed, quantity, growth stage, such as piglets and fattening stages), environmental parameters (barn temperature, humidity, and ammonia concentration, collected via temperature and humidity sensors and ammonia sensors), feed data (daily feed amount, protein content, and crude fiber content, read via the RS485 interface of the intelligent feeding system), and equipment status (manure cleaning machine runtime and conveyor belt speed, collected via PLC controller). The collection frequency is set according to data characteristics: environmental parameters every 5 minutes, feed data once a day, and growth stage data once a week. Historical manure return data is obtained through the MySQL database of the manure return management system, including manure collection volume, treatment method (composting, biogas fermentation), returned area, and crop type (rice, corn, etc.). Data is collected after each batch of treatment or application. External auxiliary data includes meteorological data (rainfall, average daily temperature, obtained through the China Weather Network RESTful API) and crop fertilizer requirement model parameters (such as nitrogen requirement during rice tillering stage, accessed via the Ministry of Agriculture and Rural Affairs crop model library HTTP interface), collected once per day. All real-time data is transmitted to the edge computing terminal via the MQTT protocol, and historical data and external data are synchronized via HTTP interface or SQL query, ensuring data transmission latency ≤10 seconds.
[0034] Data preprocessing includes two stages: data cleaning and feature engineering. In the data cleaning stage, outliers are removed using the 3σ principle: the mean μ and standard deviation σ of the sensor data are calculated, and data exceeding the range [μ-3σ, μ+3σ] are identified as outliers and filled using the average of a 5-minute sliding window. For missing values, short-term missing values (<2 hours) are filled using linear interpolation, fitting values based on the trend of valid data before and after the missing point. Long-term missing values (>2 hours) are replaced by the average of historical data within the same time period (e.g., if a sensor has been faulty for 8 hours, the average of the same 8-hour data from the past 7 days is used). In the feature engineering stage, data representation capabilities are improved by constructing derived features and selecting key features: derived features include feed conversion ratio (daily feed intake / daily weight gain, reflecting feed utilization efficiency) and environmental comfort index ((measured temperature - suitable temperature)). 2 +(Actual humidity - Suitable humidity) 2 (Quantifying the impact of the environment on livestock metabolism); Feature selection adopts the random forest feature importance algorithm to sort the initial 25 original features (such as feed protein content, environmental temperature, etc.) and select the top 15-20 features with the highest importance (such as feed protein content, daily feeding amount, and environmental temperature with importance ratios of 18%, 15%, and 12%, respectively), forming the 15-20 dimensional feature vector of the final input model.
[0035] II. Construction of Dynamic Prediction Model
[0036] The dynamic prediction model is the core of this solution. It employs an LSTM neural network combined with an attention mechanism to achieve time-series prediction of livestock and crop manure production. This model significantly improves prediction accuracy by capturing the long-term and short-term dependencies and key feature influences in the time-series data.
[0037] Model Architecture: The model is divided into an input layer, an LSTM layer, an attention layer, and an output layer. The input layer receives preprocessed 15-20 dimensional feature vectors and uses a 7-day sliding window (time step T=7) as the input sequence, corresponding to the weekly management cycle of the farm. The LSTM layer contains 2-3 layers of bidirectional LSTM: the first layer has 64-128 hidden units, the second layer has 32-64 hidden units, and Dropout (scale 0.2-0.4) is used between layers to suppress overfitting; the bidirectional LSTM concatenates the hidden states through forward propagation (capturing future trends) and backward propagation (associating with historical information) to form a hidden state sequence that integrates bidirectional temporal features. The attention layer weights and focuses the hidden state sequence output by the LSTM, calculating the importance weights of features at each time step through an additive attention mechanism, and generating a context vector as input to the output layer. The output layer is a fully connected layer that outputs the predicted daily manure production for the next 1-7 days.
[0038] Core formula and its function:
[0039] (1) LSTM gate mechanism: In order to solve the gradient vanishing problem in traditional RNN prediction of long sequences, LSTM dynamically regulates cell state through forget gate, input gate and output gate to adapt to the long-term dependence characteristics of aquaculture data (such as the lag change in manure production 2-3 days after feed adjustment).
[0040] Forget gate: controls the proportion of historical cell states retained, the formula is as follows. Among them, W f Let b be the forget gate weight matrix. f As a bias, σ is the sigmoid activation function (output 0-1). In aquaculture scenarios, the forget gate can dynamically "forget" outdated information (such as the impact of last week's low-protein feed on current manure production) while retaining key information (such as the metabolic characteristics of the current growth stage). The preset environment is time-series data within a 7-day sliding window, and its key function is to avoid interference from irrelevant historical information in long sequences.
[0041] Input gate: controls the input intensity of new features, the formula is as follows (Input gate output) and (Candidate cell state). Via i t and The product of these features incorporates current high-importance characteristics (such as high-protein feed for the day) into the cell state, with the preset environment being the dynamic changes in daily feed and environmental data. Its key function is to capture the impact of sudden changes in breeding conditions on manure production in real time.
[0042] Cell State and Output Gate: The cell state update formula is as follows The output gate formula is The output in the hidden state is Cell states, acting as "memory carriers," are dynamically updated through a gating mechanism; the output gate filters information from the cell state that is relevant to the current prediction, ensuring the hidden state h is preserved. t The focus is on key characteristics of manure production prediction (such as the nonlinear relationship between ambient temperature and manure production).
[0043] (2) Attention mechanism: In order to solve the limitation of LSTM treating all time step features equally, the importance of each time step feature is quantified through the attention mechanism to adapt to the strong influence characteristics of key time points in the breeding data (such as high protein feed on Wednesday leading to a significant increase in manure production on Thursday).
[0044] Attention score: The correlation between the current time step and historical time steps is calculated using an additive model, and the formula is as follows. Among them, v a W is a learnable vector. a U a h is a learnable matrix t Hide the current state. This is a bidirectional LSTM stitched hidden state. The formula captures the complex relationships between features (such as the interaction between feed protein content and ambient temperature) through nonlinear transformation. The preset environment is the feature differences within a 7-day time step. Its key function is to dynamically identify the time step that has the greatest impact on manure production (such as the day of growth stage transition).
[0045] Attention weights and context vectors: The weight normalization formula is as follows The formula for the context vector is: By using softmax normalization, the weights are ensured to sum to 1; the context vector serves as the essence of the weighted fusion features, highlighting the impact of high-weight time steps (such as the feature contribution of high feeding on a certain day), making the model prediction more focused on key factors and improving the ability to capture abnormal manure production (such as sudden increases or decreases).
[0046] III. Real-time Correction Mechanism
[0047] To adapt to dynamic changes in the aquaculture environment (such as seasonal changes and feed formulation adjustments), the model needs to continuously optimize parameters through a real-time correction mechanism to ensure stable prediction accuracy.
[0048] Correction Process: Every 24-48 hours (adjusted according to the volatility of breeding data, such as 24 hours when data fluctuations are large during the fattening period), the system automatically triggers correction: First, it collects the actual manure production data (y) of the past 24-48 hours. t-1 ) and corresponding predicted value ( The mean absolute error (MAE) is calculated using the following formula: (N=24−48, corresponding to hourly data volume); secondly, incremental gradient descent is used to update the model parameters, with the learning rate set to η=0.0005−0.002, and dynamically adjusted according to MAE (the smaller the error, the lower the learning rate, to avoid overcorrection); finally, the predicted value for the next period is adjusted through the correction coefficient λ, using the formula: λ is adapted according to the growth stage of poultry and livestock (the metabolism fluctuates greatly during the juvenile stage, λ=0.7−0.9; it is stable during the fattening stage, λ=0.2−0.4).
[0049] Key role: The real-time correction mechanism, through a closed loop of "error feedback - parameter update - prediction adjustment", enables the model to continuously adapt to changes in aquaculture conditions (such as a decrease in metabolic rate caused by high summer temperatures), and controls the long-term prediction error to ≤5%, overcoming the shortcomings of traditional static models in adapting to environmental changes.
[0050] IV. System Integration and Engineering Deployment
[0051] To ensure the model can be stably implemented in the complex environment of a farm, an engineered system needs to be built through edge computing, data security, and performance monitoring.
[0052] Edge computing architecture: Adopting an "edge terminal + local server" architecture: The edge terminal (such as a Raspberry Pi 4B with 4-8GB of memory) deploys a sensor data receiving module (supporting the MQTT protocol) and a preprocessing program to achieve real-time data cleaning and feature extraction; the local server deploys a prediction model and a database (InfluxDB time-series database, with a single-bucket storage period of 150-200 days, adapted to the breeding cycle), supporting model training and prediction calculations. This architecture controls data processing latency to within 1 minute, reduces reliance on the cloud, and adapts to unstable network scenarios in livestock farms.
[0053] Data security and monitoring: Data transmission uses SSL / TLS 1.3 encryption to prevent leakage during transmission; access control is based on the RBAC model (hierarchical permissions for farm administrators and supervisors), and sensitive data (such as financial data and stocking density) is anonymized. Simultaneously, the system monitors model performance metrics (MAE, R) in real time. 2 The system monitors the data and hardware status (CPU / memory utilization). When MAE > 8% or hardware load > 80%, an alarm is triggered and non-core services (such as historical data queries) are automatically downgraded to ensure the stability of the core predictive functions.
[0054] Those skilled in the art can reproduce this scheme through the above steps: deploy sensors and interfaces according to the data acquisition process, perform preprocessing to generate feature vectors, build and train an LSTM+attention model based on a public deep learning framework (such as TensorFlow) (50-100 iterations, batch size 32), configure real-time correction parameters and system monitoring, and thus realize dynamic prediction and optimization of the yield of livestock and crop manure.
[0055] To verify the impact of key parameters in this scheme on the performance of the software system, the following experiment is designed based on "Information Security Technology: Technical Requirements and Test Evaluation Methods for Data Backup and Recovery Products" (GB / T 29765-2021) and "Systems and Software Engineering: System and Software Quality Requirements and Evaluation" (ISO / IEC 25010:2023). The system performance under different parameter combinations is compared using the controlled variable method to objectively evaluate the technical significance of the parameter limitation range.
[0056] I. Experimental Design
[0057] 1. Testing Standards and Methods
[0058] Prediction accuracy: Based on the "Functionality - Accuracy" test method in ISO / IEC 25010:2023, it is evaluated by comparing the mean absolute error (MAE) between the predicted and actual manure production. The calculation formula is as follows: , where y i This is the actual value. To obtain the predicted value, it is required to test 30 samples consecutively and take the average value.
[0059] Response time (time behavior): Based on the "Performance efficiency - time behavior" test method in ISO / IEC 25010:2023, 100 concurrent prediction requests were simulated using an automated script, and the time taken from receiving input to returning result was recorded. The median was taken as the response time.
[0060] System stability (maturity): Based on the "Self-security - Error monitoring" requirements in GB / T 29765-2021, the system is continuously run for 72 hours, and the number of errors such as abnormal exit, data loss or predicted interruption is counted. 0 times is the best, and ≤3 times is qualified.
[0061] 2. Variables and Experimental Group Design
[0062] Three core parameters were selected as variables in this scheme. Except for the variables, all other conditions (such as training data volume, hardware configuration, and aquaculture scenario) remained consistent in each experimental group.
[0063] Variable A: Number of hidden units in the first layer of the LSTM (Claim range: 64-128)
[0064] Variable B: Attention mechanism time step (claims limit: 5-10 days)
[0065] Variable C: Real-time correction period (claims limit: 24-48 hours)
[0066] Experimental group division:
[0067] Standard group (groups 1-5): Variables A, B, and C are all within the specified range, and their values cover the boundaries and intermediate values of the range;
[0068] Control group (groups 6-9): at least one of variables A, B, and C exceeds the specified range (e.g., A=32 or 160, B=3 or 12 days, C=12 or 72 hours).
[0069] Blank control group (10 groups): using existing technology (traditional ARIMA time series model, without attention mechanism and real-time correction).
[0070] 3. Weighted scoring calculation
[0071] Based on the ISO / IEC 25010:2023 "Quality Grade Classification" (Excellent, Good, Acceptable) and the GB / T 29765-2021 "Result Judgment" standard, the scoring rules are set as follows (Table 1):
[0072] Table 1. Performance Parameter Evaluation Table
[0073] Performance parameters Excellent (100 points) Good (80 points) Pass (60 points) Weight Prediction accuracy MAE≤5% 5% < MAE ≤ 8% 8% < MAE ≤ 12% 40% Response time ≤0.5 seconds 0.5 seconds < t ≤ 1.5 seconds 1.5 seconds < t ≤ 3 seconds 30% System stability Error count = 0 1≤Number of errors≤2 3 ≤ Number of errors ≤ 5 30%
[0074] Note: The score is calculated as follows: (Accuracy score × 40% + Response time score × 30% + Stability score × 30%). The score is based on a third-party standard threshold rather than a set of experimental data.
[0075] II. Experimental Results and Analysis
[0076] Experimental record form (Table 2)
[0077] Table 2. Performance Evaluation Table of Experimental Group
[0078] experimental group Variable A (Number of hidden units) Variable B (time steps / day) Variable C (correction period / hour) Prediction accuracy (MAE) (%) Response time (seconds) Number of errors (times) Weighted score (points) 1 64 5 24 4.23 0.89 0 89.60 2 96 7 36 3.85 0.62 0 95.20 3 128 10 48 4.56 1.03 1 87.80 4 80 8 30 3.98 0.75 0 93.40 5 112 6 42 4.31 0.92 0 90.20 6 32 7 36 8.72 1.85 2 68.40 7 160 12 36 9.15 2.43 3 62.60 8 96 3 12 10.38 1.67 2 64.80 9 96 7 72 8.45 1.92 4 61.20 10 - (ARIMA model) - (No attention mechanism) - (Uncorrected) 15.62 3.78 5 45.00
[0079] III. Experimental Conclusions
[0080] The weighted scores of the conventional groups (groups 1-5) were all above 85 points, significantly better than the control group (62.60-68.40 points) and the blank control group (45.00 points). Furthermore, the control group as a whole outperformed the blank group, verifying that the synergistic effect of variables A, B, and C within the defined range can improve system performance. Among them, group 2 (A=96, B=7, C=36) had the highest comprehensive score (95.20 points) due to its balanced parameter combination, indicating that there is no simple linear relationship between performance and variables, but rather relies on the optimal matching of multiple parameters, further confirming the technical necessity of limiting the parameter range.
[0081] Detailed analysis based on experimental data
[0082] The experimental results above clearly demonstrate the impact of different parameter combinations on system performance. The weighted scores of the conventional groups (groups 1-5) (87.80-95.20 points) were significantly higher than those of the control group (61.20-68.40 points) and the blank control group (45.00 points). Furthermore, within the conventional groups, a non-linear trend emerged where the intermediate parameter combination yielded the best performance (group 2 had the highest score, 95.20 points). To gain a deeper understanding of the synergistic mechanism of each technical feature, a detailed analysis needs to be conducted from three dimensions: prediction accuracy, response time, and system stability, in conjunction with the model architecture and code implementation logic.
[0083] I. Core Reasons for Overall Performance Differences
[0084] (I) Comparative analysis of the routine group, the control group, and the blank control group
[0085] The weighted score of the conventional group was significantly higher than that of the control group and the blank control group. The core reason is that the parameter combination strictly matches the temporal characteristics of the aquaculture data and the computational requirements of the model.
[0086] The blank control group (Group 10, ARIMA model): LSTM and attention mechanism were not used. The prediction was based solely on linear fitting of historical data, which failed to capture the nonlinear relationship of aquaculture data (such as the quadratic curve relationship between feed protein content and manure production). This resulted in a MAE as high as 15.62%, a response time of 3.78 seconds due to the lack of parallel computing optimization, and no real-time correction mechanism. There were 5 error reports, and the weighted score was only 45.00 points.
[0087] Control group (groups 6-9): Parameters exceeding the limit disrupted model balance: For example, in group 7, the number of hidden units was 160 (exceeding the upper limit of 128), and the excessive number of neurons in the LSTM layer in the code caused gradient diffusion during backpropagation (gradient values decay exponentially with the number of layers), resulting in redundant feature extraction and an MAE of 9.15%; in group 8, the time step was 3 days (below the lower limit of 5 days), and the attention mechanism could not capture the cyclical patterns of the breeding cycle (such as the lagging effect of weekend feed adjustments), resulting in incomplete capture of temporal dependencies and an MAE of 10.38%; in group 9, the correction period was 72 hours (exceeding the upper limit of 48 hours), the model parameters were updated lagging behind, and it could not adapt to environmental changes in a timely manner (such as a decrease in metabolic rate caused by sudden high temperatures), the number of error reports increased to 4, and the weighted score was only 61.20 points.
[0088] II. Code Hierarchy Explanation of Performance Trends within the Regular Group
[0089] (a) The impact of the number of hidden units in LSTM on performance (variable A)
[0090] In the regular groups, the performance differences between 64 (Group 1), 96 (Group 2), and 128 (Group 3) hidden units stem from the feature extraction capability configuration of the LSTM layer in the code:
[0091] Hidden unit number 64 (Group 1): With the LSTM (units=64) configuration in the code, the number of neurons is relatively small, and the ability to nonlinearly map high-dimensional aquaculture data (15-20-dimensional features) is insufficient. For example, it cannot distinguish the combined effects of "high protein feed + high temperature" and "low protein feed + suitable temperature". The MAE is 4.23%, which is slightly higher than Group 2.
[0092] Hidden unit number 128 (Group 3): Although LSTM (units=128) enhances feature representation, the regularization strength is not increased synchronously in the code (Dropout=0.3 fixed), which leads to an increased risk of overfitting. For example, it overfits to abnormally high feeding data in a certain week of the training set. When generalizing to the test set, the MAE rises to 4.56%, and the response time increases to 1.03 seconds due to the increased computation of neurons.
[0093] 96 hidden units (Group 2): LSTM (units=96) achieves a balance between feature extraction and computational efficiency in the code. With return_sequences=True, it outputs the hidden state of the entire sequence, providing richer temporal features for the attention mechanism. The MAE is reduced to 3.85%, and the response time is 0.62 seconds (due to the moderate amount of computation, the GPU parallel efficiency is the highest).
[0094] (ii) The impact of the attention mechanism time step on performance (variable B)
[0095] The differences in time steps of 5 days (Group 1), 7 days (Group 2), and 10 days (Group 3) stem from the timing window configuration for attention weight calculation in the code:
[0096] 5-day time step (Group 1): When time_steps=5 in the code, the attention window only covers 5 days of data, which cannot fully capture the cycle pattern of breeding (such as the fluctuation of feed input from Monday to Sunday), resulting in insufficient capture of the lagging correlation of "high protein feeding on Wednesday → peak manure production on Friday", with an MAE of 4.23%.
[0097] Time step 10 days (Group 3): When time_steps=10, the window is too large, and the attention score calculation in the code ( The hidden states of more time steps need to be processed. After weight normalization, key features (such as feed mutations on a certain day) are diluted, the MAE is 4.56%, and the response time increases to 1.03 seconds due to the amount of matrix operations.
[0098] 7-day time step (Group 2): time_steps=7 is perfectly aligned with the weekly management cycle (7 days). The attention mechanism in the code can accurately locate key time steps each week (such as feed adjustment on Wednesday), with focused weights (the attention weight of a certain time step reaches 0.32, higher than the average of 0.14 for other time steps), reducing MAE to 3.85%, and with a moderate amount of computation (7×96 hidden state matrix) and a response time of 0.62 seconds.
[0099] (III) The impact of real-time correction cycle on performance (variable C)
[0100] The differences in correction periods of 24 hours (Group 1), 36 hours (Group 2), and 48 hours (Group 3) stem from the frequency configuration of parameter update logic in the code.
[0101] Correction period 24 hours (Group 1): When update_interval=24 in the code, the parameter updates are too frequent. Each update requires loading 24 hours of new data (n=24 samples), causing GPU resources to switch frequently between "prediction calculation" and "parameter update". The response time increases to 0.89 seconds. Although the MAE is low (4.23%), the system resource competition causes potential stability risks (no errors occurred but the response was delayed).
[0102] Correction period 48 hours (Group 3): When update_interval=48, the update interval is too long, and new data (such as feed formula adjustments) cannot be fed back to the model in a timely manner, resulting in the MAE accumulating to 4.56% in the 48th hour. In addition, error_threshold=5% in the code triggers anomaly detection, and the number of error reports increases to 1.
[0103] The correction period of 36 hours (Group 2) balances data freshness and computing resources. The code enables an independent thread to handle parameter updates through threading.Thread(target=update_model) to avoid blocking the main prediction thread. The response time is 0.62 seconds, and the 36-hour sample size (n=36) is sufficient to cover short-term fluctuations in aquaculture data (such as daily temperature changes). The MAE is the lowest (3.85%), and there are 0 error reports.
[0104] (iv) Synergistic effect: Code logic for the second group of optimal parameter combinations
[0105] The second group (96 hidden units, 7-day time steps, 36-hour correction cycle) received the highest weighted score (95.20 points), stemming from the collaborative optimization of multiple modules in the code:
[0106] Feature extraction and temporal capture are combined: The feature extraction capability of LSTM (units=96) is combined with the temporal focus of Attention (time_steps=7). In the code, the hidden states of bidirectional LSTM are concatenated by Concatenate(), so that the attention weight is accurately located to the 7-day cycle correlation of "feed-environment-manure production". For example, the attention weight on day 4 (time step 4) reaches 0.28, which corresponds to the lagged effect of feed protein peak on manure production.
[0107] Real-time correction and resource scheduling coordination: Independent thread updates with update_interval=36 (threading.Lock() avoids resource conflicts), combined with a dynamic learning rate of learning_rate=0.001*exp(-MAE / 5%), only the weights of the attention layer and fully connected layer are fine-tuned when updating parameters in the code (trainable=False freezes the LSTM layer), reducing the computational cost by 60%, and optimizing response time and stability simultaneously.
[0108] In summary, the coordinated configuration of the number of LSTM hidden units, attention time steps, and real-time correction cycle in the code is the core reason why Group 2 achieves "high precision, fast response, and zero errors," verifying the necessity and adaptability of each technical feature in the model architecture.
[0109] Exemplary Description
[0110] Example 1
[0111] Multi-source data acquisition and preprocessing: Real-time data from the farm (livestock breeds, ambient temperature, daily feed intake, with an acquisition frequency of 5 minutes / time for environmental parameters and 1 time / day for feed data), historical data on manure return to the field (collection volume and processing method), and external auxiliary data (meteorological data and crop fertilizer requirements) are collected simultaneously. Outliers are removed using the 3σ principle, and missing values are processed by linear interpolation. Derived features such as feed conversion rate are constructed, and the Top 15 features are selected through random forest to form a 15-dimensional feature vector.
[0112] Dynamic prediction model construction: A two-layer bidirectional LSTM (64 hidden units in the first layer and 32 in the second layer) is used, with Dropout=0.3 and an attention mechanism time step of 5 days. The attention score is calculated using an additive model and the weights are normalized to output the predicted manure production for the next 7 days. During model training, 5-fold time series cross-validation is used. Historical data is divided into 5 subsets in chronological order (each subset contains 45 consecutive days of aquaculture data). One subset is selected as the validation set and the remaining 4 subsets are selected as the training set. The model converges after 50 iterations. The validation set determination coefficient R is... 2 The value reached 0.94, with a root mean square error of 2.8%.
[0113] Real-time correction: New data is collected every 24 hours, MAE is calculated to be 4.23%, and incremental gradient descent (learning rate 0.001) is used to update the model parameters, with a correction coefficient λ=0.8;
[0114] System operation: Data is processed at the edge terminal, stored in a time-series database, transmitted using SSL encryption, and performance monitoring shows no abnormal errors.
[0115] Variables: 64 hidden units, 5-day time step, 24-hour correction cycle.
[0116] Performance data: Prediction accuracy (MAE) 4.23%, response time 0.89 seconds, number of errors 0, weighted score 89.60.
[0117] Example 2
[0118] The difference from Example 1 is that the variable part has 96 hidden units, a time step of 7 days, and a correction period of 36 hours; the performance data is a prediction accuracy (MAE) of 3.85%, a response time of 0.62 seconds, 0 errors, and a weighted score of 95.20.
[0119] Example 3
[0120] The difference from Example 1 is that the variable part has 128 hidden units, a time step of 10 days, and a correction period of 48 hours; the performance data is a prediction accuracy (MAE) of 4.56%, a response time of 1.03 seconds, 1 error, and a weighted score of 87.80.
[0121] Example 4
[0122] The difference from Example 1 is that the variable part has 80 hidden units, 8 days in time, and 30 hours in correction period; the performance data is a prediction accuracy (MAE) of 3.98%, a response time of 0.75 seconds, 0 errors, and a weighted score of 93.40.
[0123] Example 5
[0124] The difference from Example 1 is that the variable part has 112 hidden units, a time step of 6 days, and a correction period of 42 hours; the performance data is a prediction accuracy (MAE) of 4.31%, a response time of 0.92 seconds, 0 errors, and a weighted score of 90.20.
[0125] Example 6
[0126] The difference from Example 1 is that the number of hidden units is 32 (out of range), the time step is 7 days, and the correction period is 36 hours; the performance data is a prediction accuracy (MAE) of 8.72%, a response time of 1.85 seconds, 2 errors, and a weighted score of 68.40.
[0127] Example 7
[0128] The difference from Example 1 is that the variable part has 160 hidden units (out of range), 12 days time step (out of range), and 36 hours correction period; the performance data is prediction accuracy MAE 9.15%, response time 2.43 seconds, 3 error reports, and weighted score of 62.60.
[0129] Example 8
[0130] The difference from Example 1 is that the variable part has 96 hidden units, a time step of 3 days (out of range), and a correction period of 12 hours (out of range); the performance data is a prediction accuracy (MAE) of 10.38%, a response time of 1.67 seconds, 2 errors, and a weighted score of 64.80.
[0131] Example 9
[0132] The difference from Example 1 is that the variable part has 96 hidden units, a time step of 7 days, and a correction period of 72 hours (out of range); the performance data is a prediction accuracy (MAE) of 8.45%, a response time of 1.92 seconds, 4 errors, and a weighted score of 61.20.
[0133] Example 10 (Blank Control)
[0134] Multi-source data acquisition: Only basic historical manure production data of the farm is collected (no real-time environmental or feed data), with a collection frequency of once per day; Preprocessing: Simple cleaning (removal of obvious outliers), no feature engineering, and direct use of raw manure production time-series data; Model building: ARIMA model is used (without LSTM and attention mechanisms), and prediction is based on linear fitting of historical data; No real-time correction mechanism: Model parameters are fixed and are not updated with new data; System operation: No edge computing optimization, data transmission is unencrypted, and it relies on regular manual maintenance.
[0135] Variables: No hidden unit count (ARIMA model), no attention time step, no real-time correction cycle.
[0136] Performance data: Prediction accuracy (MAE) 15.62%, response time 3.78 seconds, number of errors 5, weighted score 45.00.
[0137] Specific work process
[0138] Please refer to Figure 1 Multi-source data is collected synchronously through intelligent sensing devices, the manure return management system interface, and third-party data services. Real-time data from the farm is collected by sensors and transmitted to the edge computing terminal via the MQTT protocol. Historical data on manure return is obtained through a database interface, and external auxiliary data is synchronized to the local server via API calls. The collected data is first cleaned, outliers are identified and removed using the 3σ principle, short-term missing data is filled with linear interpolation, and long-term missing data is replaced with the mean of historical data in the same time period. Subsequently, feature engineering is performed to construct derived features such as feed conversion rate and environmental comfort index. Key features are selected using a random forest feature importance algorithm to form the feature vector for the input model.
[0139] The feature vector is input into the dynamic prediction model. The model first processes the time-series data through an LSTM layer. The LSTM's forget gate calculates the retention ratio of historical cell states, the input gate controls the strength of new feature inclusion, and the cell states are dynamically updated through the interaction of the forget gate and the input gate. The output gate filters the information in the cell states that is relevant to the prediction and generates a hidden state sequence. The attention mechanism weights and focuses the hidden state sequence output by the LSTM. The correlation score of the features at each time step is calculated through an additive model, and the attention weights are obtained by softmax normalization. The weighted and fused hidden states generate a context vector, which is input into the fully connected layer and outputs the predicted fecal production value.
[0140] Every set period, the system automatically collects new actual manure production data and corresponding predicted values, calculates the mean absolute error, updates the model parameters using the incremental gradient descent method, and dynamically adjusts the learning rate according to the error. At the same time, it adjusts the predicted values for the next period through correction coefficients, which are adapted according to the growth stage of poultry and livestock, to achieve real-time optimization of the prediction results.
[0141] Edge computing terminals handle data acquisition and preprocessing in real time, while local servers run prediction models and real-time correction logic. Data transmission is secured using encryption protocols. The system monitors model errors and hardware status in real time through a performance monitoring module, ensuring dynamic operation of the entire process from data acquisition, preprocessing, model prediction to result correction, forming a closed loop for continuous prediction and optimization of livestock manure production.
[0142] The technical features described above can be combined in any way. For the sake of brevity, not all possible combinations of the technical features described above 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.
Claims
1. A dynamic prediction method for the yield of livestock and crop manure, characterized in that: Includes the following steps: S1. Multi-source data acquisition and preprocessing: Collect real-time data from the farm, historical data on manure return to the field, and external auxiliary data. After data cleaning and feature engineering, obtain 15-20 dimensional feature vectors. S2. Construction of dynamic prediction model: The prediction model is constructed based on LSTM neural network and attention mechanism. The LSTM neural network includes 2-3 bidirectional LSTM layers. The number of hidden units in the first layer is 64-128 and the number of hidden units in the second layer is 32-64. The time step of the attention mechanism is 5-10 days. S3. Real-time correction: The model parameters are updated every 24-48 hours based on the newly collected data, the prediction error is calculated and the prediction results are corrected, and the average absolute error of the prediction error is controlled within ≤5%.
2. The dynamic prediction method for the yield of livestock and crop manure as described in claim 1, characterized in that: In step S1, the real-time data of the farm includes basic information on poultry and livestock, environmental parameters, feed data and equipment status, the historical data of manure return to the field includes the amount of manure collected, the treatment method and the area returned to the field, and the external auxiliary data includes meteorological data and crop fertilizer requirement model parameters.
3. The dynamic prediction method for the yield of livestock and crop manure as described in claim 1, characterized in that: In step S1, the data cleaning includes outlier removal and missing value processing. The outlier removal uses a 3... In principle, short-term missing values are replaced by linear interpolation, while long-term missing values are replaced by the mean of historical data within the same time period. The feature engineering includes the construction of derived features and feature selection. The derived features include feed conversion rate and environmental comfort index. The feature selection uses random forest feature importance screening to select the top 15-20 features.
4. The dynamic prediction method for the yield of livestock and crop manure as described in claim 1, characterized in that: The Dropout of the LSTM neural network is 0.2-0.
4. The forward hidden state and the backward hidden state of the bidirectional LSTM layer are concatenated to obtain the bidirectional hidden state. The attention mechanism includes attention score calculation, weight normalization and context vector generation.
5. The dynamic prediction method for the yield of livestock and crop manure as described in claim 4, characterized in that: The cell state update of the LSTM neural network includes forget gate, input gate, and output gate control, specifically: the forget gate outputs f. t It is calculated using the sigmoid activation function, and the calculation formula is as follows: W f Let b be the forget gate weight matrix. f For the forget gate bias, h t-1 x is the hidden state from the previous moment. t The input feature vector is the sigmoid activation function at the current time step; the input gate outputs i. t and candidate cell status The results are obtained by using sigmoid and tanh activation functions respectively, and the calculation formula is as follows: , W i W C Let b be the input gate weight matrix. i b C Input gate bias; cell state C t via f t Compared to the previous cell state C t-1 The product plus i t and The product is obtained by multiplying the product, and the calculation formula is: , where ⊙ represents element-wise multiplication; Output gate output o t The current hidden state h is calculated using the sigmoid activation function. t via o t With tanh(C t The product of ) is obtained, and the calculation formula is: W o Let b be the output gate weight matrix. o This is used to bias the output gate.
6. The dynamic prediction method for the yield of livestock and crop manure as described in claim 4, characterized in that: The attention score of the attention mechanism is calculated using an additive model, specifically: Attention Score , where e ti v is the correlation score between the current time t and the historical time step i. a W is a learnable vector. a U a h is a learnable matrix t Hide the current state. The hidden state is bidirectional; attention weight α ti It is obtained by normalization using the softmax function, and the calculation formula is as follows: Where k is the time step index; context vector C t It is obtained by weighting the attention weights and the bidirectional hidden states, and the calculation formula is as follows: .
7. The dynamic prediction method for the yield of livestock and crop manure as described in claim 1, characterized in that: In step S3, the model parameters are updated using incremental gradient descent with a learning rate of 0.0005-0.002, which is dynamically adjusted according to the prediction error. The prediction error is calculated using the mean absolute error, and the calculation formula is as follows: Where N = 24 - 48, y t-1 This represents the actual manure production in hour ti. This corresponds to the predicted value; the prediction result is corrected through a correction coefficient λ, and the corrected predicted value is... λ is adjusted according to the growth stage of poultry and livestock, with λ=0.7-0.9 for young livestock and λ=0.2-0.4 for fattening livestock.
8. The dynamic prediction method for the yield of livestock and crop manure as described in claim 1, characterized in that: In step S3, the prediction results include short-term prediction and long-term trend prediction. The short-term prediction is the daily manure production and 95% confidence interval for the next 7-10 days, and the long-term trend prediction is the cumulative manure production and peak date for the next 30-60 days.
9. The dynamic prediction method for the yield of livestock and crop manure as described in claim 1, characterized in that, It also includes model training and evaluation steps: Bayesian optimization is used to search for hyperparameters, and 5-10 fold time series cross-validation is performed. The hyperparameters include an LSTM learning rate of 0.001-0.003 and 50-100 iterations. The evaluation metric includes the coefficient of determination R. 2 and root mean square error, where the coefficient of determination R 2 ≥0.92, root mean square error ≤3%.
10. The dynamic prediction method for the yield of livestock and crop manure as described in claim 1, characterized in that: In step S1, the multi-source data is collected and preprocessed through an edge computing device. The edge computing device supports the MQTT protocol and HTTP interface. Data storage adopts a time-series database with a single bucket storage period of 150-200 days. Data transmission is encrypted using the Secure Sockets Layer protocol, and data access adopts a role-based access control model.
Citation Information
Patent Citations
Vibration transmission system based on CNN-LSTM
CN111832228A
Resin material adsorption capacity prediction model and prediction method thereof
CN118280490A
Annotation generation method and device of intelligent automobile software source code
CN118708238A
Urban hazardous waste yield prediction method based on EMD-LSTM model
CN120338162A
Cited By
Resource integration management method and system for cooperative treatment of livestock and poultry manure
CN121481177A
Intelligent decision management method and system for resource output in planting and breeding combined mode
CN121638828A