A Dynamic Source Tracing Method for Food Supply Chain Quality and Safety Based on Big Data

The data of food quality tracing information have a few features, such as wide coverage range, many circulation links, complex data sources, low authenticity, and difficult information sharing. The continuous development of big data technology provides infinite possibilities for the construction of food quality source tracing systems. Currently, there are many studies on the application of food quality source tracing systems; however, most of them are in the field of food quality databases, and few have concerned about its application in the field of big data. Therefore, to fill in this research gap, this paper aimed to study a dynamic source tracing method for food supply chain quality and safety based on big data. At first, this paper summarized the variables of food supply chain quality and safety, constructed a Petri net model and a Bayesian network model for food quality prediction and source tracing, and realized the prediction of food quality features. Then, this paper applied two data analysis and processing methods—the density-based clustering algorithm and the cosine similarity algorithm—to preliminarily process the collected quality tracing information of each link in the food supply chain and analyzed the influencing factors of food quality. Finally, experimental results proved the effectiveness of the constructed model. Relying on the real-timeliness and authenticity of big data, this paper guarantees the credibility of the traceable information in the tracking process and improves the accuracy through real-time stream processing of the updated data, providing unlimited possibilities for the comprehensive tracking of food sources.


Introduction
On average, about 62.3 food quality and safety incidents occur in China per day, the overall situation is very serious, and more than 3/4 of the incidents occurring in the production and processing links are caused by human factors [1][2][3][4][5][6][7][8][9][10]. In view of the frequent food quality and safety problems and for the purpose of improving food quality and safety, it is necessary to build a food quality and safety source tracing regulatory system to track the information of all circulation links in the food industry, including production, processing, transportation, and sales [11][12][13][14][15]. Since the collection of food quality source tracing information requires the cooperation of all participants in the food supply chain, it has the characteristics of a wide coverage range, many circulation links, complex data sources, low authenticity, and di cult information sharing [15][16][17][18][19][20][21][22]. Today's smart energy manufacturing relies on big data, cloud computing, and the Internet of things. By combining big data with food, it is possible to grasp the basic laws of food production and improve the resource utilization e ciency and production e ciency of food production. rough data analysis, processing, data mining, and decision-making, the combination between big data and food would lower the trial-and-error cost in the development of the modern food industry, making the nal decision more accurate. In this way, it is possible to reduce the costs and enhance the pro ts. e continuous development of big data technology provides in nite possibilities for the construction of food quality source tracing systems.
As intelligent technologies such as the Internet of ings (IoT) and big data have emerged and been widely applied, many researchers have done jobs to combine these emerging technologies with food quality source tracing systems. For example, Hao et al. [23] proposed a traceability scheme combining reverse search and recursive algorithm based on the theory of blockchain technology and designed and implemented a food safety tracing system. en, they used experimental results to prove that the proposed scheme is more effective than the traditional source tracing models. In terms of epidemic prevention and control, food safety monitoring, data analysis, and food safety traceability are even more important. Studies on food safety source tracing systems based on big data, artificial intelligence (AI), and IoT provide ideas and methods for solving the problems of low reliability and difficult data storage during the application of traditional source tracing systems. For example, Zheng et al. [24] took rice as an example and proposed a food safety source tracing system based on RFID + QR code technology and IoT big data storage technology; by analyzing system requirements, the proposed system uses RFID and big data storage functions to obtain information in the food production process and then realizes the whole-process tracking of food production information through the designed dynamic query platform and mobile terminals. Balamurugan et al. [25] proposed an efficient food traceability management technology that makes use of the IoT. en, they deduced a solution for data transmission and used the improved cycle data and the improved Petri network model to perform food source tracing. Singh and Jenamani [26] proposed a Casandra-based NoSQL database suitable for storing traceability data. en, in order to test the performance of the database, they designed a test platform in the laboratory and simulated the operation of the supply chain of the Indian public distribution system to generate data. Food is one of the most important elements in international trade. Bordel et al. [27] proposed a food traceability system for international food trade based on the blockchain network and RFID tags, the system adopts a REST interface, NoSQL database, and JavaScript code. It realizes a distributed solution that collects, tags, and stores reliable information about food flows. e review of the above literature shows that many scholars at home and abroad have studied food quality tracking methods. However, there are problems with the consistency and universality of the data storage for the tracking system. Besides, few scholars have studied food quality tracing in the field of big data. erefore, this paper attempts to research a dynamic source tracing method for food supply chain quality and safety based on big data. e purpose is to explore the key technologies of the product quality tracing system in the food supply chain, establish a quality tracing system suitable for various types of foods, and improve consumer satisfaction and the core competitiveness of enterprises. e main contents of this paper (1) summarize the variables of food quality and safety source tracing; (2) introduce the food quality source tracing mode; (3) model the food production process based on Petri net; (4) build a Bayesian network model for food quality prediction and source tracing to realize the prediction of food quality features; (5) give the framework of the food quality source tracing system; (6) adopt two data analysis and processing methods, the density-based clustering algorithm and the cosine similarity algorithm, to preliminarily process the collected quality tracing information of each link in the food supply chain; (7) give the technical route map of food quality source tracing, and analyze the influencing factors of food quality; (8) use experimental results to prove the effectiveness of the constructed model. Relying on the real-timeliness and authenticity of big data, this paper guarantees the credibility of the traceable information in the tracking process and improves the accuracy through real-time stream processing of the updated data, providing unlimited possibilities for the comprehensive tracking of food sources.

