A method and system for monitoring animal and plant food quality and optimizing shelf life

Through deep learning models and dynamic optimization algorithms, multi-source heterogeneous data of animal and plant foods are analyzed, precise monitoring of food quality and scientific optimization of shelf life are achieved, and the problems of insufficient data utilization and undynamic shelf life setting in traditional methods are solved, which improves the level of food safety management and economic benefits.

CN118917726BActive Publication Date: 2025-03-11JILIN JINYUN LONCIN FOOD CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410966892.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-18
Publication Date
2025-03-11
Estimated Expiration
2044-07-18

AI Technical Summary

Technical Problem

Traditional food quality monitoring methods are difficult to obtain comprehensive and real-time diverse factors that affect food quality, resulting in underutilization of data resources and the current shelf life setting is difficult to dynamically adjust, which may lead to waste of resources or food safety risks.

Method used

By obtaining multi-source heterogeneous data of animal and plant food, pre-processing and inputting into a deep learning model for prediction, combining dynamic optimization algorithm models to optimize the shelf life, achieving accurate monitoring of food quality and scientific optimization of shelf life.

Benefits of technology

It significantly improves the level of food safety management and economic benefits, realizes real-time and refined monitoring of food quality and dynamic and personalized adjustments of shelf life, reducing resource waste and food safety risks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118917726B_ABST
    Figure CN118917726B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and system for monitoring the quality and optimizing the shelf life of animal and plant foods, and relates to the technical field of food quality monitoring, including: acquiring multi-source heterogeneous data of animal and plant foods, preprocessing the multi-source heterogeneous data of animal and plant foods, and obtaining a preprocessed animal and plant food data set; inputting the preprocessed animal and plant food data set into a pre-established deep learning model, and outputting a deep learning prediction result, wherein the deep learning model is optimized based on a comparison result between the deep learning prediction result and the actual quality; setting a quality threshold, comparing the deep learning prediction result with the quality threshold, if it is higher than the quality threshold, the food quality meets the requirements, and if it is lower than the quality threshold, triggering an early warning signal for early warning prompting; inputting the deep learning prediction result into a pre-established dynamic optimization algorithm model, and outputting an optimal shelf life.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of food quality monitoring, and in particular to a method and system for monitoring the quality of animal and plant food and optimizing the shelf life. Background Art

[0002] With the development of social economy and the improvement of consumers' demand for food quality, the quality monitoring and shelf life management of animal and plant foods have received increasing attention. However, when dealing with the complex and changing food production environment, storage conditions and consumer demand, traditional methods have the following problems: Traditional monitoring mainly relies on manual detection and limited sensor data, and it is difficult to obtain comprehensive and real-time multiple factors affecting food quality, such as environmental parameters, biochemical indicators, operation records, etc., resulting in insufficient use of data resources; the current shelf life is usually set based on laboratory experiments or empirical formulas, which makes it difficult to fully consider the complex variables in the actual production, storage and sales process, and it is impossible to achieve individualized and dynamic adjustment of the shelf life, which may lead to resource waste due to a short shelf life and increased food safety risks due to a long shelf life; the ability to identify and warn of potential risks in food quality is weak, and intervention is often carried out only after the problem occurs, lacking forward-looking and preventive quality management measures. Summary of the invention

[0003] In order to solve the deficiencies mentioned in the above background technology, the purpose of the present invention is to provide a method and system for monitoring the quality and optimizing the shelf life of animal and plant foods, which realizes the precise monitoring of food quality and the scientific optimization of the shelf life, and significantly improves the level of food safety management and economic benefits.

[0004] In the first aspect, the purpose of the present invention can be achieved by the following technical solution: a method for monitoring the quality and optimizing the shelf life of animal and plant food, the method comprising the following steps:

[0005] Acquire multi-source heterogeneous data of animal and plant foods, preprocess the multi-source heterogeneous data of animal and plant foods, and obtain a preprocessed animal and plant food data set;

[0006] Inputting the preprocessed animal and plant food data set into a pre-established deep learning model, and outputting a deep learning prediction result, wherein the deep learning model is optimized based on a comparison result between the deep learning prediction result and the actual quality;

[0007] Set a quality threshold and compare the deep learning prediction result with the quality threshold. If it is higher than the quality threshold, the food quality meets the requirements. If it is lower than the quality threshold, an early warning signal is triggered to issue an early warning prompt.

[0008] The deep learning prediction results are input into the pre-established dynamic optimization algorithm model, and the optimal shelf life is output.

[0009] In combination with the first aspect, in certain implementations of the first aspect, the method also includes: the multi-source heterogeneous data of animal and plant foods includes: covering raw material growth environment parameters, breeding and planting management records, processing process parameters, storage environment monitoring data, logistics tracking information and sales terminal feedback.

[0010] In combination with the first aspect, in some implementations of the first aspect, the method further includes: the process of preprocessing the multi-source heterogeneous data of animal and plant foods includes:

[0011] Complex data cleaning, integration and conversion techniques are applied to construct a data set for subsequent analysis. The time series analysis model involved is based on a deep bidirectional LSTM combined with an attention mechanism, and the anomaly detection model is based on autoencoder AE and isolation forest.

[0012] In combination with the first aspect, in some implementations of the first aspect, the method further includes: a process in which the time series analysis model performs time series analysis:

[0013] Input time series data X = (X1, X2, ..., X n ), including environmental parameters, food characteristic indicators, and sensor data, among which X n Represents the food quality monitoring index vector at the nth moment;

[0014] The input sequence is processed using a bidirectional LSTM network to capture the forward and backward dependencies in the time series:

[0015]

[0016] in, and are the hidden states of the forward and backward LSTMs respectively;

[0017] Based on the output of the bidirectional LSTM, an attention mechanism is applied to dynamically assign weights to different time steps:

[0018]

[0019] Among them, α t is the attention weight at the tth time step, and S is the weighted context vector;

[0020] Anomaly detection using anomaly detection models:

[0021] Input multidimensional time series data X of food quality n ;

[0022] By training the autoencoder to learn the low-dimensional representation of the data, there is a reconstruction error when reconstructing abnormal data:

[0023]

[0024] is the average number of nodes in the tree, which is different from the original data X n The difference can be used as a measure of the anomaly score;

[0025] Data reconstructed from the autoencoder Then, the isolation forest process is performed. iForest constructs multiple random decision trees and determines the degree of abnormality based on the average path length of the data points in the tree:

[0026]

[0027] in, point The average path length in the forest, is the average number of nodes in the tree;

[0028] For the data at each time point, an anomaly score is provided. The higher the score, the greater the probability that the data point is an outlier.

