Dosing method and system based on timing constraint and priori knowledge enhancement, and storage medium
By dividing the time series irreversibility of the chemical dosing process in water treatment and combining it with prior knowledge of chemistry and physics, the patented technology solves the problems of missing temporal logic and insufficient model fitting in the existing chemical dosing process, realizing a precise and forward-looking dosing strategy and improving the interpretability and accuracy of water quality control.
Patent Information
- Application Number
- CN202511729847.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-24
- Publication Date
- 2025-12-23
- Estimated Expiration
- 2045-11-24
AI Technical Summary
Existing water treatment prediction models lack temporal logic, resulting in feature derivation lacking clear physical meaning. These models are prone to overfitting to remedial dosing and fail to fully incorporate prior chemical and physical knowledge, making it difficult to implement forward-looking dosing strategies.
By dividing the drug administration process into pre-treatment, intervention, and outcome stages based on the irreversibility of time series, we introduce lag, future, and interaction operators to derive features, adjust feature weights by combining prior knowledge of chemical reactions and physical kinetics, and use the XGBoost model to reverse analyze future drug administration sequences to output a prospective drug administration strategy.
It improves the accuracy and foresight of dosing strategies, solves the problem of remedial dosing caused by drug effect lag, realizes a highly interpretable and accurate prediction model, and optimizes water quality control.
Smart Images

