Water quality prediction method based on ARIMA and improved chicken swarm algorithm
By combining the ARIMA model with an improved flocking algorithm and introducing optimization operators to improve water quality prediction, the problem of insufficient accuracy of the ARIMA model in water quality prediction is solved, and more accurate water quality data prediction is achieved.
Patent Information
- Application Number
- CN202210490698.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-07
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2042-05-07
AI Technical Summary
Existing ARIMA models are difficult to improve in terms of accuracy in water quality prediction and are sensitive to changes in the time interval of water quality data, which affects the accuracy of prediction results.
By combining the ARIMA model with an improved flocking algorithm, and by introducing optimization operators such as 2-opt, simulated annealing, and self-exploration operators, the flocking algorithm is recoded and the optimal prediction result is searched using neighborhood data, thereby optimizing the water quality data processing capability.
It improves the accuracy of water quality prediction, avoids premature convergence and local optima trapping, and achieves more accurate prediction of water quality data.
Smart Images

Figure CN114783548B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application relates to the technical field of water quality prediction, and particularly relates to a water quality prediction method based on ARIMA and an improved chicken swarm algorithm. BACKGROUND
[0002] With rapid economic development and continuous improvement of people's living standards, water environment has become the main guarantee for human development and progress and is an important way to improve the quality of life and the grade of cities. Water pollution prevention has been the focus of the country and society, and the use of long-term and large amounts of collected water quality monitoring data can predict the water pollution trend, which is of great significance to the management and planning of water environment. At present, the ARIMA model is widely used in the field of water quality prediction, but the accuracy of prediction by relying on a single model is difficult to improve significantly, which affects the accurate grasp of the future water quality environment. SUMMARY
[0003] The application aims to provide a water quality prediction method based on ARIMA and an improved chicken swarm algorithm, which obtains the optimal prediction result by searching and comparing the fitness of water quality data of adjacent periods, and realizes more accurate prediction of water quality data.
[0004] To achieve the above-mentioned purpose, the application provides a water quality prediction method based on ARIMA and an improved chicken swarm algorithm, which comprises the following steps:
[0005] Obtaining water quality data from an initial period to a t period;
[0006] Using the unit root test method to test the stationarity of the water quality data and determining the difference order d;
[0007] Using the Akaike information criterion AIC or the minimum Bayesian information criterion BIC to determine the autoregressive order p and the moving regression order q;
[0008] Establishing an ARIMA water quality prediction model according to the difference order d, the autoregressive order p and the moving regression order q, and obtaining water quality prediction data of the t period through the ARIMA water quality prediction model;
[0009] Introducing an optimization operator and re-encoding the chicken swarm algorithm in combination with the water quality prediction data of the t period;
[0010] Initializing the population, defining the fitness function and defining the chicken swarm swimming strategy;
[0011] Attributing the water quality prediction data to the chicken swarm according to the size of the fitness, and updating the position through different identities to obtain the optimal water quality prediction data of the t period.
[0012] Further, obtaining water quality data from an initial period to a t period specifically comprises the following steps:
[0013] Monitoring a certain water area for a certain period of time to obtain water quality data of the water area sorted by time, the water quality data including temperature, pH value, dissolved oxygen, ammonia nitrogen, dissolved solids, salinity, etc.
[0014] Further, the water quality data is subjected to stationarity test using unit root test method to determine the difference order d, specifically: the water quality data is subjected to stationarity test using ADF unit root test method, and the difference order d in the ARIMA water quality prediction model is determined through successive test and successive difference.
[0015] Further, Akaike information criterion AIC or minimum Bayesian information criterion BIC is used to determine the autoregressive order p and the moving regression order q, specifically: the autoregressive order p and the moving regression order q are determined according to the size of the water quality data sample capacity and the corresponding criterion.
[0016] Further, the water quality prediction data of the t period is obtained through the ARIMA water quality prediction model, specifically: the water quality data from the initial period to the t period is used to train the established ARIMA water quality prediction model, and the water quality data of the t-1 period is input into the model to obtain the water quality prediction data of the t period. The water quality prediction data of the t period is obtained by inputting the model
[0017] Further, an optimization operator is introduced, and the chicken swarm algorithm is re-encoded in combination with the water quality prediction data of the t period, specifically:
[0018] After encoding, the cock position updating method is as follows:
[0019] wherein, represents the updating result of the next generation cock position, which is the mapping of the t period water quality data; represents the current position of the cock, which is the mapping of the t-1 period water quality data; zbest is the optimal solution of the whole chicken swarm, and rbest is the individual historical optimal solution; X is a random exchange sequence; c1, c2 and c3 are the probability retention rates of the current generation; is a probability retention operation; "-" is an exchange sequence operation; in the formula, is an exchange sequence, and each exchange element in the exchange sequence is randomly saved according to the size of the probability retention rate, and the saved exchange element is applied to the original position to generate a new position
[0020] After encoding, the hen position updating method is as follows:
[0021] wherein, and Two different probability reservation rates respectively; Water quality prediction data of t period, By comparing And The difference between the positions, get the exchange order; the exchange in the exchange order is reserved according to the Probability; An exchange order; combined with the arrangement of two exchange orders, jointly acting on the original position New position
[0022] After encoding, the chicken position updating method is as follows:
[0023] Wherein, F and 0.4 are the probability reservation rates of the two exchange orders before and after; because the chicken is affected by the hens in the sub-group, it is obtained This exchange order, according to the probability reservation rate, the remaining exchange is applied to the original water quality data; considering the influence of senior individuals (roosters and hens) in other sub-groups on the chicken, it is obtained This exchange order.
[0024] Further, initialize the population, define the fitness function and specify the chicken population movement strategy, which is:
[0025] Initialize the population, randomly select a period of water quality data as the first visited data, and select other period water quality data adjacent to it;
[0026] The next period of water quality data to be accessed is determined by roulette method, and the water quality data to be accessed is selected from the adjacent data screened out;
[0027] It is specified that the rooster will move to the historical population optimal individual at a certain speed according to the difference between its own fitness and the fitness of the historical population optimal individual when updating the position each time; at the same time, the rooster will detect its own fitness rank in the population before updating the position each time in order to achieve the purpose of stabilizing its own position; the chicken will move to the hen according to the size of the fitness;
[0028] The fitness function is defined as: Wherein ARIMA water quality prediction model under t period of water quality prediction data; ARIMA water quality prediction model under t period of water quality data.
[0029] Further, according to the size of the fitness, the water quality data is attributed to the chicken identity, and the position is updated according to different identities, and the optimal water quality prediction data is obtained, which is:
[0030] The chicken population is ranked according to the fitness value, and the identity attribution is determined, that is, which population the cock, hen and chick belong to;
[0031] The cock is the individual with the highest fitness value, the chick is the individual with the lowest fitness value, and the rest are hens;
[0032] Randomly selecting a swap sequence of the field where the cock is located, comparing the fitness values of the cock and another cock to determine the retention rate of the swap sequence, and updating the position of the cock;
[0033] Through The swap sequence is obtained, the retention rate is obtained through the fitness value, and the position of the hen is updated;
[0034] Obtaining the swap sequence after the hen is affected And Updating the position of the chick;
[0035] The positions of the cock, hen and chick are updated into a matrix, each row of the matrix uses a 2-opt operator to obtain an updated optimal solution;
[0036] The optimal solution is applied to simulated annealing to search for a global optimal solution, that is, to obtain optimal water quality prediction data at t time period
[0037] Compared with the prior art, the above technical scheme of the present application has the advantages that: the present method overcomes the limitations of the traditional ARIMA model, such as low prediction accuracy for water quality data with large fluctuations, and large influence of different time interval of water quality data on water quality prediction results, and introduces a 2-opt operator with neighborhood, a simulated annealing operator and a self-exploration operator for optimization on the basis of the chicken swarm algorithm, re-encodes to form an improved chicken swarm algorithm, avoids the defects of the basic chicken swarm algorithm in finding an optimal solution, such as premature convergence and falling into local optimum, improves the ability of the improved chicken swarm algorithm to handle crossing when predicting water quality data at t time period by ARIMA model, obtains the optimal prediction result by searching and constantly comparing the fitness of water quality data of adjacent time periods, and finally realizes more accurate prediction of water quality data. BRIEF DESCRIPTION OF DRAWINGS
[0038] Figure 1 It is a flowchart of the water quality prediction method based on ARIMA and improved chicken swarm algorithm. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical scheme and advantages of the present application clearer and more apparent, the present application will be further described in detail below in combination with the drawings and examples. It should be understood that the specific examples described herein are only used to explain the present application and do not limit the present application, that is, the described examples are only a part of the examples of the present application, but not all the examples.
[0040] Embodiment 1
[0041] As Figure 1 shown, the application provides a water quality prediction method based on ARIMA and improved chicken population algorithm, specifically comprising:
[0042] Step 1: Obtain water quality data from the initial period to the t period;
[0043] Specifically, a certain water area is monitored within a certain time to obtain water quality data sorted by time, which includes temperature, pH value, dissolved oxygen, ammonia nitrogen, dissolved solids, salt, etc. The water quality data is a water quality time series reflecting the change of water quality parameters over time, which can be any one of temperature, pH value, dissolved oxygen, ammonia nitrogen, dissolved solids, salt, etc. The water quality data can be divided into training set and test set, and the test set is used for verification of subsequent model prediction.
[0044] Step 2: Use unit root test method to test the stationarity of the water quality data and determine the difference order d;
[0045] Specifically, the unit root test method includes ADF test method, PP test method, NP test method, etc. The commonly used ADF unit root test method can be used to test the stationarity of the water quality data, and the difference order d in the ARIMA model is determined by successive test and successive difference.
[0046] Step 3: Use Akaike information criterion AIC or minimum Bayesian information criterion BIC to determine the autoregressive order p and the moving regression order q;
[0047] Specifically, the selection of the criterion is determined by the sample size of the water quality data. When the sample size is large, the information provided by the fitting error in the AIC criterion is amplified by the sample size, so when the sample size is large, the model selected by the AIC criterion does not converge to the true model, and in this case, the BIC criterion compensates for the shortcomings of the AIC criterion. According to the corresponding criterion, the autoregressive order p and the moving regression order q are determined.
[0048] Step 4: Establish an ARIMA water quality prediction model according to the difference order d, the autoregressive order p and the moving regression order q, and obtain the water quality prediction data of the t period through the ARIMA water quality prediction model;
[0049] Specifically, the ARIMA water quality prediction model is trained by the water quality data from the initial period to the t period obtained in step 1, and the water quality data from the initial period to the t-1 period is input into the model to obtain the water quality prediction data of the t period.
[0050] Step 5: Introduce optimization operators, re-encode the chicken swarm algorithm combined with water quality prediction data at time t;
[0051] The basic chicken swarm algorithm has the defects of premature convergence and falling into local optimum when finding the optimal solution. In order to improve the ability of the improved chicken swarm algorithm to process cross when predicting water quality data at time t in the ARIMA water quality prediction model, the 2-opt operator with neighborhood is introduced. At the same time, the self-exploration operator is used to enhance the swimming ability of the chicken swarm, and the simulated annealing operator is used to improve the global search ability to prevent the algorithm from falling into local optimum due to too fast convergence, wherein:
[0052] 2-opt operator with neighborhood:
[0053] The 2-opt operator is applied to update and transform water quality prediction data at different times; before the loop ends, the water quality prediction data at two different times is flipped to generate new water quality prediction data. By comparing the fitness of the original data and the new data, it is determined whether to retain the new water quality prediction data. If the fitness of the new water quality prediction data is closer to 1, it is recorded and retained, and the optimal water quality prediction data is found by iteration.
[0054] Simulated annealing operator:
[0055] Simulated annealing is derived from the process of solid annealing. Starting from the initial temperature set, each solution set in the space is searched randomly using the Metropolis acceptance criterion of probability jump, and the global optimal solution is obtained by repeatedly sampling as the temperature gradually decreases.
[0056] Combined with the global search of simulated annealing, the common effect of chicken swarm algorithm and simulated annealing is enhanced. At the same time, the optimal water quality prediction data generated by the chicken swarm algorithm is used as the initial state of annealing for further calculation.
[0057] Self-exploration operator:
[0058] The self-exploration operator is a method of changing the internal arrangement of water quality prediction data at different times to achieve optimization. The water quality data from the initial time to time t is tested, and the data with fitness closer to 1 is retained.
[0059] The update mode of the position of the coded cock is as follows:
[0060] Among them, represents the update result of the position of the next generation cock, which is used as the mapping of water quality data at time t; The current position of the cock is represented as the mapping of water quality data at t-1 period =; zbest is the optimal solution of the whole chicken population, rbest is the individual historical optimal solution; X is a random exchange sequence; c1, c2 and c3 are the probability retention rates of the current generation; is a probability retention operation; "-" is an exchange sequence operation; in the formula is an exchange sequence, and each exchange element in the exchange sequence is randomly saved according to the size of the probability retention rate, and the saved exchange element is applied to the original position to generate a new position
[0061] The position updating mode of the hens after coding is as follows:
[0062] wherein, and are two different probability retention rates; is the water quality prediction data at t period, by comparing and the difference between the positions, an exchange sequence is obtained. The exchange elements in the exchange sequence are retained according to the probability of According to the same updating mode as above, an exchange sequence can also be obtained. By combining the arrangement of the two exchange sequences, the new
[0063] The position updating mode of the chicks after coding is as follows:
[0064] wherein, F and 0.4 are the probability retention rates of the two exchange sequences before and after. Since the chicks are affected by the hens in the sub-population, the exchange sequence is obtained, and the remaining exchange elements are applied to the original water quality data according to the probability retention rate. Considering the influence of the senior individuals (cocks and hens) in other sub-populations on the chicks, the exchange sequence is obtained.
[0065] Step 6: initialize the population, define the fitness function and specify the chicken population swimming strategy;
[0066] Specifically, the population is initialized, and water quality data of a time period is randomly selected as the first accessed data, and other time period water quality data adjacent to it is screened out; the roulette method is used to determine the next water quality data to be accessed, wherein the water quality data to be accessed is selected from the adjacent data screened out; it is stipulated that the cock will move to the historical population optimal individual at a certain speed according to the difference between its fitness and the fitness of the historical population optimal individual when updating the position each time; at the same time, the cock will detect the rank of its fitness in the population before updating the position each time in order to achieve the purpose of stabilizing its own position; the chick will move to the hen according to the size of the fitness. The fitness function is defined as wherein is the water quality prediction data of t time period under the ARIMA water quality prediction model; is the water quality data of t time period under the ARIMA water quality prediction model.
[0067] Step 7: The water quality data is attributed to the identity of the chicken according to the size of the fitness, and the position is updated according to different identities to obtain the optimal water quality prediction data.
[0068] Specifically, the chicken is ranked according to the fitness value obtained in step 6 to determine the identity attribution (which population does the cock, hen and chick belong to); the cock is the individual with the highest fitness, the chick is the individual with the lowest fitness, and the rest are hens. A random exchange sequence of the domain where the cock is located is selected, the fitness of the cock and another cock (arbitrarily) is compared to determine the retention probability of the exchange sequence, and the formula is substituted to update the position of the cock. The exchange sequence is calculated The retention rate is obtained according to the fitness, the formula is substituted to update the position of the hen. The exchange sequence obtained after the hen is obtained and The formula is substituted to update the position of the chick. The positions of the cock, hen and chick are updated into a matrix, and each row of the matrix is subjected to a 2-opt operator to obtain an updated optimal solution. The optimal solution is subjected to simulated annealing to avoid falling into local optimization due to 2-opt and search for the global; the optimal water quality prediction data of t time period is obtained
[0069] The foregoing description of specific exemplary embodiments of the application is intended for purposes of illustration and example only. These descriptions are not intended to limit the application to the precise form disclosed, and it is obvious that many changes and modifications can be made thereto without departing from the spirit thereof. The exemplary embodiments are chosen and described in order to explain the principles of the application and its practical application to thereby enable others skilled in the art to best utilize the application and various embodiments with various modifications as are suited to the particular use contemplated. It is intended that the scope of the application be defined by the following claims and their equivalents.
Claims
1. A water quality prediction method based on ARIMA and improved chicken swarm algorithm, characterized in that, The application relates to a water quality prediction method based on an ARIMA model and a chicken swarm algorithm. The water quality data of an initial period to a period t is acquired; Unit root test is used to test the stationarity of the water quality data, and the difference order d is determined; The Akaike information criterion AIC or the minimum Bayesian information criterion BIC is used to determine the autoregressive order p and the moving regression order q; An ARIMA water quality prediction model is established according to the difference order d, the autoregressive order p and the moving regression order q, and the water quality prediction data of the period t is obtained through the ARIMA water quality prediction model; An optimization operator is introduced, and the chicken swarm algorithm is re-encoded in combination with the water quality prediction data of the period t; The population is initialized, the fitness function is defined, and the chicken swarm swimming strategy is specified; The water quality prediction data is attributed to the chicken swarm according to the size of the fitness, and the optimal water quality prediction data of the period t is obtained through position updating of different identities; The optimization operator is introduced, and the chicken swarm algorithm is re-encoded in combination with the water quality prediction data of the period t. The encoding method of the cock position update is as follows: wherein, represents the update result of the next generation cock position as the mapping of the water quality data at time t; represents the current cock position as the mapping of the water quality data at time t-1; zbest is the optimal solution of the whole chicken population, rbest is the individual historical optimal solution; X is a random exchange sequence; c1, c2 and c3 are the probability retention rates of the current generation; is a probability retention operation; "-" is an exchange sequence operation; in the formula is an exchange sequence, in which each exchange element is randomly saved according to the size of the probability retention rate, and the saved exchange element is applied to the original position so as to generate a new position The encoding of the hen location update is as follows: wherein, and are two different probability reservation rates, respectively; is water quality prediction data of t period, by comparing and the difference between positions, to obtain a transposition order; the transposition in the transposition order is reserved according to the probability of ; is a transposition order; the arrangement of the two transposition orders jointly acts on the original position to generate a new position The encoding of the chicken location update is as follows: Wherein, F and 0.4 are probability retention rates of the two exchange orders; since the chicken is affected by the hens in the subgroup, it is concluded that This exchange order, according to the probability retention rate, the remaining exchange sub is applied to the original water quality data; considering the influence of the cocks and hens in other subgroups on the chickens, it is concluded that This exchange order; The population is initialized, the fitness function is defined, and the chicken swarm swimming strategy is specified. The population is initialized, and water quality data of a period is randomly selected as the first accessed data; other period water quality data adjacent to the data is screened out; The next water quality data of a period to be accessed is determined through a roulette method, wherein the water quality data to be accessed is selected from the adjacent data screened out; When a cock updates the position each time, the cock moves to the historical population optimal individual at a certain speed according to the difference between the fitness of the cock and the fitness of the historical population optimal individual; meanwhile, the cock detects the grade of the fitness of the cock in the population before updating the position each time, and the chick moves to the hen according to the size of the fitness; The fitness function is defined as: wherein is the water quality prediction data at time period t under the ARIMA water quality prediction model; is the water quality data at time period t under the ARIMA water quality prediction model; The water quality data is attributed to the chicken swarm according to the size of the fitness, and the optimal water quality prediction data is obtained through position updating of different identities. The chicken swarm is sorted and graded according to the fitness value, and the identity attribution is determined, that is, which population the cock, the hen and the chick belong to; The cock is the individual with the highest fitness, the chick is the individual with the lowest fitness, and the rest are hens; The exchange sequence of the domain where the cock is located is randomly selected, the fitness of the cock and the fitness of another cock are compared to determine the retention rate of the exchange sequence, and the position of the cock is updated; By get exchange order, get reservation rate by fitness, update hen position; After obtaining the order of exchange influenced by the hen and Update the chick's location; The positions of the cock, the hen and the chick are updated into a matrix, each row of the matrix uses a 2-opt operator, and the optimal solution is obtained after updating. The optimal solution is applied to simulated annealing to search for a global optimum, i.e. to obtain optimal water quality prediction data in the t period 2.The water quality prediction method based on ARIMA and improved chicken swarm algorithm according to claim 1, characterized in that, The water quality data of an initial period to a period t is acquired. The water quality data of a water area within a certain time is monitored, and the water quality data of the water area sorted according to time is obtained, wherein the water quality data includes temperature, PH value, dissolved oxygen, ammonia nitrogen, dissolved solids and salinity. 3.The water quality prediction method based on ARIMA and improved chicken swarm algorithm according to claim 1, characterized in that, Unit root test is used to test the stationarity of the water quality data, and the difference order d is determined.
4. The water quality prediction method based on ARIMA and improved chicken swarm algorithm according to claim 1, characterized in that, The Akaike information criterion AIC or the minimum Bayesian information criterion BIC is used to determine the autoregressive order p and the moving regression order q. The Akaike information criterion AIC or the minimum Bayesian information criterion BIC is used to determine the autoregressive order p and the moving regression order q.
5. The water quality prediction method based on ARIMA and improved chicken swarm algorithm according to claim 1, characterized in that, The water quality prediction data of the t period obtained by the ARIMA water quality prediction model is specifically: using the water quality data of the initial period to the t period to train the established ARIMA water quality prediction model, and inputting the water quality data of the t-1 period into the model to obtain the water quality prediction data of the t period In the input model, the water quality prediction data of the t period is obtained
Citation Information
Patent Citations
River water quality predicting method
CN108053054A
Three-dimensional model surface path planning method, system, equipment, terminal and application
CN113589753A