[0029] In combination with the first aspect, in certain implementations of the first aspect, the method further includes: the process of inputting the preprocessed animal and plant food data set into a pre-established deep learning model and outputting a deep learning prediction result is as follows:

[0030] Input data:

[0031] First, the quality data of food during the entire monitoring period is organized into a time series X n The input is in the form of food image I, including color and shape. The basic information of food is input as static attribute A, including type and production date.

[0032] Architecture steps:

[0033] Data preprocessing, X n Normalization is performed to achieve time series standardization; I is resized, normalized, and noise removed to achieve image preprocessing, and then features are extracted from image I through CNN to obtain a feature vector V = CNN (I; Θ CNN ); The static attribute A is converted into a vector E = Embedding(A; Θ) through the embedding layer Emb );

[0034] Based on deep bidirectional LSTM combined with attention mechanism time series modeling, using the weighted context vector S:

[0035]

[0036] in, and are the hidden states of the forward and backward LSTM, α t is the attention weight at the t-th time step, S is the weighted context vector, It means that these two hidden state vectors are concatenated to form a vector containing two direction information, W a is a weight matrix, b a is a bias vector, W T is a weight vector, tanh is the hyperbolic tangent function, and the softmax function converts the attention scores of all time steps into probability distributions;

[0037] Comprehensive feature construction, combining the final output S of LSTM, the image feature vector V and the static attribute vector E:

[0038] F=Concatenate(S,V,E)

[0039] Prediction output, input the fused feature F into the fully connected layer MLP to make the final prediction of food quality:

[0040]

[0041] in, represents the predicted food quality score, Θ MLP is the parameter set of MLP.

[0042] In combination with the first aspect, in some implementations of the first aspect, the method further includes: constructing the pre-established dynamic optimization algorithm model:

[0043] Based on the deep bidirectional LSTM combined with the attention mechanism food quality prediction, the attention-enhanced bidirectional LSTM model is introduced to capture the nonlinear trend of food quality over time, and focus on the time point features that have the greatest impact on the shelf life through the attention mechanism:

[0044]

[0045] Among them, α t is the attention weight at time step t, S is the weighted context vector, Score the predicted food quality.

[0046] In combination with the first aspect, in certain implementations of the first aspect, the method further includes: the process of inputting the deep learning prediction result into a pre-established dynamic optimization algorithm model and outputting the optimal shelf life is as follows:

[0047] The dynamic optimization algorithm model combines the predicted trend of food quality changes with the time series analysis method, taking into account environmental factors, storage conditions, and sales speed.

[0048] Profit maximization f1(X): The goal is to maximize overall profit by optimizing shelf life and inventory management strategies; profit is expressed as sales revenue minus costs, including procurement costs, storage costs, and loss costs due to expiration; let the unit price of the product be p, the unit cost be c, and the sales volume in time period t be q t , the loss is d t , then the profit function is expressed as:

[0049]

[0050] Minimize the loss cost f2(X): The loss cost is directly related to the amount of expired food and is expressed as:

[0051]

[0052] Maximizing customer repurchase rate f3(X): The customer repurchase rate is related to the freshness, availability and price of food. In the model, satisfaction is positively correlated with the repurchase rate and negatively correlated with the price, which can be expressed as:

[0053]

[0054] in, is the weight parameter, dFreshness t represents the freshness index of food at time t, p t is the average selling price at time t, q t For sales volume;

[0055] Environmental constraints j (X; E)≤0,j=1,…,m

[0056] Ensure that the food storage environment meets safety standards, j (X; E) = T store (X)-T max ≤0, where T store is the expected storage temperature calculated based on the decision variable X, T max is the maximum permissible temperature;

[0057] Resource and inventory constraints k (X)=0,k=1,…,n

[0058] Keep inventory levels within a reasonable range, h1(X)=I tatal (X)-I capacity =0, where I tatalis the estimated total inventory, I capacity For storage capacity.

[0059] In a second aspect, in order to achieve the above-mentioned purpose, the present invention discloses a system for monitoring the quality of animal and plant food and optimizing the shelf life, comprising:

[0060] A data processing module is used to obtain multi-source heterogeneous data of animal and plant foods, pre-process the multi-source heterogeneous data of animal and plant foods, and obtain a pre-processed animal and plant food data set;

[0061] A model prediction module, used to input the preprocessed animal and plant food data set into a pre-established deep learning model, and output a deep learning prediction result, wherein the deep learning model is optimized based on the comparison result between the deep learning prediction result and the actual quality;

[0062] The quality analysis module is used to set the quality threshold and compare the deep learning prediction results with the quality threshold. If it is higher than the quality threshold, the food quality meets the requirements. If it is lower than the quality threshold, an early warning signal is triggered for early warning.

[0063] The shelf life optimization module is used to input the deep learning prediction results into the pre-established dynamic optimization algorithm model and output the optimal shelf life.

[0064] In conjunction with the second aspect, in certain implementations of the second aspect, the system further includes: the multi-source heterogeneous data of animal and plant food in the data processing module includes: covering raw material growth environment parameters, breeding and planting management records, processing process parameters, storage environment monitoring data, logistics tracking information and sales terminal feedback;

[0065] The process of preprocessing multi-source heterogeneous data of animal and plant foods in the data processing module includes:

[0066] Apply complex data cleaning, integration and conversion techniques to build data sets for subsequent analysis. The time series analysis model involved is based on deep bidirectional LSTM combined with attention mechanism, and the anomaly detection model is based on autoencoder AE and isolation forest.

[0067] The process of time series analysis by the time series analysis model in the data processing module:

[0068] Input time series data X = (X1, X2, ..., X n ), including environmental parameters, food characteristic indicators, and sensor data, among which X n Represents the food quality monitoring index vector at the nth moment;

[0069] The input sequence is processed using a bidirectional LSTM network to capture the forward and backward dependencies in the time series:

[0070]

[0071] in, and are the hidden states of the forward and backward LSTMs respectively;

[0072] Based on the output of the bidirectional LSTM, an attention mechanism is applied to dynamically assign weights to different time steps:

[0073]

[0074] Among them, α t is the attention weight at the tth time step, and S is the weighted context vector It means that these two hidden state vectors are concatenated to form a vector containing two direction information, W a is a weight matrix, b a is a bias vector, W T is a weight vector, tanh is the hyperbolic tangent function, and the softmax function converts the attention scores of all time steps into probability distributions;

[0075] Anomaly detection using anomaly detection models:

[0076] Input multidimensional time series data X of food quality n ;

[0077] By training the autoencoder to learn the low-dimensional representation of the data, there is a reconstruction error when reconstructing abnormal data:

[0078]

[0079] is the average number of nodes in the tree, which is different from the original data X n The difference can be used as a measure of the anomaly score;