Construction of the Food Quality Source Tracing Model
Food production has many processing procedures, and there are many reasons for the causing quality and safety problems; therefore, the quality tracing information generated during the production and circulation process has many types and is transmitted and accumulated between the various supply chain links.
In the developed world, food safety tracing systems have been established to supervise the whole process of food production, from the planting and breeding of animals and plants (sources of food production) to the detailed records of production, processing, and sales. e purpose is to monitor and manage all the links for the food from the source to consumers, such as to ensure the safety and quality of the food on the tables. Any food in the market must carry a label of the required information. Besides, the production and processing records of the food must be traceable. Overall, countries around the world are very concerned with the safe development of agricultural products. Figure 1 shows a diagram of the food quality source tracing mode. According to the figure, when food of a certain batch output from the supply chain has quality problems and its quality needs to be analyzed, the data of actual production workshop information, food quality feature information, and production process information collected from the production process of this food batch, are analyzed to find the reasons that cause the quality problems of this food batch.
During the multistage food processing, the three key links that are most closely related to quality are: raw material supply, production, and circulation. Common problems include chemical contamination, shelf-life problem, excessive harmful ingredients, and poor production sanitation conditions, etc. Figure 2 gives a summary of food quality and safety source tracing variables.
Starting from the perspectives of food production process and food quality source tracing, at first, this paper constructed a model of the food production process based on Petri net. Figure 3 shows the flow of food quality source tracing. A Petri net was used to describe the relationship between quality tracing activities and activity links in the above figure It is assumed that X (x ij ) represents the incidence matrix, and it satis es x ij q'(d i , e j )-q'(e j , d i ). From the existing descriptions of Petri net, it can be obtained from the following equations: e Petri net can be expressed rigorously in math and described visually with graphs. With rich system description means and system behavior analysis technologies, the Petri net provides a solid conceptual foundation for computer science.
For the food quality source tracing model based on Petri net, its food quality evaluation index system has the characteristics of bounded and accessible;, therefore, aiming at the accessibility of speci c food source tracing information, this paper veri ed the e ectiveness of the constructed model. en, the strength of association attributes represented by the directed edges between the node variables can be described by the conditional probability, which can be calculated by the following formula: Assuming c represents the observed quantity, ξ represents the unknown parameter, o(c, ξ) represents the joint distribution of c and ξ, ρ(c) and ρ(ξ) represent edge density, and π(a)χ(ξ) represents the prior probability distribution of ξ, then, based on the multivariate Bayes theorem, we obtain the following formula: Formula (5)   After simplification, there is: After training the constructed network model and completing the calculation of conditional probability, the tabular expression form of the model could be obtained.