Figure CN121189772A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of water quality regulation, and particularly relates to a dosing method and system based on time sequence constraint and prior knowledge enhancement and a storage medium. BACKGROUND
[0002] In the water treatment process of a water supply plant, the PAC dosing (the operation process of adding a coagulant, polyaluminum chloride) in the coagulation stage and the disinfectant dosing in the disinfection stage are core links for regulating water quality, and the dosing amount directly affects key indicators such as water turbidity and residual chlorine. At present, data-driven prediction models, such as regression prediction models and XGBoost machine learning prediction models, are commonly used in the industry to predict the influence of dosing on water quality and assist in optimizing the dosing strategy. The construction of these prediction models usually relies on historical water quality data (such as inlet water turbidity and pH value) and dosing data (such as PAC dosing amount and disinfectant dosing amount), generates input variables through statistical features (such as mean, variance, and correlation) or feature derivation without explicit time sequence constraints, and then fits and predicts target water quality indicators (such as outlet water turbidity and residual chlorine) based on the prediction model. However, the existing dosing operation has a significant time lag effect - the PAC dosing needs to go through physical and chemical reaction processes such as coagulation and sedimentation before the turbidity regulation effect can be realized, and the disinfectant dosing needs a certain time to stabilize the residual chlorine level. Therefore, in actual production, it is often difficult to accurately grasp the time lag relationship, resulting in a "remedial" dosing strategy, that is, the dosing amount is adjusted passively according to the current water quality deviation, making it difficult to achieve forward-looking regulation.
[0003] Specifically, the method for predicting the correlation between water plant dosing and water quality based on machine learning is to fit the correlation between dosing operation and water quality indicators through a data-driven prediction model (such as XGBoost, random forest, etc.) to assist in optimizing the dosing strategy. The typical steps of this method are as follows:
[0004] Step 1: Data collection and preprocessing;
[0005] First, collect the historical operation data of the water supply plant, including: inlet water quality parameters (such as inlet water turbidity, pH value, temperature, flow rate, etc.); dosing operation parameters (such as PAC dosing amount, disinfectant dosing amount, dosing frequency, etc.); outlet water quality indicators (such as outlet water turbidity, residual chlorine, pH value, etc., as target variables); auxiliary parameters (such as sedimentation tank liquid level, reaction time, etc.). Then, clean the data (remove outliers, fill in missing values), standardize it (such as normalization or standardization), and unify the time granularity (such as aligning the data by hour or minute).
[0006] Step 2: Feature derivation;
[0007] Based on the original data derived statistical features, no strict time sequence stage division, mainly includes: basic statistical features: such as the mean, variance, maximum / minimum of the turbidity of the influent in a certain period; Simple time sequence features: such as the difference between the turbidity of the influent at time t and t-1, t-2, the cumulative amount of dosing; Unconstrained interaction features: such as the product of the dosing amount at t-1 and the aluminum concentration of the influent at t, the ratio of the manganese concentration of the influent at t and the dosing amount at t-1, etc.
[0008] Step 3: prediction model training and optimization;
[0009] Select a machine learning prediction model (such as XGBoost), use the features derived in step 2 as input, and use the water quality indicators (such as turbidity, residual chlorine) as target variables to build a prediction model. Train the prediction model using conventional methods: divide the training set and validation set, optimize the prediction model parameters (such as tree depth, learning rate, etc.) based on the loss function (such as mean square error), and do not make targeted adjustments to the feature importance. Prediction model evaluation: verify the fitting effect of the prediction model through accuracy, root mean square error, etc. If the effect is not good, return to step 2 to adjust the features or step 3 to optimize the parameters.
[0010] Step 4: prediction model application and dosing guidance;
[0011] Deploy the trained prediction model to the water plant control system, input real-time influent water quality and dosing data, and predict future effluent water quality indicators. Then, based on the prediction results, deduce the dosing suggestions. For example, if the predicted effluent turbidity is high, suggest increasing the PAC dosage; if the residual chlorine is low, suggest increasing the disinfectant dosage (essentially a remedial logic of "current water quality deviation → subsequent dosing adjustment").
[0012] However, the above scheme does not consider the time sequence irreversibility of the water treatment process, the feature derivation confuses the "pre-intervention-result" stage, and does not adjust the feature importance combined with chemical / physical prior knowledge, resulting in the prediction model being difficult to explain the dynamic mechanism of dosing and water quality change, and being prone to over-reliance on uncontrollable influent parameters (such as influent turbidity), and unable to solve the preventive dosing problem caused by the time lag of drug efficacy.
[0013] In summary, the existing technology has the following defects:
[0014] (1) Feature derivation lacks time sequence logic and poor interpretability;
[0015] The feature derivation of the existing prediction model is mainly based on statistical correlation, and the time sequence irreversibility of "influent water quality (preposition) - dosing operation (intervention) - water quality result (target)" is not strictly distinguished. Different variables in different stages are often combined without distinction (such as using the water quality index in the result stage to infer the characteristics in the preposition stage), resulting in the derived features lacking clear physical meaning. For example, there may be "t-time effluent turbidity and t-1-time influent turbidity without logical cross characteristics", the prediction model may fit the data law, but it cannot explain the dynamic influence mechanism of dosing on water quality, and it is difficult to guide the actual process optimization.
[0016] (2) The prediction model is easy to overfit the "remedial dosing" mode, and the importance of key variables is distorted;
[0017] Due to time lag effect, the existing prediction model mainly learns the remedial dosing logic of "current water quality deviation -> subsequent dosing adjustment", which leads to:
[0018] ① Non-key variables (such as uncontrollable influent turbidity) are overestimated in importance due to strong statistical correlation with target water quality (such as effluent turbidity), which masks the actual impact of dosing operation;
[0019] ② The importance of dosing variables is underestimated, and the prediction model has insufficient accuracy when analyzing the dosing strategy in reverse (for example, misjudging that "t-time dosing amount is only determined by t-time influent turbidity", ignoring the sustained effect of the previous time dosing);
[0020] ③ It cannot distinguish between "insufficient dosing leading to substandard water quality" and "excessive dosing but water quality has stabilized", resulting in limited guidance value of the prediction result for preventive dosing.
[0021] (3) Prior knowledge is not effectively integrated into the prediction model, and the physical and chemical mechanisms are ignored;
[0022] The existing prediction model mainly relies on data statistical law, and does not fully combine prior knowledge such as chemical reactions (such as PAC and colloid flocculation) and physical dynamics (such as time lag effect of reagent diffusion) in water treatment process, resulting in poor generalization ability of the prediction model when the data distribution changes (such as sudden change of influent water quality), and difficulty in explaining "why a certain dosing strategy is better", which cannot meet the requirements of industrial scene for the reliability of the prediction model. SUMMARY
[0023] The purpose of the present application is to provide a dosing method, system and storage medium based on time sequence constraint and prior knowledge enhancement, which aims to solve any one of the above problems.
[0024] The present application is mainly realized by the following technical solutions:
[0025] A dosing method based on time sequence constraint and prior knowledge enhancement, comprising the following steps:
[0026] Step S1: firstly, data acquisition and pretreatment are carried out; then, based on the time series irreversibility, the water plant dosing process is divided into a pre-stage, an intervention stage and a result stage, through correlation analysis, under the constraint of time series, based on the lag operator, the future operator, the interaction operator and the rolling statistics operator of the pre-stage and the intervention stage, the derived features are derived; finally, the features with high correlation with the target variable of the result stage are reserved;
[0027] The lag operator is the historical value of the variable of the pre-stage; the future operator is the future value of the variable of the intervention stage; the interaction operator is the product or ratio of the variables of the pre-stage and the intervention stage; the rolling statistics operator is the sliding statistics of the variable of the pre-stage;
[0028] Step S2: a prediction model is constructed based on the XGBoost model, and the feature weight of the key variable is dynamically adjusted based on the prior knowledge of chemical reaction and physical kinetics, the influence of the dosing variable is strengthened, the over-reliance of the prediction model on non-key variables is corrected, and the prediction model more accurately captures the dynamic correlation between dosing and water quality change;
[0029] Step S3: in the reverse analysis stage of the prediction model, through the gradient descent method, the unique set of dosing suggestion values is solved under the constraint of the historical dosing interval and the cost minimization target, and the dosing suggestion value is integrated to form a future dosing sequence; based on the future dosing sequence, the corresponding dosing strategy is output.
[0030] In order to better realize the present application, further, the step S1 comprises the following steps:
[0031] Step S11: according to the operation cycle T of the stirrer of the flocculation reaction tank, the operation data is resampled, and each sampling data granularity is aligned;
[0032] Step S12: based on the correlation analysis method, the value range of the drug effect lag P and the water flow lag Q is analyzed, the influent, dosing and effluent data of the same batch of water are identified and aligned, and the feature derivation follows the pre-intervention-result time sequence constraint;
[0033] Step S13: the water treatment process is divided into three time sequence stages of pre-stage, intervention stage and result stage, based on the variables of the pre-stage and the intervention stage, the lag operator, the future operator, the interaction operator and the rolling statistics operator are introduced, the feature derivation is carried out according to the time sequence constraint, and the variables with high correlation with the target variable of the result stage are reserved.
[0034] For better implementation of the present application, further, in the step S11, the operation data includes variables of influent turbidity, influent aluminum concentration, influent iron concentration and influent temperature; a sampling frequency is set so that each time of sampling data contains 1 time of stirring; and the sampling data is aligned in time sequence.
[0035] For better implementation of the present application, further, in the step S12, the analysis is made on the dosing and water flow time lag, a target variable is set to determine the dosing time point affecting the same batch of water, and a basis is provided for the characteristic derived time sequence constraint;
[0036] The change curve of the Pearson correlation coefficient of the future turbidity or residual chlorine change caused by the dosing in the dosing time lag P period under different water flow time lag Q conditions is analyzed respectively; based on the change curve, the dosing time lag period of the highest correlation point is determined, and the target variable is set as the turbidity or residual chlorine reduction amount in the dosing time lag period of the highest correlation point.
[0037] For better implementation of the present application, further, the step S13 includes the following steps:
[0038] Step A1: dividing the water treatment process into three time sequence stages of a pre-stage, an intervention stage and a result stage, and the variables of the pre-stage, the intervention stage and the result stage being influent water quality parameters, dosing operation parameters and a target variable respectively;
[0039] Step A2: based on the influent water quality parameters and the dosing operation parameters, introducing a lag operator, a future operator, an interaction operator and a rolling calculation operator to generate characteristics according to time sequence constraints;
[0040] Step A3: calculating the linear correlation of the derived characteristics in the step A2 and the target variable, retaining the first 20% characteristics, and eliminating redundant characteristics with a correlation between characteristics >0.9.
[0041] For better implementation of the present application, further, in the step S2, for the dosing data above the median, the gradient and Hessian matrix of the dosing characteristics are scaled; and the target function Loss adj of the prediction model is:
[0042]
[0043]
[0044] Wherein: is a regularization term;
[0045] is the prediction value of the i-th tree;
[0046] gi Gradient of the ith dosing feature;
[0047] h i Hessian matrix of the ith dosing feature;
[0048] k is a hyperparameter;
[0049] Gradient of the modified ith dosing feature;
[0050] Hessian matrix of the modified ith dosing feature;
[0051] n is the total number of samples.
[0052] To better achieve the present application, further, in the step S3, the formula of the cost minimization target is:
[0053] ;
[0054] Wherein: Min Cost is the cost minimization target;
[0055] w3, w4 are the cost weights of PAC and disinfectant;
[0056] PAC(t+k) is the PAC dosing cost of the t+k period;
[0057] Cl(t+k) is the disinfectant dosing cost of the t+k period;
[0058] t is the label of the current time point;
[0059] u is the future dosing step number determined based on the correlation analysis of step S12;
[0060] k is the future period number;
[0061] The historical dosing interval constraint is:
[0062] Prediction error tolerance:; ;
[0063] Dosing range: PAC min ≤PAC(t+k)≤PAC max , Cl min ≤Cl(t+k)≤Cl max ;
[0064] Wherein: is the model prediction value;
[0065] y target is the target water quality index;
[0066] is a threshold value;
[0067] PAC min , PAC max respectively are the dosing thresholds provided by historical process experience, i.e. the minimum PAC dosing amount and the maximum PAC dosing amount;
[0068] Cl min , Cl max respectively are the dosing thresholds provided by historical process experience, i.e. the minimum Cl dosing amount and the maximum Cl dosing amount.
[0069] In order to better realize the present application, further, in the step S3, the dosing strategy includes a conservative strategy, a medicine saving strategy and a balanced strategy, the dosing strategy takes the maximum value in the future dosing sequence, the medicine saving strategy takes the minimum value in the future dosing sequence, and the balanced strategy takes the average value in the future dosing sequence.
[0070] The present application is mainly realized by the following technical solutions:
[0071] A dosing system based on time sequence constraint and prior knowledge enhancement, based on the above-mentioned dosing method based on time sequence constraint and prior knowledge enhancement, comprising a data acquisition and preprocessing module, a feature generation module, a water quality prediction module and a reverse analysis module;
[0072] The data acquisition and preprocessing module is used for acquiring running data within a running period T of the stirrer and performing data preprocessing;
[0073] The feature generation module is used for constructing time sequence interaction features of pre-positioning-intervention-result three stages;
[0074] The water quality prediction module is used for constructing a prediction model and enhancing feature weights of key variables based on chemical reaction and physical kinetics prior knowledge;
[0075] The reverse analysis module is used for reverse analysis and solving future dosing sequences, and outputting corresponding dosing strategies.
[0076] A computer readable storage medium having a computer program stored thereon, the program being executed by a processor to implement the above-mentioned dosing method based on time sequence constraint and prior knowledge enhancement.
[0077] The beneficial effects of the present application are as follows:
[0078] (1) The present application can solve the remedial dosing problem caused by the time lag of drug effect in the dosing process of water supply plant, effectively improving the precision and foresight of dosing strategy. Specifically, in view of the problems of missing feature derivation time sequence logic, over-fitting remedial dosing of prediction model, distortion of key variable importance and ineffective use of prior knowledge in the prior art, the present application analyzes the dynamic correlation of PAC dosing, disinfectant dosing and water quality indicators (such as turbidity, residual chlorine), combines time series characteristics and chemical and physical prior knowledge, and constructs a prediction model with strong interpretability and high prediction accuracy.
[0079] (2) In view of the problem of missing feature derivation time sequence logic, the present application divides the dosing stage according to the "pre-intervention-result" time sequence, and through correlation analysis, based on the lag, future and interaction operators of the pre-intervention stage (the result stage does not participate), ensures that the features meet the water treatment time irreversibility, and improves the interpretability. Specifically, based on the time series irreversibility, the dosing process of the water plant is divided into pre-intervention stage (inlet water quality parameters), intervention stage (dosing operation parameters) and result stage (target water quality indicators), the features are derived through the time sequence interaction of the first two stages (introducing lag, rolling, absolute value, etc.), the result stage does not participate in feature derivation (avoiding the interference of target variables), so that the derived features have clear physical meaning and interpretability, which is better than the existing feature derivation method without time sequence constraint.
[0080] (3) In view of the problems of over-fitting remedial dosing of prediction model and distortion of key variable importance, the present application adjusts the feature weight based on prior knowledge, strengthens the influence of dosing variables, weakens the interference of non-key variables, corrects the over-dependence of prediction model on non-key variables, makes the prediction model more accurately capture the dynamic correlation between dosing and water quality change, and solves the prediction model bias caused by remedial dosing. Specifically, based on the prior knowledge of chemical or physical dynamics equation, the importance of key derived features (such as dosing related variables, etc. which play a core role in the theoretical equation) in the prediction model (such as XGBoost) is enhanced (achieved by adjusting the gradient and hessian matrix), solving the problem of over-fitting "remedial dosing" mode of prediction model caused by time lag of drug effect, avoiding overestimating the importance of non-key variables (such as uncontrollable inlet turbidity), while strengthening the influence weight of controllable dosing variables, improving the accuracy of prediction model in reverse analysis of dosing strategy, and providing reliable basis for preventive dosing
[0081] (4) In order to solve the problem of being unable to output a forward-looking dosing strategy, the present application combines time delay and feature derivation method, introduces a future operator, and solves the future dosing sequence under the constraints of historical dosing interval and the minimum cost optimization target by gradient descent method, outputs a multi-strategy solution, realizes preventive dosing, and solves the remedial dosing problem caused by the time delay of drug effect. Specifically, the present application combines time delay analysis and cost optimization to output a future dosing strategy, provides a preventive dosing decision basis for water supply plants, reduces water quality fluctuations, and optimizes dosing efficiency. The present application can be widely applied to water quality regulation and process optimization scenarios in urban water supply plants, and is especially suitable for water treatment processes that require precise control of PAC dosing, disinfectant dosing, and dynamic correlation of water quality indicators (such as turbidity and residual chlorine).
[0082] (5) The present application quantifies the time delay correlation between dosing operations (such as PAC dosage and disinfectant dosage) and water quality changes (such as effluent turbidity and residual chlorine) by constructing a time series feature and prior knowledge enhanced prediction model, providing a data-driven decision basis for manual dosing. For example, based on the time sequence rule of "pre-feeding water quality-intervention dosing-resulting water quality" analyzed by the prediction model, the traditional "remedial dosing" mode relying on experience can be optimized to a more forward-looking "preventive dosing" strategy, reducing water quality fluctuations caused by drug effect time delay, and improving the accuracy and efficiency of manual dosing.
[0083] (6) The present application emphasizes the core role of dosing variables in the prediction model, clearly defines the direct impact of controllable dosing operations on water quality, and provides support for water supply plants to optimize reagent consumption and reduce secondary pollution (such as excessive residual chlorine and reagent residues) caused by excessive dosing. At the same time, based on the interpretable feature derivation results, it can assist in identifying key links affecting the water supply ecosystem (such as the long-term regulation of PAC dosage on turbidity and the correlation between disinfectant dosage and residual chlorine stability), helping to build a more sustainable water treatment process system, and improving the stability and safety of the water supply ecosystem. BRIEF DESCRIPTION OF DRAWINGS
[0084] Figure 1 Flowchart of the dosing method of the present application based on time series constraints and prior knowledge enhancement;
[0085] Figure 2 For example 2, the change curve of Pearson correlation coefficient with dosing time delay period under different water flow time delay Q conditions. DETAILED DESCRIPTION
[0086] Example 1:
[0087] A dosing method based on time constraint and prior knowledge enhancement, based on the actual operation data and process characteristics of the water plant, combining with the XGBoost machine learning prediction model, learning the dynamic correlation between PAC dosing and turbidity change and the dynamic correlation between disinfectant dosing and residual chlorine, including the time lag effect of dosing operation on water quality indicators, the interaction of characteristics in different time sequences, and the correction of dosing rules in manual operation mode, etc. The final goal is to accurately predict water quality changes and inversely analyze the optimal dosing scheme to realize the intelligent optimization of water plant dosing process.
[0088] Specifically, for simplicity, only the problem of PAC+disinfectant (referred to as: dosing) causing the change of influent turbidity is taken as an example, including the following steps:
[0089] (1) According to the stirring cycle T (for example: 20 minutes / time) of the flocculation reaction tank of the water plant, resample the data to align the data granularity returned by each sensor;
[0090] (2) Through correlation analysis method, analyze the value range of drug effect time lag P and water flow time lag Q, the purpose is to identify and align the influent, dosing and effluent data of the same batch of water, and make the feature derivation strictly follow the time sequence constraint of "preposition-intervention-result";
[0091] (3) Introduce lag, future, interaction and rolling elements, generate features according to time sequence constraints, and retain variables with high correlation with target variables.
[0092] (4) In the prediction model construction, dynamically adjust the weight of the key dosing related features, enhance the gradient and second derivative corresponding to 51%-100% quantile dosing data, in order to improve the importance of dosing related features, and make the prediction model rely more on dosing related features to complete learning.
[0093] (5) In the inverse analysis stage of the prediction model, given the target turbidity change, the future dosing sequence is solved by gradient descent algorithm, and under the constraint of historical dosing interval (5%-95% quantile), the minimum total dosing amount is taken as the goal, a unique set of dosing suggestion values can be solved, and the obtained dosing suggestion values are integrated to dynamically output any one of the conservative, drug-saving and balanced strategies. The total dosing amount = w1 x PAC dosing amount + w2 x disinfectant dosing amount, wherein w1 and w2 are dosing weights.
[0094] Example 2:
[0095] A dosing method based on time constraint and prior knowledge enhancement, as shown in Figure 1 , including the following steps:
[0096] Step 1: data acquisition and preprocessing;
[0097] The historical operation data of the water plant is collected by the preset sensor, such as: water turbidity, water aluminum concentration, water iron concentration, water temperature and other variables. Because the feedback data time frequency of each sensor is different, therefore, the sampling frequency T (such as 20 min) is needed to align the data of each sensor in time sequence. This sampling frequency can refer to the running interval of the flocculation reactor mixer, so as to ensure that each sampling data contains 1 mixing.
[0098] Step 2: Drug administration and water flow time lag analysis, set target variable; aims to find the drug administration time point which has influence on the same batch of water, and provide basis for feature derivation time sequence constraint.
[0099] ① Set water flow time lag Q, drug effect time lag P, the future change of water turbidity at t time can be expressed as: The drug administration at t-P time can be expressed (taking PAC addition as an example): ;
[0100] ② As shown in Figure 2 , fix Q unchanged, take different values of P (horizontal coordinate), calculate the Pearson correlation coefficient (vertical coordinate) of past P period drug administration on future turbidity change; on this basis, take different values of Q, Figure 2 The thickness of the curve represents different Q values, and the Pearson correlation coefficient of past P period drug administration on future Q period turbidity change (taking the decrease as a measure) is calculated.
[0101] ③ Analysis Figure 2 , it can be found that: the PAC administration at t+11 period has the highest correlation with the turbidity reduction value of t to t+17 period, the administration from t+11 to t+6 period also has promoting effect on the change of water turbidity from t to t+17 period (the correlation coefficient in this interval increases obviously); in other words: the administration from t to t+5 period has great influence on the turbidity reduction value of t+11 period, and this batch of water will wait for 17 period of effluent in flocculation reactor and sedimentation tank;
[0102] ④ Based on the above data exploration results, the target variable can be set as (taking turbidity change as an example): the future 11 period water turbidity reduction value.
[0103] Step 3: Feature derivation under time sequence constraint;
[0104] 3.1 Stage division (based on time sequence irreversibility);
[0105] The water treatment process is divided into three time sequence stages: pre-stage, intervention stage and result stage, and the feature derivation strictly follows the time flow direction of "pre-stage → intervention → result" (the result stage does not participate in derivation to avoid the interference of target variable).
[0106] ①Pre-stage: water quality parameters (e.g. influent turbidity, influent pH, influent aluminum concentration, etc.);
[0107] ②Intervention stage: dosing parameters (e.g. PAC dosage, chlorine dosage);
[0108] ③Result stage: target variables (e.g. turbidity change, residual chlorine change, etc.).
[0109] 3.2 Feature derivation operators (including interaction features);
[0110] Based on the above stages, the following operators are introduced to generate features (taking turbidity prediction as an example):
[0111] ① Lag operator lag: historical values in the pre-stage, such as: past 1 period of influent pH, past 2 periods of influent aluminum concentration, etc.;
[0112] ② Future operator lead: future values in the intervention stage, lead values can be obtained according to the results of Figure 2 , such as the future 5 periods of PAC dosing affecting the target variable, then lead can take value 5, it should be noted that the value of the future operator should be <= water flow time lag Q (this can also reflect the constraint conditions of time series, which can be simply understood as: if the water flow has completely flowed out, the subsequent dosing diffusion effect should not affect this batch of water).
[0113] ③ Interaction operator: product or ratio of pre-stage and intervention stage, such as: ratio of influent turbidity and current chlorine dosage, product of influent pH and future 2-step PAC amount, etc.
[0114] ④ Rolling statistics operator: sliding statistics of pre-stage, such as 3-step sliding mean of influent pH history, etc.
[0115] ⑤ Other statistical quantity operator: for variables in the pre-stage, additional feature derivation methods such as maximum value, minimum value, absolute value, change rate within a period of time can be added.
[0116] 3.3 Feature selection;
[0117] Calculate the linear correlation between derived features and target variables, retain the top 20% features, and eliminate redundant features with correlation > 0.9 between features (avoid multicollinearity).
[0118] Step 4: Prediction model construction based on feature weight optimization;
[0119] 4.1 Prediction model selection and objective function;
[0120] XGBoost prediction model is used, and the objective function is the mean square error (MSE) between predicted value and true value:
[0121] ;
[0122] wherein: is the true target variable;
[0123] is the predicted value of the prediction model, is the feature vector generated in step 3.
[0124] 4.2 Feature importance adjustment (weight optimization based on prior knowledge); aims to improve the importance of the dosing related features (intervention stage) so that the prediction model uses as many dosing related features as possible to complete the prediction.
[0125] ① Scale the gradient ( ) and Hessian matrix ( ) of the dosing features (including interaction features); for dosing data above the median of the features ( ):
[0126] ,
[0127] where k is a hyperparameter, indicating the multiple of feature importance improvement (the optimal solution can be obtained by hyperparameter optimization).
[0128] ② The adjusted XGBoost objective function is:
[0129] ;
[0130] wherein, is the regularization term, is the predicted value of the i-th tree.
[0131] 4.3 Prediction model training and evaluation;
[0132] Divided into training set (70%), validation set (15%) and test set (15%) in time sequence order to avoid data leakage. Adopt MSE (mean square error), MAPE (mean absolute percentage error), RMSE (root mean square error) and R² (determination coefficient) to verify the performance of the prediction model. After completing a round of training, select the top m most important features (m is generally less than 10, the purpose is to reduce the features, which can speed up the prediction model in the reverse analysis stage) to train the prediction model again. The performance results of the prediction model and the default prediction model without feature importance adjustment are shown in Table 1.
[0133] Table 1 Test results of the prediction model for the change of PAC+ disinfectant on influent turbidity
[0134]
[0135] Based on the results of Table 1, it can be found that the prediction model of the present application can improve the feature importance of the dosing-related features (+82.96%), although the fitting effect of the prediction model in the training stage is not as good as the default prediction model, but in the test set part, the generalization ability of the prediction model of the present application is stronger, which illustrates the effectiveness of the present application.
[0136] Step 5: Prediction model reverse analysis (dosing scheme solving);
[0137] 5.1 Optimization objective and constraint condition;
[0138] Optimization objective: given the target water quality index (such as turbidity, residual chlorine, etc.), solve the dosing sequence and minimize the total dosing cost:
[0139] ;
[0140] Wherein: Min Cost is the cost minimization objective;
[0141] is the cost weight of PAC and disinfectant; is the future dosing step number (determined based on the correlation analysis of step 2, such as ), k is the future period number.
[0142] Constraint condition:
[0143] ① Prediction error tolerance: ( is the threshold, such as turbidity change =0.05);
[0144] ② Dosing range: PAC min ≤PAC(t+k)≤PAC max , Cl min ≤Cl(t+k)≤Cl max (take the 5%-95% quantile of historical dosing data).
[0145] 5.2 Solving algorithm (gradient descent method);
[0146] ① Initialize dosing sequence as the historical average;
[0147] ② Iterative update dosing value:
[0148] ;
[0149]
[0150] Wherein, is the learning rate, and the gradient is calculated by backpropagation of the prediction model.
[0151] ③Cycling optimization: increase tolerance every 50 iterations (e.g. +0.05 each time), until the constraints are met (usually converges within 5 minutes).
[0152] 5.3 Multi-strategy output;
[0153] As shown in Table 2, based on the solution results, due to the introduction of the future operator during feature derivation, the reverse analysis results usually contain recommended values such as future 1 period PAC dosage (L / h) and future 2 period PAC dosage (L / h).
[0154] Table 2: PAC dosing sequence example table
[0155]
[0156] Based on Table 2, three dosing strategies can be generated:
[0157] ① Conservative strategy: take the maximum value of the future dosing sequence (for example, at t+2, the maximum value of the future 3 period column can be selected), to ensure that the water quality meets the standard.
[0158] ② Medicine saving strategy: take the minimum value of the future dosing sequence (for example, at t+2, the minimum value of the future 3 period column can be selected), to reduce the cost.
[0159] ③ Balanced strategy: take the average value of the future dosing sequence (for example, at t+2, the average value of the future 3 period column can be selected), to balance the cost and water quality stability.
[0160] The above is only a preferred embodiment of the present application, and does not limit the present application in any form. Any simple modification or equivalent change made according to the technical essence of the present application to the above embodiment falls within the protection scope of the present application.
Claims
1. A dosing method based on temporal constraints and prior knowledge enhancement, characterized in that, Includes the following steps: Step S1: First, perform data acquisition and preprocessing; Then, based on the irreversibility of time series, the water plant chemical dosing process is divided into a pre-treatment stage, an intervention stage, and a result stage. Through correlation analysis, under the constraint of time series, the characteristics are derived based on the lag operator, future operator, interaction operator, and rolling statistical operator of the pre-treatment and intervention stages. Finally, the characteristics of high correlation with the target variable of the result stage are retained. The lag operator is the historical value of the variable in the pre-intervention stage; the future operator is the future value of the variable in the intervention stage; the interaction operator is the product or ratio of the variables in the pre-intervention stage and the intervention stage; the rolling statistics operator is the sliding statistic of the variable in the pre-intervention stage. Step S2: Construct a prediction model based on the XGBoost model, and dynamically adjust the feature weights of key variables based on prior knowledge of chemical reaction and physical kinetics to strengthen the influence of drug dosage variables; Step S3: In the reverse analysis stage of the prediction model, the gradient descent method is used to reverse analyze the data. Under the constraints of historical dosing intervals and the goal of minimizing costs, a unique set of dosing recommendations is obtained, and the dosing recommendations are integrated to form the future dosing sequence. The corresponding dosing strategy is output based on the future dosing sequence.
2. The dosing method based on temporal constraints and prior knowledge enhancement according to claim 1, characterized in that, Step S1 includes the following steps: Step S11: Based on the operating cycle T of the agitator in the flocculation reaction tank, resample the operating data and align the particle size of each sampled data. Step S12: Based on the correlation analysis method, analyze the value range of the drug efficacy lag P and the water flow lag Q, identify and align the influent, dosing and effluent data of the same batch of water, so that feature derivation follows the time sequence constraint of pre-intervention-result; Step S13: Divide the water treatment process into three time-series stages: the pre-treatment stage, the intervention stage, and the result stage. Based on the variables of the pre-treatment and intervention stages, introduce lag operators, future operators, interaction operators, and rolling statistical operators, perform feature derivation according to time series constraints, and retain variables that are highly correlated with the target variables of the result stage.
3. The dosing method based on temporal constraints and prior knowledge enhancement according to claim 2, characterized in that, In step S11, the operating data includes variables such as influent turbidity, influent aluminum concentration, influent iron concentration, and influent temperature; the sampling frequency is set so that each sampled data includes one stirring; and the sampled data is aligned in a time series.
4. The dosing method based on temporal constraints and prior knowledge enhancement according to claim 2, characterized in that, In step S12, the time lag between dosing and water flow is analyzed, and target variables are set to determine the dosing time point that affects the same batch of water, providing a basis for the time-series constraints derived from the features. Analyze the Pearson correlation coefficient curves of the effect of dosing time delay P on future changes in turbidity or residual chlorine under different water flow time delay Q conditions; Based on the change curve, the dosing lag period at the point of highest correlation is determined, and the target variable is set as the reduction in turbidity or residual chlorine at the dosing lag period at the future point of highest correlation.
5. A dosing method based on temporal constraints and prior knowledge enhancement according to claim 2 or 4, characterized in that, Step S13 includes the following steps: Step A1: Divide the water treatment process into three time-series stages: the pretreatment stage, the intervention stage, and the result stage. The variables in the pretreatment stage, the intervention stage, and the result stage are the influent water quality parameters, the chemical dosing operation parameters, and the target variable, respectively. Step A2: Based on the influent water quality parameters and dosing operation parameters, introduce lag operators, future operators, interaction operators and rolling statistical operators, and generate features according to time series constraints; Step A3: Calculate the linear correlation between the derived features from step A2 and the target variable, retain the top 20% of features, and remove redundant features with a correlation greater than 0.
9.
6. The dosing method based on temporal constraints and prior knowledge enhancement according to claim 1, characterized in that, In step S2, for dosing data above the median, the gradient of the dosing characteristics is calculated. and Hessian matrix Scaling is applied; the objective function of the prediction model is Loss. adj for: ; ; in: It is a regularization term; Let be the predicted value for the i-th tree; g i The gradient of the i-th dosing feature; h i Let be the Hessian matrix of the i-th drug administration feature; k is a hyperparameter; The gradient of the i-th dosing feature after correction; The corrected Hessian matrix of the i-th dosing feature; n represents the total number of samples.
7. The dosing method based on temporal constraints and prior knowledge enhancement according to claim 1, characterized in that, In step S3, the formula for the cost minimization objective is: ; Where: Min Cost is the cost minimization objective; w3 and w4 are the cost weights of PAC and disinfectant; PAC(t+k) is the cost of PAC dosing in period t+k; Cl(t+k) represents the disinfectant application cost in period t+k. t is the marker for the current time point; u represents the number of future drug administration steps determined based on the correlation analysis in step S12; k is the number of future periods; The historical dosing interval constraint is as follows: Tolerance for prediction error: ; Dosing range: PAC min ≤PAC(t+k)≤PAC max Cl min ≤Cl(t+k)≤Cl max ; in: These are the model's predicted values; y target The target water quality indicators; For the threshold; PAC min PAC max These represent the minimum and maximum PAC dosage, respectively. Cl min Cl max These represent the minimum and maximum Cl dosages, respectively.
8. A dosing method based on temporal constraints and prior knowledge enhancement according to claim 1 or 7, characterized in that, In step S3, the dosing strategy includes a conservative strategy, a drug-saving strategy, and a balanced strategy. The dosing strategy takes the maximum value in the future dosing sequence, the drug-saving strategy takes the minimum value in the future dosing sequence, and the balanced strategy takes the average value in the future dosing sequence.
9. A dosing system based on temporal constraints and prior knowledge enhancement, comprising a dosing method based on temporal constraints and prior knowledge enhancement as described in any one of claims 1-8, characterized in that, It includes a data acquisition and preprocessing module, a feature generation module, a water quality prediction module, and a reverse analysis module; The data acquisition and preprocessing module is used to acquire the operating data within the stirrer's operating cycle T and perform data preprocessing. The feature generation module is used to construct the temporal interaction features of the three stages of pre-intervention-outcome; The water quality prediction module is used to build a prediction model and enhance the feature weights of key variables based on prior knowledge of chemical reactions and physical kinetics. The reverse analysis module is used to reverse analyze and solve for the future dosing sequence, and output the corresponding dosing strategy.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements the drug administration method based on timing constraints and prior knowledge enhancement as described in any one of claims 1-8.
Citation Information
Patent Citations
Water processing medicine addition digital online control system
CN105425592A
Water plant dosing system with online simulation experiment function and control method thereof
CN116256979A
Intelligent dosing method and system for sewage treatment based on artificial intelligence
CN116956155A
Sewage denitrification dosing method and system based on machine learning and storage medium
CN120877905A
Intelligent control method and system for water treatment agent
CN121050322A
Cited By
Drug injection optimization control method and system for large time delay
CN121432943A