[0080] Data reconstructed from the autoencoder Then, the isolation forest process is performed. iForest constructs multiple random decision trees and determines the degree of abnormality based on the average path length of the data points in the tree:

[0081]

[0082] in, point The average path length in the forest, is the average number of nodes in the tree;

[0083] For the data at each time point, an anomaly score is provided. The higher the score, the greater the probability that the data point is an outlier.

[0084] In the model prediction module, the preprocessed animal and plant food data set is input into the pre-established deep learning model, and the process of outputting the deep learning prediction result is as follows:

[0085] Input data:

[0086] First, the quality data of food during the entire monitoring period is organized into a time series X n The input is in the form of food image I, including color and shape. The basic information of food is input as static attribute A, including type and production date.

[0087] Architecture steps:

[0088] Data preprocessing, X n Normalization is performed to achieve time series standardization; I is resized, normalized, and noise removed to achieve image preprocessing, and then features are extracted from image I through CNN to obtain a feature vector V = CNN (I; Θ CNN ); The static attribute A is converted into a vector E = Embedding(A; Θ) through the embedding layer Emb );

[0089] Based on deep bidirectional LSTM combined with attention mechanism time series modeling, using the weighted context vector S:

[0090]

[0091] in, and are the hidden states of the forward and backward LSTM, α t is the attention weight at the t-th time step, S is the weighted context vector, It means that these two hidden state vectors are concatenated to form a vector containing two direction information, W a is a weight matrix used to map the concatenated hidden state to a new space whose dimension is different from the original hidden state space, b a is a bias vector that increases the flexibility of the model, W Tis a weight vector used to calculate the attention score from the mapped space. Tanh is the hyperbolic tangent function, which is used as a nonlinear activation function to convert the mapped vector into a numerical value within a range. The softmax function converts the attention scores of all time steps into a probability distribution, ensuring that the sum of the attention weights of all time steps is 1, which allows the model to compare the relative importance of different time steps.

[0092] Comprehensive feature construction, combining the final output S of LSTM, the image feature vector V and the static attribute vector E:

[0093] F=Concatenate(S,V,E)

[0094] Prediction output, input the fused feature F into the fully connected layer MLP to make the final prediction of food quality:

[0095]

[0096] in, represents the predicted food quality score, Θ MLP is the parameter set of MLP;

[0097] Construction of pre-established dynamic optimization algorithm model in the shelf life optimization module:

[0098] Based on the deep bidirectional LSTM combined with the attention mechanism food quality prediction, the attention-enhanced bidirectional LSTM model is introduced to capture the nonlinear trend of food quality over time, and focus on the time point features that have the greatest impact on the shelf life through the attention mechanism:

[0099]

[0100] Among them, α t is the attention weight at time step t, S is the weighted context vector, Score the predicted food quality;

[0101] In the shelf life optimization module, the deep learning prediction results are input into the pre-established dynamic optimization algorithm model, and the process of outputting the optimal shelf life is as follows:

[0102] The dynamic optimization algorithm model combines the predicted trend of food quality changes with the time series analysis method, taking into account environmental factors, storage conditions, and sales speed.

[0103] Profit maximization f1(X): The goal is to maximize overall profit by optimizing shelf life and inventory management strategies; profit is expressed as sales revenue minus costs, including procurement costs, storage costs, and loss costs due to expiration; let the unit price of the product be p, the unit cost be c, and the sales volume in time period t be q t , the loss is d t , then the profit function is expressed as:

[0104]

[0105] Minimize the loss cost f2(X): The loss cost is directly related to the amount of expired food and is expressed as:

[0106]

[0107] Maximizing customer repurchase rate f3(X): The customer repurchase rate is related to the freshness, availability and price of food. In the model, the repurchase rate is positively correlated with freshness and negatively correlated with price, which can be expressed as:

[0108]

[0109] in, is the weight parameter, dFreshness t represents the freshness index of food at time t, p t is the average selling price at time t, q t For sales volume;

[0110] Environmental constraints j (X; E)≤0,j=1,…,m

[0111] Ensure that the food storage environment meets safety standards, j (X; E) = T store (X)-T max ≤0, where T store is the expected storage temperature calculated based on the decision variable X, T max is the maximum permissible temperature;

[0112] Resource and inventory constraints k (X)=0,k=1,…,n

[0113] Keep inventory levels within a reasonable range, h1(X)=I tatal (X)-I capacity =0, where I tatal is the estimated total inventory, I capacity For storage capacity.

[0114] In another aspect of the present invention, in order to achieve the above-mentioned purpose, a terminal device is disclosed, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the memory stores a computer program capable of running on the processor, and when the processor loads and executes the computer program, the method for monitoring the quality and optimizing the shelf life of animal and plant food as described above is adopted.

[0115] Beneficial effects of the present invention:

[0116] Based on the deep mining of big data, the system of the present invention can comprehensively and deeply grasp the various factors affecting food quality, realize real-time and refined monitoring of the quality of animal and plant foods, and significantly improve the monitoring accuracy and predictability; based on the deep mining results and real-time quality evaluation, the system can dynamically and individually set the shelf life of food, which not only avoids the waste of resources caused by too short a shelf life, but also prevents the food safety risks caused by too long a shelf life, and improves the scientificity and flexibility of shelf life management; accurate quality monitoring and shelf life optimization help reduce the loss caused by quality degradation, reduce the cost of recalls and returns, improve resource utilization efficiency, and bring significant economic benefits to enterprises. The present invention has constructed an efficient and intelligent new food quality management system by deeply integrating big data deep mining technology with food quality monitoring and shelf life management, which is of great value to improving food safety levels, protecting consumer rights, and promoting the sustainable development of the food industry. BRIEF DESCRIPTION OF THE DRAWINGS

[0117] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0118] Figure 1 It is a framework diagram of the method of the present invention;

[0119] Figure 2 This is a schematic diagram of the deployment of a distributed environment monitoring sensor network of the present invention;

[0120] Figure 3 It is a schematic diagram of the satellite remote sensing technology of the present invention;

[0121] Figure 4 This is a flow chart of identifying and processing outliers based on a statistical method machine learning algorithm (DBSCAN) of the present invention;

[0122] Figure 5 Setting the quality threshold for the present invention is a flow chart for setting the quality threshold;

[0123] Figure 6It is a schematic diagram of the system structure of the present invention;

[0124] Figure 7 is a comparison chart of loss costs in this embodiment;

[0125] Figure 8 is the profit growth bar chart of this embodiment;

[0126] Fig. 9 It is a pie chart of the customer repurchase rate ratio before the experiment of this embodiment;

[0127] Fig.10 It is a pie chart of the customer repurchase rate ratio after the experiment in this embodiment. DETAILED DESCRIPTION

[0128] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0129] Embodiment 1:

[0130] The following is an introduction to the relevant terms involved in the embodiments of the present application:

[0131] Multi-source heterogeneity: The fusion of multi-source heterogeneous data sources is to integrate data from different data sources, different formats or different structures together to make more comprehensive and accurate analysis and decision-making. This process involves multiple steps such as data cleaning, data integration, and data conversion.

[0132] Deep Learning: Deep Learning (DL) is a new research direction in the field of Machine Learning (ML). It is introduced into machine learning to make it closer to its original goal - Artificial Intelligence (AI).

[0133] Deep learning is the process of learning the inherent laws and representation levels of sample data. The information obtained in the learning process is of great help in interpreting data such as text, images, and sounds. Its ultimate goal is to enable machines to have analytical learning capabilities like humans and to recognize data such as text, images, and sounds. Deep learning is a complex machine learning algorithm that has achieved results in speech and image recognition that far exceed previous related technologies.

[0134] like Figure 1 As shown, a method for monitoring the quality and optimizing the shelf life of animal and plant food comprises the following steps:

[0135] Obtain multi-source heterogeneous data of animal and plant foods, preprocess the multi-source heterogeneous data of animal and plant foods, and obtain the preprocessed animal and plant food dataset. The time series analysis model involved in the process is based on deep bidirectional LSTM combined with attention mechanism, and the anomaly detection model is based on autoencoder (AE) and isolation forest (iForest);

[0136] The multi-source heterogeneous data of animal and plant food includes: raw material growth environment parameters, breeding and planting management records, processing parameters, storage environment monitoring data, logistics tracking information and sales terminal feedback;

[0137] Specifically, the present invention is further described below by way of embodiments:

[0138] Data collection, which widely collects multivariate and heterogeneous data on the animal and plant food production chain from multiple channels, covers raw material growth environment parameters, breeding / planting management records, processing parameters, storage environment monitoring data, logistics tracking information, and sales terminal feedback. The process includes the following steps:

[0139] like Figure 2 As shown, the raw material growth environment parameters are collected by using a distributed environmental monitoring sensor network to collect soil temperature, humidity, nutrient content, pH value, conductivity, and heavy metal ion concentration micro-environmental parameters in real time;

[0140] like Figure 3 As shown, satellite remote sensing technology is used to regularly obtain macro-environmental data of the planting area, vegetation index, NDVI (normalized difference vegetation index), land cover type, and climate change information; combined with the geographic information system (GIS), the spatial distribution information is combined with environmental parameters to form a high-precision spatial environmental map;

[0141] Integration of breeding / planting management records: By integrating the internal ERP system of the enterprise, it automatically captures and integrates the management data of the entire planting / breeding process, including the source of seeds / seedlings, sowing / feeding time, fertilizer / feed type and amount, pest and disease control measures, harvesting / slaughtering time, key time nodes and events; it provides a mobile APP entrance for farmers to manually enter daily management records to ensure data integrity;

[0142] Monitoring and recording of processing parameters: arranging automated data acquisition equipment at key nodes of the production line to record the temperature, humidity, pressure, and time process parameters of the processing process in real time; using AI visual recognition technology to monitor and record changes in color, shape, and size appearance characteristics during the processing process; integrating the operating data of processing equipment, such as equipment operating time, failure rate, and maintenance records, and linking them to the processing parameters of a specific batch of products;

[0143] Synchronize storage environment monitoring data, install intelligent temperature and humidity sensors, gas detectors and other equipment to monitor the storage environment of food in the warehouse around the clock to ensure that the temperature, humidity, oxygen and carbon dioxide concentration environmental parameters are maintained within an appropriate range; implement a warehouse location management system to record the physical state information such as the storage time, storage location, and stacking height of each batch of food; remotely monitor and record the data of vehicle-mounted temperature control equipment during cold chain transportation to ensure the integrity of the cold and hot chains of food throughout the entire storage and transportation process;

[0144] Logistics tracking information collection, using GPS positioning system and RFID tag technology to track the location and movement of goods in the logistics process in real time, record the time of goods in transit, where they stay, and changes in temperature and humidity; connect with the logistics company system to obtain node information such as departure, arrival, loading and unloading of transport vehicles, and analyze logistics efficiency and factors that may affect food quality;

[0145] Feedback analysis at the sales terminal: obtain sales orders, user reviews, and return and exchange record sales data through the backend interface of the e-commerce platform, and analyze consumers' purchasing habits, satisfaction, and quality complaints; combine with the offline store POS system to collect sales speed, inventory turnover rate, and commercial operation data of each sales terminal; combine with shelf life monitoring to observe the quality change trend of food in the terminal sales link, and feedback to the shelf life optimization model.

[0146] The process of preprocessing multi-source heterogeneous data of animal and plant foods includes:

[0147] Complex data cleaning, integration and conversion techniques are applied to construct a data set for subsequent analysis. The time series analysis model involved is based on a deep bidirectional LSTM combined with an attention mechanism, and the anomaly detection model is based on autoencoder AE and isolation forest.

[0148] Data cleaning: remove obvious errors, missing and unreasonable data points; use interpolation methods to fill in missing data; identify and process outliers based on statistical methods and machine learning algorithms (DBSCAN);

[0149] Data integration: integrating data from different sources and different time periods in production and storage to build a continuous time series data set;

[0150] Data transformation, standardization / normalization: For continuous variables, use Z-score standardization to make them have the same scale and distribution characteristics; Sequence data adjustment: Convert non-time series data into time series data, and map discrete production records and storage records to a continuous time axis;

[0151] The process of time series analysis model for time series analysis:

[0152] Input time series data X = (X1, X2, ..., X n ), including environmental parameters, food characteristic indicators, and sensor data, among which X n Represents the food quality monitoring index vector at the nth moment;

[0153] First, the input sequence is processed using a bidirectional LSTM network to capture the forward and backward dependencies in the time series:

[0154]

[0155] in, and are the hidden states of the forward and backward LSTMs respectively;

[0156] Based on the output of the bidirectional LSTM, an attention mechanism is applied to dynamically assign weights to different time steps, emphasizing the information that is more important for prediction. :

[0157]

[0158] Among them, α t is the attention weight at the t-th time step, S is the weighted context vector, It means that these two hidden state vectors are concatenated to form a vector containing two direction information, W a is a weight matrix used to map the concatenated hidden state to a new space whose dimension is different from the original hidden state space, b a is a bias vector that increases the flexibility of the model, W T is a weight vector used to calculate the attention score from the mapped space. Tanh is the hyperbolic tangent function, which is used as a nonlinear activation function to convert the mapped vector into a numerical value within a range. The softmax function converts the attention scores of all time steps into a probability distribution, ensuring that the sum of the attention weights of all time steps is 1, which allows the model to compare the relative importance of different time steps.