The Processing of Food Quality Source
Tracing Information Based on Big Data Figure 4 shows the framework of food quality source tracing system, which is consisted of base layer, data layer, business layer, and application layer. e base layer includes the information of the actual production workshops, the information of food quality features, and the information of production process. e data layer supports data integration management, including source tracing data file storage, dataset of food quality tracing information, and data operation log. e business layer is mainly responsible for data analysis and processing, i.e., identifying abnormal data by densitybased clustering algorithm, classifying data by cosine similarity algorithm, getting the source tracing results by analyzing the influencing factors of food quality, and taking the value corresponding to the maximum probability change rate. Because the quality tracing information generated during production and circulation process has various types and is transmitted and accumulated between various supply chain links, the quality description variables have multiple correlations. In order to analyze the influencing factors of food quality, it is necessary to preliminarily process the collected quality tracing information of each link in the food supply chain, this paper mainly adopted two data processing methods: the density-based clustering algorithm and the cosine similarity algorithm.

Data Processing.
In the density-based clustering algorithm, all variables were extracted from the dataset of food quality source tracking information and it satisfies a i ∈ A, then, for the set of variables in set A with a distance from a i less than the value of σ, its neighborhood can be defined as follows: When the number of other variables in the neighborhood of a i is greater than the manually set minimum value of variables in the neighborhood, then a i is called a core variable. If there are core variables in the neighborhood of noncore variable a i , then, a i is called an aboundary element, and there are as follows: If core variables a i and a j belong to the same neighborhood, then, it is said that a j is directly density-reachable from a i .
If core variable a i belongs to set A which contains n subdatasets of food quality tracing information, where {b 1 , b 2 ,. . ., b 1n } represents the subdatasets, and it satisfies a i � b i , a j � b n ; subsets b 1 , b 2 , b 3 ,. . ., b n-1 are all core variables, and b i+1 is directly density-reachable from b i , then, it can be inferred that a j is directly density-reachable from a i by the following variable: If there is variable a l , and it satisfies that variables a i and a j are both directly density-reachable from a l , then, their called that a i and a j are density-connected. e cosine similarity algorithm is to calculate the cosine value of the angle between two vectors, which is represented by β. e larger the angle, the lower the similarity between the two vectors. For β, the calculation formula of the cosine function is as follows: e length of vectors x and y in the Cartesian coordinate system can be calculated by the following formula: Assuming vector z represents the distance between x and y, then, the calculation formula of the length is as follows: e following formula shows the cosine function in the Cartesian coordinate system: Assuming X i represents each component of vector X, Y i represents each component of vector Y, then, the similarity of the multidimensional space can be calculated by the following formula:

Obtaining the Source Tracing Results.
rough the description of food quality source tracing, the source tracing process can be regarded as a diagnosis and reasoning process based on the constructed multiple Bayesian networks. e food quality source tracing problem can be described as assuming A � [a 1 , a 2 ,. . ., a i ..a m ] represents the reasons that cause the food quality and safety problem, W � [w1,w2,. . .wi,. . .wm] represents the types of food quality and safety problem, wl represents the type of quality problem of a certain food batch, and o(wl) represents the Discrete Dynamics in Nature and Society probability that the quality problem is the KL-th type problem, then, o(wl)needs to satisfy: e source tracing of food quality is actually to determine which type of quality and safety problem within the range of causes [a 1 , a 2 ,. . ., a l ,. . ., a m ] when wl occurs. Figure 5 shows the technical route of food quality source tracing. e analysis of the in uencing factors of food quality includes the following steps: Step 1. Analyze food quality information Separately, quantify each quality description variable, determine the main quality evaluation indicators of the food production or distribution process, and count the quality evaluation parameters wl of each link in the production or distribution process. Assuming W represents the total quality evaluation parameter of food quality source tracing and θ l represents the coe cient of in uence of the quality information of each link on the total quality information, then, there is: According to the above formula, the total quality evaluation indicator of food quality source tracing is equal to the weighted sum of the quality indexes of each production and circulation link.
According to above formula, the food quality evaluation index of the independent production or circulation link is equal to the weighted sum of each quality index of this link. Adjust relevant production and circulation environment, production and logistics equipment, production processes, and participants, etc.    Discrete Dynamics in Nature and Society Step 3. Analyze the direct influence relationship of adjacent production or circulation links Assuming μ i,i+1 represents the correlation coefficient of the influence of a previous link on the latter link, if two adjacent links are correlated, then, there is 0<μ i, i+1 ≤1, if two adjacent links are not correlated, then, there is μ i, i+1 � 0. e following formula gives the expression of the food quality evaluation index when two adjacent links have an influence relationship: According to above formula, when there's an influence relationship between two adjacent production and circulation links, the food quality evaluation index is equal to the quantitative value of the influence of the link and its coupling link plus the weighted sum of each quality index of the link. According to the data features of quality description variables, discretize the continuous variable a i to generate several state variables ZT + , ZT − , etc. e data involved in the process of food production and distribution have two types of variables: the discrete type, and the continuous type. e following formula gives the conversion formulas for continuous variables and discrete variables: Food quality source tracing is to find out the cause according to the features of the quality and safety problem when a batch of food has a quality and safety problem. Under the condition that the state variable probabilities related to the features of the quality and safety problem were known, this paper sorted the state variable probabilities, obtained the reason of the food quality and safety problem corresponding to the maximum probability change rate after the constructed network was updated, and then took the reason as the cause of the current food quality and safety problem.
In this paper, the state probability of quality authenticity of node variables in the output layer of the network was studied as the feature of the quality and safety problem changed from high � 100% to low � 100%, and the following formula gives the calculation of probability change: Figure 6 and 7, respectively, show the execution time distribution of the map phase and the reduce phase of big data analysis. According to Figure 6, with the increase of the scale of quality tracing information data generated in the production and circulation process, the execution time of the map phase increased accordingly, but the increment was limited, which is mainly because the source tracing information was not stored in this phase. By comparing Figures 6 and 7, we can find that with the increase of the scale of quality tracing information data generated in the production and circulation process, the execution time of the reduce phase increased with it, and the generation time of source tracing results was relatively long, which is because the source tracing information had been stored in this phase; that is, the source tracing information was written into the HDFS file. Figure 8 shows the percentage of source tracing results generation time in the entire execution time.