[0159] Finally, the anomaly detection model is used for anomaly detection:

[0160] Identify and process outliers based on statistical machine learning algorithms (DBSCAN), including:

[0161] a1. Parameter setting: ε (epsilon): neighborhood radius, real number; MinPts: minimum neighborhood point threshold, positive integer.

[0162] a2. Calculate the neighbor relationship:

[0163] Given a data set D = {X1, X2, ..., X n}, where X i ∈Rd is a d-dimensional feature vector.

[0164] Choose a distance metric function dist(X i ,X j ), Euclidean distance:

[0165]

[0166] Calculate the distance matrix M between each pair of sample points in the data set, where M ij = dist(X i ,X j )

[0167] a3. Mark core points and boundary points:

[0168] For a data point X i , whose ε-neighborhood is defined as:

[0169] N∈(X i )={X j ∈D:dist(X i ,X j )≤∈}

[0170] If |N∈(X i )∣≥Mibpts, then X i is a core point; otherwise, if X i If a point is located in the ε-neighborhood of a core point, it is a boundary point.

[0171] a4. Density reachable and density connection:

[0172] Density reachability relation: If there exists a point sequence X i ,X i+1 ,...,X j , satisfying that for all k, dist(X k ,X k+1 )≤∈ and X k is the core point, then X i From X j Density can reach.

[0173] Density connection: If there is a density-reachable path such that X i and X j All the intermediate points between them are core points, then X i and X j Density connection.

[0174] a5. Forming clusters:

[0175] Starting from any core point, traverse all points that are reachable by its density and classify these points (including core points and boundary points) into the same cluster; repeat this process until all core points are included in one cluster.

[0176] a6. Identify outliers:

[0177] An outlier (noise point) is defined as a point that does not belong to any cluster (i.e., is not density-reachable) and has fewer samples in its ε-neighborhood than Mibpts.

[0178] a7. Handling outliers:

[0179] Elimination: Remove outliers from the dataset D to obtain the purified dataset D′.

[0180] Marking: Keep outliers but mark them specially so that normal data can be distinguished from abnormal data in subsequent analysis for anomaly detection or further study of abnormal patterns.

[0181] Correction: In some cases, outliers may be due to measurement errors or entry errors, which can be corrected through interpolation, smoothing or other data repair techniques.

[0182] Ignore: In some application scenarios, the impact of outliers may be small, and you can choose to ignore them during analysis.

[0183] Input multidimensional time series data X of food quality n ;

[0184] Then, the autoencoder is trained to learn the low-dimensional representation of the data. Abnormal data will have a large reconstruction error when reconstructed:

[0185]

[0186] is the average number of nodes in the tree, which is different from the original data X n The difference can be used as a measure of the anomaly score;

[0187] Data reconstructed from the autoencoder Then perform isolation forest processing to further identify outliers. iForest constructs multiple random decision trees and determines the degree of anomaly based on the average path length of the data point in the tree:

[0188]

[0189] in, point The average path length in the forest, is the average number of nodes in the tree;

[0190] For the data at each time point, an anomaly score is provided. The higher the score, the greater the probability that the data point is an outlier.

[0191] Inputting the preprocessed animal and plant food data set into a pre-established deep learning model, and outputting a deep learning prediction result, wherein the deep learning model is optimized based on a comparison result between the deep learning prediction result and the actual quality;

[0192] Deep learning modeling adopts a hybrid architecture that combines recurrent neural networks (RNN), especially deep bidirectional LSTM combined with attention mechanism and multi-layer perceptron (MLP) to make full use of time series data and food attribute characteristics to achieve accurate prediction of food quality status and establish a food quality prediction model framework representation:

[0193] a1. Input data: First, organize the quality data (temperature, humidity, pH value) of the food during the entire monitoring period into a time series X n The form is used as input; the quality changes (color, shape) of food appearance are organized into food image I as input; the basic information of food (type, production date) is input as static attribute A.

[0194] a2. Data preprocessing, X n Normalization is performed to achieve time series standardization; I is resized, normalized, and noise removed to achieve image preprocessing, and then features are extracted from image I through CNN to obtain a feature vector V = CNN (I; Θ CNN ); The static attribute A is converted into a vector E = Embedding(A; Θ) through the embedding layer Emb ).

[0195] a3. Based on deep bidirectional LSTM combined with attention mechanism time series modeling, in step S20, the weighted context vector S is used:

[0196]

[0197] in, and are the hidden states of the forward and backward LSTM, α t is the attention weight of the t-th time step, S is the weighted context vector, It means that these two hidden state vectors are concatenated to form a vector containing two direction information, W a is a weight matrix used to map the concatenated hidden state to a new space whose dimension is different from the original hidden state space, b ais a bias vector that increases the flexibility of the model, W T is a weight vector used to calculate the attention score from the mapped space. Tanh is the hyperbolic tangent function, which is used as a nonlinear activation function to convert the mapped vector into a numerical value within a range. The softmax function converts the attention scores of all time steps into a probability distribution, ensuring that the sum of the attention weights of all time steps is 1, which allows the model to compare the relative importance of different time steps.

[0198] a4. Comprehensive feature construction, combining the final output S of LSTM, the image feature vector V and the static attribute vector E:

[0199] F=Concatenate(S,V,E)

[0200] a5. Prediction output: Input the fused feature F into the fully connected layer (MLP) to make the final prediction of food quality:

[0201]

[0202] in, represents the predicted food quality score, Θ MLP is the parameter set of MLP.

[0203] Set a quality threshold and compare the deep learning prediction result with the quality threshold. If it is higher than the quality threshold, the food quality meets the requirements. If it is lower than the quality threshold, an early warning signal is triggered to issue an early warning prompt.

[0204] like Figure 4 As shown, in step 4, quality monitoring and early warning, setting quality thresholds according to deep learning prediction results includes:

[0205] a1. Consult the national standards and industry standards of the relevant food industry to understand the quality indicators and their allowable ranges for specific food types.

[0206] a2. Study applicable food safety regulations to ensure that the thresholds set meet the requirements of laws and regulations

[0207] a3. Analyze the company's internal historical data, identify the impact of different production stages, seasons, raw material batches and other factors on food quality, and determine a reasonable quality fluctuation range; consult industry experts or internal technicians to set more precise quality thresholds based on their professional knowledge and experience

[0208] a4. Use the trained deep learning model to predict the real-time or future food quality and obtain the predicted value y^; compare the predicted value of the quality index with the corresponding threshold T

[0209] a5. When the predicted value is lower than (or higher than, depending on the specific situation) the quality threshold, i.e., ŷ < T (or ŷ > T), a warning signal is triggered.

[0210] a6. According to the warning signal, producers or managers take corresponding adjustment measures, such as optimizing process parameters, strengthening raw material screening, improving storage conditions, etc., to ensure that the food quality is restored to the qualified range.

[0211] Input the deep learning prediction results into a pre-established dynamic optimization algorithm model, and the optimal shelf life is output.

[0212] Among them, the dynamic optimization algorithm model combines the predicted food quality change trend, uses the time series analysis method, and comprehensively considers multiple factors such as environmental factors, storage conditions, and sales speed.

[0213] Based on the food quality prediction of deep bidirectional LSTM combined with the attention mechanism, an attention-enhanced bidirectional LSTM (A-BiLSTM) model is introduced to capture the non-linear trend of food quality changing over time, and the attention mechanism focuses on the time point features that have the greatest impact on the shelf life.

[0214]

[0215] Among them, α t is the attention weight at time step t, S is the weighted context vector, is the predicted food quality or shelf life status.

[0216] a2. Profit maximization (f1(X)): The goal is to maximize the overall profit by optimizing the shelf life and inventory management strategies; the profit can be expressed as the sales revenue minus the costs, including the procurement cost, storage cost, and loss cost caused by expiration; let the selling price per unit product be p, the unit cost be c, the sales volume within the time period t be q t , and the loss amount be d t , then the profit function can be expressed as:

[0217]

[0218] a3. Minimization of loss cost (f2(X)): Reducing the loss caused by food expiration is another important goal. The loss cost is directly related to the quantity of expired food and can be expressed as:

[0219]

[0220] a4. Maximize customer repurchase rate (f3(X)): Customer repurchase rate is usually related to the freshness, availability and price of food. In the model, the repurchase rate is positively correlated with freshness and negatively correlated with price, which can be expressed as:

[0221]

[0222] in, is the weight parameter, dFreshness t represents the freshness index of food at time t, p t is the average selling price at time t, q t For sales volume, these are affected by shelf life setting and inventory management strategies.

[0223] a5. While optimizing these objective functions, a series of constraints must be observed to ensure the feasibility of the solution:

[0224] a. Environmental constraints (g j (X; E)≤0, j=1,…,m):

[0225] Ensure that the food storage environment (temperature, humidity) meets safety standards, j (X; E) = T store (X)-T max ≤0, where T store is the expected storage temperature calculated based on the decision variable X, T max is the maximum allowable temperature

[0226] b. Resource and inventory constraints (h k (X)=0,k=1,…,n)

[0227] Keep inventory levels within a reasonable range to avoid overstocking or out-of-stock, h1(X)=I tatal (X)-I capacity =0, where I tatal is the estimated total inventory, I capacity For storage capacity.

[0228] The deep learning model is optimized based on the comparison between the deep learning prediction results and the actual quality:

[0229] 1. Reinforcement learning and dynamic strategy adjustment:

[0230] a1. Establish a reinforcement learning environment, where at each time step t, the state of the environment S t Contains food quality prediction of S40 as described in the current product Inventory I t , Environmental conditions (such as temperature, humidity) E, Sales speed V tFeatures. Action space a t Includes different shelf life adjustment strategies.

[0231] a2. Reward function design, reward R t At time step t, the consequences of executing action A are determined by profit contribution: actions that increase profit should receive positive rewards, and actions that decrease profit should receive negative rewards. t The single-period profit for the profit maximization (f1(X)) can be defined as: R t =α·(P t -P t-1 ), where α is the weight coefficient of profit; C t The loss cost is the loss cost of minimizing (f2(X)), and the loss reward can be expressed as: R t =β·(C t -C t-1 ), where β is the weight coefficient of loss; F t is the customer satisfaction that maximizes the customer satisfaction (f3(X)), denoted by R t =δ·(F t -F t-1 ), where δ is the weight of customer satisfaction. Combining the above reward function:

[0232] R t =α·(P t -P t-1 )-β·(C t -C t-1 )+δ·(F t -F t-1 )+ω·I t

[0233] Among them, ω is the weight coefficient of inventory management, I t It reflects the optimization of inventory levels, such as too much or too little inventory may lead to negative rewards.

[0234] a3. Initialization: Build two deep neural networks (NN), one is the target network Q(s,a|θ - ), and the other is the evaluation network Q(s,a|θ), which share the same architecture but different parameters. - Represent the weights of the evaluation network and the target network respectively.

[0235] Select action: select a with probability 1-∈ t = argmax a Q(S t ,a|θ), randomly select an action with probability ∈.

[0236] Experience replay: Each time a step is executed, the tuple (St ,a t ,R t ) is stored in the experience replay buffer D, and a batch of experiences are randomly extracted from it for learning.

[0237] Learning update: randomly sample a small batch of experience from D and calculate the target value Y t =R t +Ymax a’ Q'(S t ,a'|θ - ), where a' = argmax a’ Q(S t ,a|θ), and finally update the evaluation network parameters θ to reduce the TD error:

[0238]

[0239] Target network update: Regular soft update of target network parameters:

[0240] θ - ←τθ+(1-τ)θ -

[0241] Practical verification case: Optimizing the shelf life of strawberry supply chain

[0242] 1. Data collection and preprocessing

[0243] Data source: Strawberry sales data from a local large supermarket chain from January to April of the past year was collected, including daily sales volume, return volume, temperature records, and humidity records.

[0244] Data preprocessing: clean the data, remove outliers and missing values, standardize temperature and humidity data, and encode dates as time series features.

[0245] 2. Model construction and training

[0246] Quality prediction model: A deep bidirectional LSTM combined with attention mechanism (A-BiLSTM) model is used. The input includes historical sales data, environmental factors (temperature, humidity) and strawberry quality indicators, and the output is the prediction of strawberry quality in the next week.

[0247] Shelf life optimization model: Based on the D-DRL (distributed deep reinforcement learning) framework, especially the dual DQN algorithm, the shelf life strategy is dynamically adjusted to adapt to market changes and environmental fluctuations.

[0248] 3. Experimental Design

[0249] Baseline strategy: Use the traditional static shelf life strategy, that is, all strawberries have a uniform shelf life of 7 days.

[0250] Experimental strategy: Apply the above A-BiLSTM prediction model and D-DRL optimization strategy to dynamically adjust the shelf life and make real-time decisions based on the predicted quality and environmental changes.

[0251] 4. Experimental Results

[0252] Loss cost: Under the experimental strategy, the loss cost was reduced to about 25%, indicating that the dynamic adjustment of shelf life strategy effectively reduced the amount of expired food.

[0253] Profit growth: The experimental strategy achieved approximately 10% profit growth due to reduced shrinkage and optimized inventory management.

[0254] Customer feedback: Under the experimental strategy, customer repurchase rate increased by 12%.