Analysis of Experimental Results
According to the figure, with the increase of the scale of a quality tracing information data generated in the production and circulation process, the percentage of the generation time of source tracing results in the entire execution time was controlled between 28% and 51%. erefore, according to the analysis of the above experimental results, the food quality source tracing method adopted in modeling had little impact on the performance of the bottom execution framework of big data analysis. Figure 9 shows the comparison results of the distribution of source tracing results generation time of different models, and the reference model is a fine-grained source tracing model, the word count model. According to Figure 9, with the increase of the scale of quality tracing information data, the generation time of source tracing results of the two models grew continuously, but there's a big difference in the growth rate. Based on these results, it can be seen that the source tracing efficiency of the proposed model was better than that of the reference model, and its performance was even better as the input data volume increased.
According to Figure 10, when the scale of quality tracing information data generated in the production and circulation process is fixed, with the increase in the number of production and circulation links, the source tracing results generation time of the reference model and the proposed model grew continuously, but at different rates. According to the figure, the generation time of source tracing result of the proposed model grew approximately linearly.
is is because the proposed model's retrieval scales of the source tracing information of each link were basically the same, so the source tracing results generation time grew linearly with the number of production and circulation links. However, for the reference model, with the increase of the number of production and circulation links, the source tracing results generation time grew rapidly. e model is a many-to-one model, and its retrieval scales multiplied, resulting in the source tracing results generation time grew faster and the performance was lower.
In this paper, the quality tracing information data were first processed into Netica software format data, then, a Bayesian network model was constructed, and the structure and parameter learning was carried out. After that, the probability of the proposed model was reasoned to evaluate the effectiveness of the constructed network in food quality and safety source tracing. After completing the analysis as the feature of quality and safety problems changed from high � 100% to low � 100%, the calculation results of the state probability of quality authenticity of node variables in the output layer of the network after the automatic update are shown in Table 1. rough observation, it was found that Discrete Dynamics in Nature and Society when the food safety and quality feature changed from high 100% to low 100%, the state probabilities corresponding to the four variables of raw material supply information, production and processing process information, circulation process information, and quality inspection and storage information all changed; wherein the change of the probability of production and processing process information was the largest. erefore, this paper judged that the reason for this type of food quality change was due to the processing environment and the processing technique.
Next, for the four variables of raw material supply information, production and processing process information, circulation process information, and quality inspection and storage information, the probability changes of the corresponding quality evaluation criteria were calculated, and the results are shown in Table 2. e speci c variables include raw material batch/type 1, supplier/buyer information 2, raw material quality/key component content 3, production and processing environment information 4, production and processing equipment information 5, production and processing personnel information 6, production and processing link information 7, distribution time/person and other     information 8, delivery time information 9, distribution temperature and humidity environment 10, quality inspection result information 11, storage location/time information 12, IM/EX-warehouse information 13, and other information 14.
According to the table, when the food safety quality changed from high 100% to low 100%, the probability change of the raw material quality/key component content was the largest, so this paper judged that this food quality change was caused by the raw material quality/key component content variable in the raw material supply information. erefore, the link in which the food quality and safety problems occurred could be preliminarily located, and the problem-tracing personnel can verify the accuracy of the judgements made by the model by checking the value of raw material quality/key component content in the raw material supply information. e probability change of the delivery time information in the table is 0.2, which means that the delivery time information has little impact on food quality features. Because in the food production and distribution process, the delivery time information is checked repeatedly before distribution and the food quality has a relatively long shelf life, a shorttime delivery delay will not cause food quality defects, which is consistent with the actual production situations of enterprises.

Conclusion
is paper researched a dynamic source tracing method of food supply chain quality and safety based on big data. At rst, it summarized the variables of food quality and safety source tracing, constructed a Petri net model and a Bayesian network model for food quality prediction and source tracing, and realized the prediction of food quality features. en, this paper applied two data analysis and processing methods-the density-based clustering algorithm and the cosine similarity algorithm-to preliminarily process the collected quality tracing information of each link in the food supply chain and analyzed the in uencing factors of food quality. e experimental results showed the distribution of the execution time of the map phase and reduce phase in big   Discrete Dynamics in Nature and Society data analysis and the percentage of source tracing results generation time in the entire execution time, which verified that the food quality source tracing method adopted by the proposed model has little impact on the performance of the bottom execution framework of big data analysis. Moreover, this paper also gave the distribution of source tracing results generation time and the distribution of tracing time under different numbers of production and circulation links, and the results proved that the proposed model was more efficient in generating source tracing results and its performance was higher. At last, the paper also gave the probability changes of the variables of food quality and safety source tracing, the calculation results listed in the table were in line with the actual production situations of enterprises, which verified the accuracy of the judgment made by the model.

Data Availability
e data used to support the findings of this study are available from the corresponding author upon request.

Conflicts of Interest
e authors declare that they have no conflicts of interest.