[0255] 5. Verify charts and data

[0256] Loss cost comparison chart: shows the time series comparison of loss costs before and after the experiment, intuitively showing the effect of the experimental strategy.

[0257] Profit growth bar chart: Compares monthly profits before and after the experiment, highlighting the economic benefits brought by strategy optimization.

[0258] Customer repurchase rate ratio pie chart: The pie chart shows the comparison of customer repurchase rate ratios before and after the experiment, reflecting the positive changes in customer feedback.

[0259] Embodiment 2: In the second aspect, as Figure 6 As shown, in order to achieve the above-mentioned purpose, the present invention discloses a system for monitoring the quality of animal and plant food and optimizing the shelf life, comprising:

[0260] The data processing module 11 is used to obtain multi-source heterogeneous data of animal and plant foods, pre-process the multi-source heterogeneous data of animal and plant foods, and obtain a pre-processed animal and plant food data set;

[0261] A model prediction module 12 is used to input the preprocessed animal and plant food data set into a pre-established deep learning model, and output a deep learning prediction result, wherein the deep learning model is optimized based on a comparison result between the deep learning prediction result and the actual quality;

[0262] The quality analysis module 13 is used to set a quality threshold and compare the deep learning prediction result with the quality threshold. If it is higher than the quality threshold, the food quality meets the requirements. If it is lower than the quality threshold, an early warning signal is triggered for early warning.

[0263] The shelf life optimization module 14 is used to input the deep learning prediction results into a pre-established dynamic optimization algorithm model and output the optimal shelf life.

[0264] In the description of this specification, the description with reference to the terms "one embodiment", "example", "specific example", etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present disclosure. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.

[0265] The above shows and describes the basic principles, main features and advantages of the present disclosure. Those skilled in the art should understand that the present disclosure is not limited by the above embodiments, and the above embodiments and descriptions are only for explaining the principles of the present disclosure. Without departing from the spirit and scope of the present disclosure, the present disclosure may have various changes and improvements, and these changes and improvements fall within the scope of the present disclosure to be protected.

Claims

1. A method for monitoring the quality and optimizing the shelf life of animal and plant food, characterized in that: The method comprises the following steps: Acquire multi-source heterogeneous data of animal and plant foods, preprocess the multi-source heterogeneous data of animal and plant foods, and obtain a preprocessed animal and plant food data set; Inputting the preprocessed animal and plant food data set into a pre-established deep learning model, and outputting a deep learning prediction result, wherein the deep learning model is optimized based on a comparison result between the deep learning prediction result and the actual quality; Input the deep learning prediction results into the pre-established dynamic optimization algorithm model, and output the optimal shelf life; The process of inputting the preprocessed animal and plant food data set into the pre-established deep learning model and outputting the deep learning prediction result is as follows: Input data: First, the quality data of food during the entire monitoring period is organized into a time series X n The input is in the form of food image I, including color and shape. The basic information of food is input as static attribute A, including type and production date. Architecture steps: Data preprocessing, X n Normalization is performed to achieve time series standardization; I is resized, normalized, and noise removed to achieve image preprocessing, and then features are extracted from image I through CNN to obtain feature vector V; static attribute A is converted into vector E through the embedding layer; Based on deep bidirectional LSTM combined with attention mechanism time series modeling, the weighted context vector S is obtained; The final output S of LSTM, the image feature vector V and the static attribute vector E are fused to obtain the fused feature F; The fused feature F is input into the fully connected layer MLP to make the final prediction of food quality and obtain the predicted food quality score. ; Set a quality threshold and compare the deep learning prediction result with the quality threshold. If it is higher than the quality threshold, the food quality meets the requirements. If it is lower than the quality threshold, an early warning signal is triggered for early warning. According to the early warning signal, the producer or manager takes corresponding adjustment measures to restore the food quality to the qualified range. The deep learning model is optimized based on the comparison result between the deep learning prediction result and the actual quality, including: a1, establish a reinforcement learning environment, including each time step t, the state S of the environment t and the action space a t ; The state of the environment S t Contains the food quality prediction score of the current product Inventory I t , Environmental conditions En, Sales speed V t Features; Action space a t Includes different shelf life adjustment strategies; a2, Reward R t Function design, reward R t At time step t, the consequences of executing action Ac are determined. Actions that increase profits should receive positive rewards, while actions that do not should receive negative rewards. a3, Initialization: Build two deep neural networks, one is the target network Q(s,a|θ - ), and the other is the evaluation network Q(s,a|θ), which share the same architecture but different parameters; parameters θ and θ - Represent the weights of the evaluation network and the target network respectively; Select action: select a with probability 1-ε t , randomly select action Ac with probability ε; Experience replay: Each time a step is executed, the tuple (S t ,a t ,R t ) is stored in the experience playback buffer D, and a batch of experiences are randomly selected from it for learning; Learning update: randomly sample small batches from D for testing, and finally update the evaluation network weights θ to reduce the error; Target network update: The target network weights are updated periodically based on the evaluation network weights and the target network weights.

2. A method for monitoring the quality and optimizing the shelf life of animal and plant food according to claim 1, characterized in that: The multi-source heterogeneous data of animal and plant foods include: raw material growth environment parameters, breeding and planting management records, processing process parameters, storage environment monitoring data, logistics tracking information and sales terminal feedback.

3. The method for monitoring the quality and optimizing the shelf life of animal and plant food according to claim 1, characterized in that: The process of preprocessing the multi-source heterogeneous data of animal and plant foods includes: Complex data cleaning, integration and conversion techniques are applied to construct a data set for subsequent analysis. The time series analysis model involved is based on a deep bidirectional LSTM combined with an attention mechanism, and the anomaly detection model is based on autoencoder AE and isolation forest.

4. A method for monitoring the quality and optimizing the shelf life of animal and plant food according to claim 3, characterized in that: The process of time series analysis by the time series analysis model is as follows: Input time series data X = (X1, X2, ..., X n ), including environmental parameters, food characteristic indicators, and sensor data, among which X n Represents the food quality monitoring index vector at the nth moment; The input sequence is processed using a bidirectional LSTM network to capture the forward and backward dependencies in the time series: in, and are the hidden states of the forward and backward LSTMs respectively; Based on the output of the bidirectional LSTM, an attention mechanism is applied to dynamically assign weights to different time steps: Among them, α t is the attention weight at the tth time step, and S is the weighted context vector; Anomaly detection using anomaly detection models: Input multidimensional time series data X of food quality n ; By training the autoencoder to learn the low-dimensional representation of the data, there is a reconstruction error when reconstructing abnormal data: is the average number of nodes in the tree, which is different from the original data X n The difference between is used as a measure of the anomaly score; Data reconstructed from the autoencoder Then, the isolation forest process is performed. iForest constructs multiple random decision trees and determines the degree of abnormality based on the average path length of the data points in the tree: in, Yes The average path length in the forest, is the average number of nodes in the tree; For the data at each time point, an anomaly score is provided. The higher the score, the greater the probability that the data point is an outlier.

5. The method for monitoring the quality and optimizing the shelf life of animal and plant food according to claim 1, characterized in that: The weighted context vector S is calculated as: in, and are the hidden states of the forward and backward LSTM, α t is the attention weight at the t-th time step, S is the weighted context vector, It means that these two hidden state vectors are concatenated to form a vector containing two direction information, W a is a weight matrix, b a is a bias vector, W T is a weight vector, tanh is the hyperbolic tangent function, and the softmax function converts the attention scores of all time steps into probability distributions; The calculation process of the fused feature F is: F=Concatenate(S,V,E) Predicted food quality scores The calculation process is: in, represents the predicted food quality score, Θ MLP is the parameter set of MLP.

6. The method for monitoring the quality and optimizing the shelf life of animal and plant food according to claim 1, characterized in that: Construction of the pre-established dynamic optimization algorithm model: Based on the deep bidirectional LSTM combined with the attention mechanism food quality prediction, the attention-enhanced bidirectional LSTM model is introduced to capture the nonlinear trend of food quality over time, and focus on the time point features that have the greatest impact on the shelf life through the attention mechanism: Among them, α t is the attention weight at time step t, S is the weighted context vector, Score the predicted food quality.

7. The method for monitoring the quality and optimizing the shelf life of animal and plant food according to claim 1, characterized in that: The process of inputting the deep learning prediction results into the pre-established dynamic optimization algorithm model and outputting the optimal shelf life is as follows: The dynamic optimization algorithm model combines the predicted trend of food quality changes with the time series analysis method, taking into account environmental factors, storage conditions, and sales speed factors; Profit maximization f1(X): The goal is to maximize overall profit by optimizing shelf life and inventory management strategies; profit is expressed as sales revenue minus costs, including procurement costs, storage costs, and loss costs due to expiration; let the unit price of the product be p, the unit cost be c, and the sales volume in time period t be q t , the loss is d t , then the profit function is expressed as: Minimize the loss cost f2(X): The loss cost is directly related to the amount of expired food and is expressed as: Maximizing customer repurchase rate f3(X): The customer repurchase rate is related to the freshness, availability and price of food. In the model, satisfaction is positively correlated with the repurchase rate and negatively correlated with the price, which can be expressed as: Among them, β,μ, is the weight parameter, dFreshness t represents the freshness index of food at time t, p t is the average selling price at time t, q t For sales volume; Environmental constraints j (X; E)≤0,j=1,…,m Ensure that the food storage environment meets safety standards, j (X; E) = T store (X)-T max ≤0, where T store is the expected storage temperature calculated based on the decision variable X, T max is the maximum permissible temperature; Resource and inventory constraints k (X)=0,k=1,…,n Keep inventory levels within a reasonable range, h1(X)=I tatal (X)-I capacity =0, where I tatal is the estimated total inventory, I capacity For storage capacity.

8. A system for monitoring the quality of animal and plant food and optimizing the shelf life, characterized in that: include: A data processing module is used to obtain multi-source heterogeneous data of animal and plant foods, pre-process the multi-source heterogeneous data of animal and plant foods, and obtain a pre-processed animal and plant food data set; A model prediction module, used to input the preprocessed animal and plant food data set into a pre-established deep learning model, and output a deep learning prediction result, wherein the deep learning model is optimized based on the comparison result between the deep learning prediction result and the actual quality; The quality analysis module is used to set the quality threshold and compare the deep learning prediction results with the quality threshold. If it is higher than the quality threshold, the food quality meets the requirements. If it is lower than the quality threshold, an early warning signal is triggered for early warning. According to the early warning signal, the producer or manager takes corresponding adjustment measures to restore the food quality to the qualified range. The shelf life optimization module is used to input the deep learning prediction results into the pre-established dynamic optimization algorithm model and output the optimal shelf life; The process of inputting the preprocessed animal and plant food data set into the pre-established deep learning model and outputting the deep learning prediction result is as follows: Input data: First, the quality data of food during the entire monitoring period is organized into a time series X n The input is in the form of food image I, including color and shape. The basic information of food is input as static attribute A, including type and production date. Architecture steps: Data preprocessing, X n Normalization is performed to achieve time series standardization; I is resized, normalized, and noise removed to achieve image preprocessing, and then features are extracted from image I through CNN to obtain feature vector V; static attribute A is converted into vector E through the embedding layer; Based on deep bidirectional LSTM combined with attention mechanism time series modeling, the weighted context vector S is obtained: Comprehensive feature construction: the final output S of LSTM, the image feature vector V and the static attribute vector E are fused to obtain the fused feature F; The fused feature F is input into the fully connected layer MLP to make the final prediction of food quality and obtain the predicted food quality score. ; The deep learning model is optimized based on the comparison result between the deep learning prediction result and the actual quality, including: a1, establish a reinforcement learning environment, including each time step t, the state S of the environment t and the action space a t ; The state of the environment S t Contains the food quality prediction score of the current product Inventory I t , Environmental conditions En, Sales speed V t Features; Action space a t Includes different shelf life adjustment strategies; a2, Reward R t Function design, reward R t At time step t, the consequences of executing action Ac are determined. Actions that increase profits should receive positive rewards, while actions that do not should receive negative rewards. a3, Initialization: Build two deep neural networks, one is the target network Q(s,a|θ - ), and the other is the evaluation network Q(s,a|θ), which share the same architecture but different parameters; parameters θ and θ - Represent the weights of the evaluation network and the target network respectively; Select action: select a with probability 1-ε t , randomly select action Ac with probability ε; Experience replay: Each time a step is executed, the tuple (S t ,a t ,R t ) is stored in the experience playback buffer D, and a batch of experiences are randomly selected from it for learning; Learning update: randomly sample small batches from D for testing, and finally update the evaluation network weights θ to reduce the error; Target network update: The target network weights are updated periodically based on the evaluation network weights and the target network weights.

9. The animal and plant food quality monitoring and shelf life optimization system according to claim 8, characterized in that: The multi-source heterogeneous data of animal and plant food in the data processing module includes: raw material growth environment parameters, breeding and planting management records, processing process parameters, storage environment monitoring data, logistics tracking information and sales terminal feedback.

10. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, characterized in that: The memory stores a computer program that can be run on the processor. When the processor loads and executes the computer program, a method for monitoring the quality and optimizing the shelf life of animal and plant food according to any one of claims 1 to 7 is adopted.