A water treatment dosing optimization method and system based on multi-model cooperation and dynamic hypothesis space
Patent Information
- Application Number
- CN202610807328.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-05
- Publication Date
- 2026-08-21
AI Technical Summary
其缺点在于:大时滞特性导致参数难以整定,系统易振荡;无法处理多变量耦合;对进水水质突变响应滞后严重
[0058] The beneficial effects of this application are as follows: This application presents a water treatment dosing optimization method and system based on multi-model collaboration and a dynamic hypothesis space. Addressing the challenges of traditional PID control in handling large time delays, multivariate coupling, and delayed responses to sudden changes in water quality, this invention introduces flocculent image features (such as particle size and fractal dimension) to enable the model to perceive the microscopic morphological changes during the flocculation process, significantly improving response speed and control accuracy under complex operating conditions. To address the shortcomings of existing neural network predictive control, such as ignoring flocculation features, weak generalization ability of single models, and high computational cost of fixed grid search, this invention employs a multi-model collaborative prediction architecture, effectively improving the prediction accuracy and generalization of multi-objective effluent water quality. Simultaneously, it dynamically constructs a hypothesis space based on the fluctuation characteristics of the actual dosing sequence, adaptively adjusting the search range and step size, avoiding full-space enumeration, effectively reducing computational cost, and achieving real-time optimization.
Smart Images

Figure CN122608170A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of intelligent water treatment, specifically a water treatment chemical dosing optimization method and system based on multi-model collaboration and dynamic hypothesis space. Background Technology
[0002] In the field of water treatment technology, it is necessary to add water purification agents (such as flocculants) to wastewater. The control of dosing determines whether the agent can fully react with impurities in the water and achieve flocculation. Currently, traditional dosing control methods are generally based on traditional PID control or predictive control based on neural networks.
[0003] Traditional PID (proportional-integral-derivative) control methods rely on feedback control based on a single effluent parameter (such as turbidity). Its drawbacks include: large time delays making parameter tuning difficult and system oscillations likely; inability to handle multivariate coupling; and severe lag in response to sudden changes in influent water quality. Neural network-based predictive control uses BP neural networks or LSTM to establish a mapping between chemical dosage and effluent water quality. Its disadvantages include: considering only water quality parameters and ignoring floc morphological characteristics; using a single model for prediction, resulting in limited generalization ability; and optimization methods typically involving simple grid search, leading to high computational cost and low accuracy. Summary of the Invention
[0004] In view of this, the purpose of this application is to provide a water treatment dosing optimization method and system based on multi-model collaboration and dynamic hypothesis space to solve the problems in the background art.
[0005] To achieve the above objectives, this application adopts the following technical solution:
[0006] This application discloses a water treatment chemical dosing optimization method based on multi-model collaboration and dynamic hypothesis space, comprising the following steps:
[0007] The system acquires water quality data and underwater image sequences within a target time period, and obtains actual chemical dosage sequences for multiple time points prior to the current time point. The target time period includes the current time point and multiple time points prior to the current time point. The water quality data includes values of various water quality parameters, and the actual chemical dosage sequences include the actual dosages of various chemicals at multiple time points. The water quality data and the actual chemical dosage sequences are aligned using pool capacity lag compensation.
[0008] Flocculation feature data is extracted from multiple frames of underwater images in the underwater image sequence, wherein the flocculation feature data includes values of various flocculation parameters;
[0009] The fluctuation characteristics of the actual dosage sequence are calculated by constructing a dynamic hypothesis space based on the actual dosage and fluctuation characteristics of multiple agents at the previous time point, extracting multiple dosage combinations from the dynamic hypothesis space, and constructing multiple hypothesis input vectors based on multiple dosage combinations, water quality data, and flocculation characteristic data. The calculation of the fluctuation characteristics of the actual dosage sequence includes: calculating the coefficient of variation and mean absolute difference of the actual dosage of each agent at multiple time points in the actual dosage sequence; weighting the coefficient of variation and mean absolute difference of the actual dosage of each agent to obtain a comprehensive fluctuation score for each agent; weighting the comprehensive fluctuation scores of multiple agents to obtain the fluctuation characteristics of the actual dosage sequence, wherein the weights of multiple agents are based on the correlation evaluation of agent price and flocculation effect; constructing a dynamic hypothesis space based on the actual dosage and fluctuation characteristics of multiple agents at the previous time point, and extracting multiple dosage combinations from the dynamic hypothesis space, including: calculating the amplitude coefficient based on the fluctuation characteristics. and step scaling factor Wherein, the expansion coefficient and the step scaling factor The mathematical expression is:
[0010]
[0011]
[0012] In the formula, Indicates fluctuation characteristics, Indicates the maximum expansion coefficient. Indicates the maximum fluctuation score. Indicates the minimum fluctuation score. This represents the maximum reduction factor; based on the actual dosage of various agents at the previous time point and the expansion factor. Calculate the search half-width, determine the search boundary based on the search half-width and the actual dosage of various agents at the previous time point, and determine the search boundary based on the step size scaling factor. Determine the search step size, wherein the mathematical expressions for the search boundary and the search step size are:
[0013]
[0014]
[0015]
[0016] In the formula, Indicates the first The lower limit of the search for a certain drug. Indicates the first The actual amount of the pesticide applied at the previous time point. Indicates the first The search half-width of the drug. Indicates the first The upper limit of the search for a certain drug. Indicates the first The search step size for each drug Indicates the minimum allowable step size. The search is performed within the search boundary using the search step size to obtain a set of candidate values for multiple agents; and the Cartesian product is performed on the set of candidate values for multiple agents to obtain multiple dosage combinations.
[0017] The system predicts the water quality index for each hypothetical input vector based on multiple pre-built water quality prediction models. It also selects the target input vector and the target delivery quantity combination of the target input vector based on the cost of multiple hypothetical input vectors and the predicted water quality index. Each water quality prediction model predicts one water quality index.
[0018] In one embodiment of this application, extracting flocculation feature data from multiple frames of the underwater image sequence includes:
[0019] Each frame of the underwater image in the underwater image sequence is preprocessed to obtain a preprocessed image, wherein the preprocessing includes grayscale conversion, Gaussian filtering, and contrast enhancement.
[0020] The preprocessed image is binarized based on an adaptive threshold to obtain a binarized image;
[0021] Perform a morphological closing operation on the binarized image to obtain a morphologically processed image;
[0022] From the morphologically processed image, connected components with an area greater than or equal to a preset area threshold are selected to obtain multiple flocs in the image;
[0023] Extract the area, perimeter, equivalent diameter, and centroid coordinates of each floc; and count the total number of flocs.
[0024] The average diameter is calculated based on the equivalent diameter of multiple flocs; the average area is calculated based on the area of multiple flocs; the average perimeter is calculated based on the perimeter of multiple flocs; and the number of fine particles with an equivalent diameter less than a preset threshold is selected.
[0025] The fractal dimension of the morphologically processed image is extracted based on box counting; and the gray-level variance, average gradient, kurtosis, and entropy of the preprocessed image are calculated.
[0026] Flocculation feature data are constructed based on the total number of flocs, average diameter, average perimeter, number of fine particles, fractal dimension, gray-level variance, average gradient, kurtosis, and entropy.
[0027] In one embodiment of this application, the actual dosage of various agents at the previous time point and the amplification coefficient are considered. Calculate the search half-width, including:
[0028] When the dosage of the agent at a previous time point satisfy: At that time, calculate the search half-width. The mathematical expression for the search half-width is:
[0029]
[0030] In the formula, For drug type index, Indicates the base half-width factor;
[0031] When the dosage of the agent at a previous time point satisfy: or At that time, calculate the search half-width. The mathematical expression for the search half-width is:
[0032]
[0033] In the formula, This indicates the absolute baseline half-width.
[0034] In one embodiment of this application, multiple hypothetical input vectors are constructed based on multiple dosage combinations, water quality data, and flocculation characteristic data, including:
[0035] The water quality data and the flocculation characteristic data are preprocessed to obtain preprocessed water quality data and preprocessed flocculation characteristic data. The preprocessing includes outlier handling, filtering, resampling, hysteresis compensation, normalization, and time series reconstruction.
[0036] Multiple dosage combinations are concatenated with the pretreated water quality data and the pretreated flocculation characteristic data to obtain the feature vector at the current time point; and a hypothesis input vector is constructed based on the feature vectors at multiple time points and the feature vector at the current time point.
[0037] In one embodiment of this application, a target input vector and a target dosage combination of the target input vectors are selected based on the cost and predicted water quality indicators of multiple hypothetical input vectors, including:
[0038] The predicted water quality indicators corresponding to multiple hypothetical input vectors are compared with the preset minimum indicators.
[0039] When multiple hypothetical input vectors predict water quality indicators that are less than or equal to the minimum indicator, the total cost of the reagents for the multiple hypothetical input vectors is calculated, and the hypothetical input vector with the lowest total cost is taken as the target input vector.
[0040] When there is only one hypothetical input vector whose predicted water quality index is less than or equal to the minimum index, the hypothetical input vector that is less than or equal to the minimum index shall be used as the target input vector.
[0041] When there is no hypothetical input vector whose predicted water quality index is less than or equal to the minimum index, calculate the difference between the predicted water quality index of multiple hypothetical input vectors and the minimum index, and take the hypothetical input vector with the smallest difference as the target input vector.
[0042] The dosage of various agents is extracted from the target input vector to obtain the target dosage combination.
[0043] In one embodiment of this application, the plurality of water quality prediction models include a turbidity prediction model and a total phosphorus and chemical oxygen demand prediction model, wherein the water quality prediction models are trained from labeled training samples.
[0044] In one embodiment of this application, it further includes:
[0045] The target delivery quantity combination determined at the current time point is sent to the drug delivery execution module so that the drug delivery execution module can execute the target delivery quantity combination.
[0046] This application also provides a water treatment dosing optimization system based on multi-model collaboration and dynamic hypothesis space, including:
[0047] The acquisition module is used to acquire water quality data and underwater image sequences within a target time period, and to acquire the actual dosage sequence of multiple time points before the current time point. The target time period includes the current time point and multiple time points before the current time point. The water quality data includes the values of various water quality parameters, and the actual dosage sequence includes the actual dosage of various agents at multiple time points. The water quality data and the actual dosage sequence are aligned through pool capacity lag compensation.
[0048] The feature extraction module is used to extract flocculation feature data from multiple frames of underwater images in the underwater image sequence, wherein the flocculation feature data includes the values of various flocculation parameters;
[0049] The hypothesis space simulation module is used to calculate the fluctuation characteristics of the actual dosage sequence. It constructs a dynamic hypothesis space based on the actual dosage and fluctuation characteristics of multiple agents at the previous time point, extracts multiple dosage combinations from the dynamic hypothesis space, and constructs multiple hypothesis input vectors based on these dosage combinations, water quality data, and flocculation characteristic data. The calculation of the fluctuation characteristics of the actual dosage sequence includes: calculating the coefficient of variation and mean absolute difference of the actual dosage of each agent at multiple time points in the actual dosage sequence; weighting the coefficient of variation and mean absolute difference of the actual dosage of each agent to obtain a comprehensive volatility score for each agent; weighting the comprehensive volatility scores of multiple agents to obtain the fluctuation characteristics of the actual dosage sequence, wherein the weights of multiple agents are based on the correlation evaluation between agent price and flocculation effect; and constructing a dynamic hypothesis space based on the actual dosage and fluctuation characteristics of multiple agents at the previous time point, and extracting multiple dosage combinations from the dynamic hypothesis space, including: calculating the amplitude coefficient based on the fluctuation characteristics. and step scaling factor Wherein, the expansion coefficient and the step scaling factor The mathematical expression is:
[0050]
[0051]
[0052] In the formula, Indicates fluctuation characteristics, Indicates the maximum expansion coefficient. Indicates the maximum fluctuation score. Indicates the minimum fluctuation score. This represents the maximum reduction factor; based on the actual dosage of various agents at the previous time point and the expansion factor. Calculate the search half-width, determine the search boundary based on the search half-width and the actual dosage of various agents at the previous time point, and determine the search boundary based on the step size scaling factor. Determine the search step size, wherein the mathematical expressions for the search boundary and the search step size are:
[0053]
[0054]
[0055]
[0056] In the formula, Indicates the first The lower limit of the search for a certain drug. Indicates the first The actual amount of the pesticide applied at the previous time point. Indicates the first The search half-width of the drug. Indicates the first The upper limit of the search for a certain drug. Indicates the first The search step size for each drug Indicates the minimum allowable step size. The search is performed within the search boundary using the search step size to obtain a set of candidate values for multiple agents; and the Cartesian product of the set of candidate values for multiple agents is performed to obtain multiple dosage combinations.
[0057] The optimization module is used to predict the predicted water quality index for each hypothetical input vector based on multiple pre-built water quality prediction models, and to select the target input vector and the target delivery quantity combination of the target input vector based on the cost of multiple hypothetical input vectors and the predicted water quality index. Each water quality prediction model predicts one water quality index.
[0058] The beneficial effects of this application are as follows: This application presents a water treatment dosing optimization method and system based on multi-model collaboration and a dynamic hypothesis space. Addressing the challenges of traditional PID control in handling large time delays, multivariate coupling, and delayed responses to sudden changes in water quality, this invention introduces flocculent image features (such as particle size and fractal dimension) to enable the model to perceive the microscopic morphological changes during the flocculation process, significantly improving response speed and control accuracy under complex operating conditions. To address the shortcomings of existing neural network predictive control, such as ignoring flocculation features, weak generalization ability of single models, and high computational cost of fixed grid search, this invention employs a multi-model collaborative prediction architecture, effectively improving the prediction accuracy and generalization of multi-objective effluent water quality. Simultaneously, it dynamically constructs a hypothesis space based on the fluctuation characteristics of the actual dosing sequence, adaptively adjusting the search range and step size, avoiding full-space enumeration, effectively reducing computational cost, and achieving real-time optimization. Attached Figure Description
[0059] The present application will be further described below with reference to the accompanying drawings and embodiments:
[0060] Figure 1 This is an application scenario diagram of a water treatment dosing optimization method based on multi-model collaboration and dynamic hypothesis space, as shown in one embodiment of this application.
[0061] Figure 2 This is a schematic diagram of the underwater camera configuration interface in one embodiment of this application;
[0062] Figure 3 This is a flowchart illustrating a water treatment dosing optimization method based on multi-model collaboration and dynamic hypothesis space in one embodiment of this application;
[0063] Figure 4 This is an example of an underwater image in one embodiment of this application;
[0064] Figure 5 This is a structural diagram of a water treatment dosing optimization system based on multi-model collaboration and dynamic hypothesis space, as shown in one embodiment of this application. Detailed Implementation
[0065] The following specific examples illustrate the implementation of this application. Those skilled in the art can easily understand other advantages and effects of this application from the content disclosed in this specification. This application can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of this application. It should be noted that, unless otherwise specified, the following embodiments and features in the embodiments can be combined with each other.
[0066] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of this application. Therefore, the drawings only show the layers related to this application and are not drawn according to the actual number, shape and size of the layers in the actual implementation. In the actual implementation, the form, number and proportion of each layer can be arbitrarily changed, and the layer layout may also be more complex.
[0067] Numerous details are explored in the following description to provide a more thorough explanation of embodiments of this application; however, it will be apparent to those skilled in the art that embodiments of this application may be practiced without these specific details.
[0068] Figure 1 This is an application scenario diagram illustrating a water treatment dosing optimization method based on multi-model collaboration and dynamic hypothesis space, as shown in one embodiment of this application. Figure 1 As shown, this system is deployed in the sedimentation tank area of the wastewater treatment plant. The main hardware includes:
[0069] Multiple water quality sensors 110: Installed at the inlet, middle of the sedimentation tank, and outlet, for real-time acquisition of water quality parameters. These include, but are not limited to: pH sensors, temperature sensors, flow meters, conductivity sensors, influent turbidity meters, effluent turbidity meters, and online analyzers for total phosphorus (TP) and chemical oxygen demand (COD).
[0070] Underwater camera 120: Fixed in the flocculation reaction zone of the sedimentation tank or near the effluent weir, equipped with LED supplemental lighting, for continuously acquiring underwater image sequences of the flocs. Camera 120 acquires one frame per minute, which, after being treated to be waterproof and antifouling, is transmitted to the onshore control room via coaxial cable or network cable.
[0071] Automatic dosing device 140: Composed of a metering pump, a chemical storage tank, and a control valve, it is connected to the main unit 130 via a control line. According to the dosing instructions issued by the main unit 130, it automatically adds water purification agents such as coagulants (such as PAC) and flocculants (such as PAM) to the sedimentation tank inlet pipe or flocculation zone. Figure 2 This is a schematic diagram of the underwater camera configuration interface in one embodiment of this application. The specific configuration interface is as follows: Figure 2 As shown.
[0072] Host 130: Located in the onshore machine room, it is equipped with a high-performance industrial computer (GPU acceleration) and runs the dosing optimization algorithm described in this invention. Host 130 receives data from water quality sensor 110 and camera 120 via data acquisition card or industrial Ethernet, processes the data to generate dosing instructions, and then sends them to automatic dosing device 140 via PLC or direct digital control (DDC).
[0073] Based on the above hardware structure, the overall concept of this application includes:
[0074] (1) Data alignment and feature extraction: First, obtain the water quality data and underwater image sequence within a historical window before the current time point, and obtain the actual dosage sequence of multiple time points before the current time point (the dosage at the current time point is unknown and is the decision time point).
[0075] Using a pool volume lag compensation algorithm, the water retention time is dynamically calculated based on the volume and instantaneous flow rate of each treatment unit. The influent water quality and chemical dosage data are then shifted backward to precisely align with the effluent water quality. The images in the pool are then aligned with the influent / effluent time points using pre-calibrated time difference compensation values.
[0076] Training phase: The aligned effluent water quality is used as the label (target value) of the training samples.
[0077] Inference phase: The quality of the effluent is not included in the input and is only used for the final effect evaluation.
[0078] Meanwhile, geometric features (such as area, diameter, and fractal dimension) and texture features (such as gray-level variance and entropy) of flocs are extracted from underwater images to form a quantitative description of the flocculation state.
[0079] During the real-time inference (prediction) phase, the model's inputs only include: influent water quality, dosage (historical true value or current assumed value), and flocculation characteristics. Effluent water quality is not used as an input feature to ensure causal consistency.
[0080] (2) Dynamic hypothesis space generation: Analyze the volatility of the historical actual drug dosage sequence (such as coefficient of variation, mean absolute difference) to obtain a comprehensive volatility index. Based on the actual dosage of each agent at the previous time point, the search range (narrow when stable, wide when drastic) and sampling step size (sparse when stable, dense when drastic) are adaptively determined according to the magnitude of the volatility. A finite number of candidate dosage combinations are generated through Cartesian product to avoid full space enumeration.
[0081] (3) Hypothesis Input Vector Construction: For each candidate dosage combination, it is used as the hypothetical dosage at the current time point. Together with the historical time step, the actual water quality, flocculation characteristics, and actual dosage at the current time point, it forms a time series tensor, which is used as the input to the LSTM model. In this tensor, the dosage at the historical time step is the actual historical value, and the dosage at the current time point is the hypothetical value, representing the hypothetical scenario of "if the dosage is added at the current time point according to a certain set, and the historical state remains unchanged".
[0082] (4) Multi-model prediction: Multiple pre-trained water quality prediction models are used to predict different effluent indicators (such as turbidity and total phosphorus) for each hypothetical input vector. Each model focuses on one target to achieve multi-indicator collaborative prediction.
[0083] The water quality prediction model in this application uses an LSTM model. The input layer receives time-series data in the shape of (time step, feature dimension) (time step is 7, and the feature dimension includes water quality, flocculation features, and dosage). Two LSTM layers are then stacked, each with 64 hidden units, and Dropout (0.2) is added to prevent overfitting. Finally, a fully connected layer (32 neurons, ReLU activation) outputs the predicted water quality index (a single numerical value).
[0084] Training process: Historical data (after lag compensation and normalization) is used, with mean squared error (MSE) as the loss function, and optimization is performed using the Adam optimizer (learning rate 0.001). Batch size is 32, maximum number of training epochs is 100, and early stopping is enabled (the training terminates if the validation set loss does not decrease for 10 consecutive epochs). The model is automatically retrained and hot-replaced daily using the latest data.
[0085] (5) Tiered optimization and decision-making: Based on the principle of "compliance first, cost second best", first select the combination of all key indicators (such as total phosphorus) with the predicted values meeting the standards; then select several combinations with the best predicted values of the main indicators (such as turbidity); finally, within a 5% margin of the best values, select the combination with the lowest total cost of the reagents as the final recommendation. If there is no combination that meets the standards, select the combination with the lowest predicted value of the main indicator as the fallback strategy.
[0086] (6) Send to the executor for execution, and return to step (1) for automatic loop execution at the next time point.
[0087] The above overall approach achieves precise, efficient, and adaptive control of water treatment chemical dosing through physical alignment, visual perception, dynamic sampling, multi-model collaboration, and hierarchical optimization. The specific solution is described below.
[0088] Figure 3 This is a flowchart illustrating a water treatment dosing optimization method based on multi-model collaboration and dynamic hypothesis space, as shown in one embodiment of this application. Figure 3 As shown, a water treatment dosing optimization method based on multi-model collaboration and dynamic hypothesis space in this application mainly includes the following steps:
[0089] S310, acquire water quality data and underwater image sequences within a target time period, and acquire actual dosing sequence for multiple time points prior to the current time point. The target time period includes the current time point and multiple time points prior to it. The water quality data includes values of various water quality parameters, and the actual dosing sequence includes the actual dosage of various chemicals at multiple time points. The water quality data and the actual dosing sequence are aligned using pool capacity lag compensation.
[0090] Specifically, the host reads water quality parameters such as influent flow rate, influent turbidity, effluent turbidity, pH, temperature, TP, and COD from each water quality sensor 110 at a 1-minute cycle and stores them in a real-time database.
[0091] The host computer synchronously triggers the camera to capture underwater images of the flocs in the sedimentation tank. Figure 4 As an example of an underwater image in one embodiment of this application, the underwater image is as follows: Figure 4 As shown, after preprocessing each frame of the image including grayscale conversion, Gaussian filtering, and adaptive threshold segmentation, the following flocculation features are extracted: total number of flocs, total number of fine particles, fractal dimension, average diameter, average perimeter, average area, grayscale variance, gradient, kurtosis, and entropy. These features reflect the morphology, density, and spatial distribution of the flocs. The specific feature extraction process will be described later.
[0092] Because there is a certain residence time between the water at the dosing point and the sedimentation tank outlet, the main unit dynamically calculates the lag time based on the current influent flow rate and the volume of each treatment unit. It then shifts the influent water quality parameters and dosing parameters backward to align with the effluent water quality parameters, ensuring causal consistency between training and prediction samples. The mathematical expression for the lag time is:
[0093]
[0094] In the formula, Indicates the first Each processing unit at time... The effective lag time, For the first The empirical correction factor for each treatment unit (used to compensate for the "short-flow effect" (some water flows out along a shorter path) in actual engineering), dead zones, or non-ideal flow. The smaller the value, the more severe the short circuit or dead zone, and the shorter the effective residence time. This can be calibrated through tracer experiments. Indicates the first The volume of each processing unit Indicates time The inflow rate.
[0095] S320, extract flocculation feature data from multiple frames of underwater images in the underwater image sequence, wherein the flocculation feature data includes values of various flocculation parameters;
[0096] In this application, image processing techniques are used to extract features from multiple frames of underwater images in an underwater image sequence, which are then used as features for subsequent model input. Specifically, this includes:
[0097] S321, preprocess each frame of the underwater image in the underwater image sequence to obtain a preprocessed image, wherein the preprocessing includes grayscale conversion, Gaussian filtering and contrast enhancement;
[0098] Specifically, the RGB color image is converted to a single-channel grayscale image to reduce computational cost while preserving the brightness information of the flocs. A Gaussian kernel is then used to convolve the image to smooth noise while preserving the floc edges. Finally, CLAHE (Contrast-Limited Adaptive Histogram Equalization) is applied to enhance local contrast, making the separation of the flocs from the background more obvious. These preprocessing steps eliminate uneven illumination and sensor noise, highlight the floc contours, provide high-quality input for subsequent segmentation, and improve the accuracy and stability of feature extraction.
[0099] S322, The preprocessed image is binarized based on an adaptive threshold to obtain a binarized image;
[0100] Specifically, for each pixel, the average grayscale value within its neighborhood (e.g., 15×15) is used as a reference to dynamically calculate the threshold. If the pixel's grayscale value is less than (1-offset) times the neighborhood average, it is set as the foreground (flocculent); otherwise, it is set as the background. Adaptive binarization can adaptively distinguish between flocculents and the background, and is especially suitable for environments with uneven lighting within the pool.
[0101] S323, Perform morphological closing operation on the binarized image to obtain a morphologically processed image;
[0102] The principle of morphological closing operations is to first expand and then erode, filling the small pores inside the floc and connecting adjacent floc fragments. This eliminates the micro-voids and fractures caused by segmentation, making the floc region more complete and continuous, and improving the reliability of subsequent connected domain analysis.
[0103] S324, Select connected regions with an area greater than or equal to a preset area threshold from the morphologically processed image to obtain multiple flocs in the image;
[0104] Specifically, all connected components are identified using an 8-connectivity or 4-connectivity labeling algorithm. The area (number of pixels) of each connected component is calculated, and small noise points with an area smaller than a preset threshold (e.g., 50 pixels) are removed. The remaining connected components are the valid flocs. This process removes noise and minor impurities, retaining only the true flocs, reducing false detections, and improving the accuracy of subsequent statistical features.
[0105] S325: Extract the area, perimeter, equivalent diameter, and centroid coordinates of each floc; and count the total number of flocs. ;
[0106] Among them, area ( (For flocculent index) is obtained by counting the number of pixels within the connected component, perimeter This is the pixel length of the edge of the connected component (4-connected or 8-connected correction).
[0107] equivalent diameter The formula for calculation is: .
[0108] S326, calculate the average diameter based on the equivalent diameter of multiple flocs; calculate the average area based on the area of multiple flocs; calculate the average perimeter based on the perimeter of multiple flocs; and screen out the number of fine particles with an equivalent diameter less than a preset threshold.
[0109] Then, the average value is calculated based on the individual characteristics of all flocs, and fine particles are screened out according to the particle size threshold. The calculation formula is as follows:
[0110] Average diameter: ,in, Indicates the number of flocs in the image;
[0111] Average area: ;
[0112] Average perimeter, ;
[0113] Total number of fine particles By using a preset threshold, flocs are screened. Fine particles are generated when impurities in the water do not react sufficiently with the reagent. By counting the number of fine particles, information on whether the reaction is sufficient can be included in subsequent features.
[0114] S327, Extract the fractal dimension of the morphologically processed image based on box counting; and calculate the gray-level variance, average gradient, kurtosis and entropy of the preprocessed image;
[0115] Fractal dimension reflects the irregularity and structural complexity of the floc boundaries. The calculation of fractal dimension involves covering a binary floc image with grids of different scales, counting the number of grids covering the foreground, and fitting the absolute value of the slope of a double logarithmic curve. Specifically, this includes:
[0116] (1) Take a binary image containing all flocs (or take only the largest flocs).
[0117] (2) Using different side lengths Grid overlay image (e.g.) (pixels).
[0118] (3) For each Count the number of grids covering the flocs (foreground). .
[0119] (4) Fit a straight line in a double logarithmic coordinate system:
[0120]
[0121] In the formula, Represents the intercept and the absolute value of the slope. That is, the fractal dimension, for example: A value close to 1 indicates that the flocs have a dense structure and smooth boundaries. A value close to 2 indicates that the floc structure is loose and the boundaries are complex.
[0122] Dense flocs with smooth boundaries indicate that the dosage of coagulant / coagulant aid is appropriate, the colloidal particles in the water have been effectively destabilized and aggregated into large, dense particles, and the binding force between the flocs is strong. At this point, the effluent turbidity is low, and there is no need to adjust the dosage, or it can be appropriately reduced to save costs. Loose flocs with complex boundaries usually indicate that the particles have not been completely destabilized, the flocs are not fully grown, the structure is loose, and excessive shear force leads to floc breakage and the formation of irregular fragments.
[0123] Gray variance The formula for calculation is:
[0124]
[0125] In the formula, Indicates the size of the graphic. Represents pixel coordinates, Represents pixels grayscale, This represents the average gray level of the image.
[0126] average gradient The formula for calculation is:
[0127]
[0128] In the formula, Represents the grayscale value of a pixel;
[0129] Kudo The formula for calculation is:
[0130]
[0131] entropy The mathematical expression is:
[0132]
[0133] In the formula, Indicates grayscale level. This represents the probability of the grayscale histogram.
[0134] Gray-level variance, average gradient, kurtosis, and entropy together describe the texture characteristics of flocculent populations, which are related to flocculation effect and particle size distribution, and make up for the microstructural information that geometric features cannot express.
[0135] S328, construct flocculation feature data based on the total number of flocs, average diameter, average perimeter, number of fine particles, fractal dimension, gray-level variance, average gradient, kurtosis and entropy.
[0136] Finally, all the above statistics are combined into a fixed-dimensional feature vector. As part of the input to the subsequent LSTM model, it is represented as:
[0137]
[0138] Through the above feature extraction process, a multi-angle, multi-level feature description of the flocculation process is formed, including individual morphology (diameter, area), population distribution (number of fine particles), and texture complexity (fractal dimension, entropy). These features, combined with water quality parameters and chemical dosage, can significantly improve the accuracy of effluent water quality prediction.
[0139] S330, calculate the fluctuation characteristics of the actual dosage sequence, construct a dynamic hypothesis space based on the actual dosage and fluctuation characteristics of multiple agents at the previous time point, extract multiple dosage combinations from the dynamic hypothesis space, and construct multiple hypothesis input vectors based on multiple dosage combinations, water quality data and flocculation characteristic data;
[0140] This application employs a dynamic hypothesis space approach to enumerate possible deployment combinations, thereby providing a data foundation for subsequent multi-mode collaboration. However, setting the same hypothesis space and using the same data collection step size to construct hypothetical deployment combinations under all circumstances would result in a waste of computational resources for verification during low-fluctuation operating conditions.
[0141] Based on the above problems, this application proposes a solution that aims to save computation time and improve efficiency by dynamically adjusting the search range and sampling density of the hypothesis space according to the fluctuation characteristics of the actual dosage sequence. Its core logic can be summarized as "allocating computational resources on demand."
[0142] Low-fluctuation conditions (stable dosage): Under these conditions, water quality and flocculation status change gradually, and the optimal dosage is likely to fall within a small range near the actual value at the previous time point. If a fixed, large-range, high-density search is still used (e.g., ±30% of the entire interval, 1% step size), a large number of redundant combinations (e.g., hundreds to thousands) will be generated, resulting in a waste of computational resources. The strategy at this time is to automatically reduce the search range (e.g., ±10%) and increase the sampling step size (e.g., 3%~5%), which can reduce the number of combinations by more than 70% and reduce the response time from several seconds to sub-seconds, without sacrificing optimization accuracy.
[0143] High-fluctuation operating conditions (drastic changes in dosing): This may correspond to sudden changes in influent water quality, instability in flocculation, etc. The optimal dosing point may be far from the actual value at the previous time point, and higher accuracy is required. In this case, a fixed small-range search is prone to missing the global optimum, leading to control failure. The strategy in this case is to expand the search range (e.g., ±50%) and increase the step size (e.g., 0.5%~1%). Although the number of combinations increases, the computational cost is only incurred when necessary, avoiding the contradiction of either constant waste or insufficient supply during abnormal situations caused by a "one-size-fits-all" approach.
[0144] The above strategy is based on the fluctuation characteristics of the actual dosage of various drugs within the target time period. The calculation methods for these fluctuation characteristics include:
[0145] S331, calculate the coefficient of variation and mean absolute difference of the actual dosage of each agent at multiple time points in the actual dosage sequence;
[0146] For each medicine Take the actual dosage sequence within its historical window (length L, e.g., 30 minutes): ;
[0147] Then, the coefficient of variation is calculated based on the above actual dosage sequence. and mean absolute difference coefficient of variation and mean absolute difference The mathematical expression is:
[0148]
[0149]
[0150] In the formula, This represents the standard deviation (percentage) of the actual dosage sequence. This represents the mean (percentage) of the actual dosage sequence. To prevent the coefficient from being divided by zero, for The actual amount added at any given time for The actual amount added at any given time.
[0151] S332, the coefficient of variation and mean absolute difference of the actual dosage of each agent are weighted to obtain the comprehensive volatility score of each agent;
[0152] coefficient of variation and mean absolute difference A weighted average is used to create a comprehensive score, balancing the effects of relative fluctuations and instantaneous changes. Because the two have different dimensions, it is necessary to... Divide by 100 to normalize (because the dosage range is 0~100). Overall volatility score for each drug. for:
[0153]
[0154] In the formula, These are the weighting coefficients.
[0155] coefficient of variation Measuring overall volatility (relative to the mean) reflects the dispersion of the sequence, but it cannot reflect the frequency of abrupt changes between adjacent time points. Mean absolute difference (MAD) It measures the drasticness of instantaneous changes, is sensitive to local jumps, but is less affected by the mean and may ignore slow drifts. This can be achieved by assigning weights (e.g., ...). =0.5), the comprehensive score can capture both long-term trend drift (CV) and short-term sharp changes (MAD), more accurately reflecting the true degree of fluctuation in the operating conditions, thereby driving the dynamic hypothesis space to make reasonable range and step size adjustments, avoiding over- or under-search.
[0156] S333, the overall volatility score of multiple agents is weighted to obtain the volatility characteristics of the actual dosage sequence, wherein the weights of multiple agents are based on the correlation evaluation of agent price and flocculation effect.
[0157] Different chemicals contribute differently to effluent quality and cost. For example, coagulants (such as PAC) are relatively inexpensive but play a decisive role in flocculation, while coagulant aids (such as PAM) are expensive and used in small quantities. Therefore, when calculating overall volatility, higher-priced or more important chemicals should be given greater weight, making their volatility more influential in expanding or narrowing the search scope. Overall Volatility Characteristics The formula for calculation is:
[0158]
[0159]
[0160] In the formula, Indicates the type and quantity of medicines. For the first Normalized weights of the drugs For balance coefficient, For the first Normalized price of a drug. For the first The correlation score of the flocculation effect of the agent (obtained by expert experience or correlation analysis based on big data, indicating the degree of influence of the agent on the flocculation effect). For drug type index, For the first Normalized price of a drug. For the first Correlation score of the flocculation effect of the drug.
[0161] After obtaining the fluctuation characteristics, a dynamic hypothesis space can be constructed based on these characteristics, and multiple hypothesis input vectors can be generated, including:
[0162] S334, Calculate the amplitude expansion coefficient based on the fluctuation characteristics. and step scaling factor Wherein, the expansion coefficient and the step scaling factor The mathematical expression is:
[0163]
[0164]
[0165] In the formula, Indicates fluctuation characteristics, Indicates the maximum expansion coefficient. Indicates the maximum fluctuation score. Indicates the minimum fluctuation score. Indicates the maximum reduction factor;
[0166] The principle of step S334 is: to take the overall fluctuation characteristics obtained in the previous step... Linear mapping to two coefficients:
[0167] Expansion coefficient Used to amplify the search half-width; the greater the fluctuation... The larger the value, the wider the search range.
[0168] Step scaling factor Used to reduce the search step size; the greater the fluctuation... The smaller the step size, the closer the step size (the higher the accuracy).
[0169] S335, based on the actual dosage of various agents at the previous time point and the aforementioned amplification coefficient. The search half-width is calculated as follows:
[0170] S335-1, when the first The amount of the agent applied at the previous time point satisfy: At that time, calculate the search half-width. The mathematical expression for the search half-width is:
[0171]
[0172] In the formula, For drug type index, Indicates the base half-width factor;
[0173] The amount of data released at the previous point in time Multiply by the base half-width factor (Typically 0.3) and expansion factor This yields half the width. However, boundary cases (0 or 100%) require special handling; otherwise, the proportional method will result in zero half the width or be completely unable to search to one side.
[0174] S335-2, when the first The amount of the agent applied at the previous time point satisfy: or At that time, calculate the search half-width. The mathematical expression for the search half-width is:
[0175]
[0176] In the formula, This indicates the absolute baseline half-width.
[0177] In boundary conditions, the absolute reference half-width (e.g., 30%) is used as the unidirectional expansion scaling factor. Under normal operating conditions, the search range is proportional to the dose (the absolute range of change is large when the dose is large, which conforms to actual processes). At the boundary, the search range is prevented from degenerating into a single point, ensuring that the system can be effectively adjusted from zero dosing or full-scale state.
[0178] For example: , , ;
[0179] Agent A: Dosage (Normal range) The corresponding range is [45%-21.9%, 45%+21.9%] = [23.1%, 66.9%];
[0180] Drug B: Dosage (boundary), The upper limit is 48.66%.
[0181] S336, determine the search boundary based on the search half-width and the actual dosage of various agents at the previous time point, and determine the step size scaling factor based on the step size scaling factor. Determine the search step size, wherein the mathematical expressions for the search boundary and the search step size are:
[0182]
[0183]
[0184]
[0185] In the formula, Indicates the first The lower limit of the search for a certain drug. Indicates the first The amount of this agent applied at the previous time point. Indicates the first The search half-width of the drug. Indicates the first The upper limit of the search for a certain drug. Indicates the first The search step size for each drug Indicates the minimum allowable step size. Base step size;
[0186] The search boundary in this application is calculated by adding or subtracting half the width from the actual dose at the previous time point, and then truncating to the [0, 100%] physical range. Base step size. (e.g., 2%) multiplied by the scaling factor Then, with the minimum allowable step size (e.g., 0.5%) Take the maximum value to prevent excessively dense step sizes from causing combinatorial explosion.
[0187] Boundary cutoff ensures all assumed doses remain within the device's allowable range. Dynamic step size adjustment: a large step size during stable periods (faster calculations), and a small step size during periods of fluctuation (higher accuracy), with a lower limit to ensure controllability.
[0188] For example: Agent d: dosage , ,but:
[0189]
[0190]
[0191] set up , , ;
[0192]
[0193] The hypothesis space is as follows: starting from 23.1%, the value is increased to 66.9% with a step size of about 1.07%, resulting in approximately (66.9-23.1) / 1.07+1≈42 candidate values.
[0194] The above distance represents a high-volatility segment. In a low-volatility segment, the number of candidate points will decrease to 10-20, thereby effectively reducing the computational load and improving operational efficiency.
[0195] S337, search within the search boundary with the search step size to obtain a set of candidate values for multiple agents; and perform a Cartesian product on the set of candidate values for multiple agents to obtain multiple dosage combinations.
[0196] Finally, for each drug, within its range Inner step length Discretize the drug to obtain a list of candidate values. Then, perform a Cartesian product on all candidate lists to generate all possible dosage combinations. Each combination corresponds to a set of hypothetical dosage vectors.
[0197] Finally, using the obtained combinations of multiple delivery volumes, a hypothetical input vector for the time series is constructed, specifically including:
[0198] S338, The water quality data and the flocculation characteristic data are preprocessed to obtain preprocessed water quality data and preprocessed flocculation characteristic data, wherein the preprocessing includes outlier handling, filtering, resampling, hysteresis compensation, normalization and time series reconstruction.
[0199] Specifically, preprocessing includes:
[0200] Outlier Handling: Outlier handling identifies and corrects obvious erroneous values in sensor data acquisition (such as negative values, values outside the physical range, and abrupt changes). Common methods include setting negative values to NaN and then padding them using linear interpolation or forward padding.
[0201] Filtering: Kalman filtering is used to recursively smooth the time series data, and the state-space model is used to estimate the true value to eliminate Gaussian noise and random fluctuations.
[0202] Resampling: Data from different sampling frequencies (such as water quality every minute, images every 5 minutes) are unified to the same equally spaced time axis through linear interpolation or forward padding.
[0203] Lag compensation: The water retention time is dynamically calculated based on the volume and instantaneous flow rate of each treatment unit (as mentioned above), and the influent water quality and chemical dosage sequence is shifted backward to align with the effluent water quality.
[0204] Normalization: For each feature dimension, use the maximum and minimum values (or mean and standard deviation) of the historical sliding window to perform Min-Max normalization (or Z-score standardization), mapping the values to [0,1] or a standard normal distribution.
[0205] Time series reconstruction: A fixed-length historical window (e.g., the past 90 minutes) is set. Using the current moment as the endpoint, features from multiple time points are extracted at fixed steps (e.g., 15 minutes) to form samples of shape (time step, number of features). Each sample corresponds to a prediction target (e.g., the effluent water quality for the next 30 minutes). In addition, flocculation features are also compensated and aligned according to pre-calibrated time differences.
[0206] Through the above six preprocessing steps, the original data is cleaned, aligned, smoothed, normalized, and reconstructed into high-quality time series samples, laying a reliable foundation for the subsequent construction of hypothesis input vectors and model prediction.
[0207] S339, the multiple dosage combinations are spliced with the pretreated water quality data and the pretreated flocculation characteristic data to obtain the feature vector at the current time point; and a hypothesis input vector is constructed based on the feature vectors at multiple time points and the feature vector at the current time point.
[0208] Among them, feature vectors at multiple time points It can be represented as:
[0209]
[0210] In the formula, Indicates the combination of delivery volume. Indexed by time point;
[0211] The feature vector here For the quality of the incoming water, Features captured by cameras inside the pool.
[0212] The dosage combinations at historical time points are the actual dosage combinations, and are horizontally concatenated with the pretreated water quality data and pretreated flocculation characteristic data at the corresponding historical time points to obtain a one-dimensional feature vector for each historical time point. For each candidate dosage combination (the assumed dosage at the current time point), it is horizontally concatenated with the pretreated water quality data and pretreated flocculation characteristic data at the current moment to form a complete one-dimensional feature vector.
[0213] For an LSTM model, its input requires multiple historical time steps. We keep the features of the historical time steps (before the current time step) unchanged (where the dosage is the actual historical dosage), and only assume that the dosage at the current time step is the dosage generated from the candidate combinations. This yields the input vector:
[0214]
[0215] The above input vector is the hypothetical input vector for the subsequent model.
[0216] S340 predicts the predicted water quality index for each hypothetical input vector based on multiple pre-built water quality prediction models, and selects the target input vector and the target delivery quantity combination of the target input vector based on the cost of multiple hypothetical input vectors and the predicted water quality index. Each water quality prediction model predicts one water quality index.
[0217] The physicochemical mechanisms and dominant factors of different water quality indicators (turbidity, total phosphorus, COD, etc.) vary. A single model, which forces a single network to fit all outputs, is prone to conflicts or compromises. Multi-model approaches allow for the independent selection of optimal input features for each indicator (e.g., turbidity depends on image features, total phosphorus depends on pH and phosphorus removal agents), and individual parameter tuning, resulting in higher prediction accuracy for each indicator.
[0218] This application employs two prediction models in a specific context, including:
[0219] (1) Model-A, turbidity prediction model, LSTM prediction model for turbidity index;
[0220] (2) Model-B, using other indicators (TP, COD, etc.) as target variables;
[0221] The above models are trained using historical data. Model-A is trained using training data with turbidity labels (turbidity labels are the turbidity in the effluent water quality data mentioned above), and Model-B is trained using training data with other indicator labels (turbidity labels are other indicators in the effluent water quality data mentioned above). The specific training process is existing technology and will not be described in detail here.
[0222] The multiple hypothetical input vectors constructed above are input into Model-A and Model-B respectively to obtain the predicted turbidity and other indicators (TP, COD, etc.).
[0223] Each hypothesis input vector corresponds to a combination of water quality indicators, for example:
[0224] Suppose that a candidate dosing combination corresponding to a certain hypothetical input vector is (PAC=48%, PAM=13%), and Model-A predicts an effluent turbidity of 2.1 NTU, while Model-B predicts a total phosphorus (TP) of 0.25 mg / L and a COD of 18 mg / L. Then, the water quality index combination corresponding to this hypothetical input vector is (turbidity = 2.1 NTU, TP = 0.25 mg / L, COD = 18 mg / L).
[0225] After obtaining multiple hypothetical input vectors and the corresponding water quality indicators, the optimal solution can be selected using the hierarchical optimization and decision-making method proposed in this application. The specific process is as follows:
[0226] S341 compares the predicted water quality indicators corresponding to multiple hypothetical input vectors with the preset minimum indicators;
[0227] The preset minimum indicators (such as turbidity ≤ 4.0 NTU, total phosphorus ≤ 0.5 mg / L) represent the upper limit of the effluent water quality compliance. For each hypothetical input vector, its predicted indicators are compared with the corresponding standards one by one to determine whether it "meets the standard" (i.e., the predicted value ≤ the standard). This step divides all candidate schemes into two categories: compliant and non-compliant.
[0228] For example:
[0229] Preset standards: Turbidity ≤ 4.0 NTU, total phosphorus ≤ 0.5 mg / L. Three hypothetical vectors and their prediction results:
[0230] A: Turbidity 3.2, Total Phosphorus 0.4 → Meets standards;
[0231] B: Turbidity 3.8, Total Phosphorus 0.6 → Total phosphorus exceeds the standard, failing to meet the requirement;
[0232] C: Turbidity 5.1, Total Phosphorus 0.3 → Turbidity exceeds standard, fails to meet standard;
[0233] S342, when there are multiple hypothetical input vectors whose predicted water quality indicators are less than or equal to the minimum indicator, calculate the total cost of the reagents for the multiple hypothetical input vectors, and take the hypothetical input vector with the lowest total cost as the target input vector;
[0234] When multiple hypothetical input vectors satisfy all water quality indicators, the system further calculates the total cost of chemicals for each scheme (the sum of the unit price of chemicals and the dosage). Among the schemes that meet the standards, the one with the lowest total cost is selected as the optimal solution. This reflects the economic objective of "second-best cost"—saving as much chemical cost as possible while ensuring compliance.
[0235] For example:
[0236] Option 1: PAC=45%, PAM=12%, cost=45×6+12×20=270+240=510 yuan / thousand tons of water;
[0237] Option 2: PAC=48%, PAM=10%, cost = 48×6+10×20=288+200=488 yuan / thousand tons of water;
[0238] Option 3: PAC=42%, PAM=14%, cost=42×6+14×20=252+280=532 yuan / thousand tons of water;
[0239] The lowest total cost is option 2 (488 yuan), which is selected as the target input vector.
[0240] S343, when there is only one hypothetical input vector whose predicted water quality index is less than or equal to the minimum index, the hypothetical input vector that is less than or equal to the minimum index shall be used as the target input vector.
[0241] If there is exactly one hypothetical input vector that satisfies all water quality indicators, then no cost comparison is needed; this vector is directly taken as the optimal solution. This is the fallback option for achieving the standards.
[0242] S344, when there is no predicted water quality index of any hypothetical input vector that is less than or equal to the minimum index, calculate the difference between the predicted water quality index of multiple hypothetical input vectors and the minimum index, and take the hypothetical input vector with the smallest difference as the target input vector.
[0243] When at least one metric in all hypothetical input vectors exceeds the standard, the system abandons the hard constraints and instead selects the solution with the smallest deviation from the standard. Here, the "difference" can be defined as the weighted sum of the deviations of each metric (or the maximum deviation factor), prioritizing the candidate with the smallest overall deviation. This ensures that the system can output a relatively optimal feasible solution under any extreme conditions, avoiding system crashes when there is no solution. Simultaneously, this solution can serve as a manual reference in emergency situations, minimizing the degree of deviation.
[0244] For example:
[0245] Option 1: Turbidity 4.5 (exceeding 0.5), total phosphorus 0.4 (meets standard) → Exceeding standard multiple = 4.5 / 4.0 - 1 = 0.125;
[0246] Option 2: Turbidity 3.8 (meets standard), total phosphorus 0.6 (exceeds standard by 0.1) → Exceedance multiple = 0.6 / 0.5 - 1 = 0.2;
[0247] Option 3: Turbidity 5.0 (exceeding 1.0), total phosphorus 0.55 (exceeding 0.05) → maximum exceedance multiple = 5.0 / 4.0-1 = 0.25; select Option 1 with the smallest exceedance multiple.
[0248] S345, extract the dosage of multiple agents from the target input vector to obtain the target dosage combination.
[0249] Finally, the target input vector is the unique optimal hypothesis input vector determined through the above screening. It contains the current water quality, flocculation characteristics, and candidate dosage combinations. The dosage of chemicals (such as the percentage of PAC or PAM) is extracted from it, which is the recommended control instruction for the automatic dosing device. This completes the conversion from the hypothesis space to the actual control instruction, outputting a directly executable dosage value, thus achieving closed-loop control.
[0250] Finally, the target dosage combination determined at the current time point is sent to the dosing execution module, enabling the module to execute the target dosage combination. This completes the optimization and control for the current time point. In subsequent processes, the entire process is repeated in a rolling loop, achieving automated processing of water treatment dosing optimization based on multi-model collaboration and a dynamic hypothesis space.
[0251] This application presents a water treatment dosing optimization method based on multi-model collaboration and a dynamic hypothesis space. Addressing the challenges of traditional PID control in handling large time delays, multivariate coupling, and delayed responses to sudden changes in water quality, this invention introduces flocculent image features (such as particle size and fractal dimension) to enable the model to perceive microscopic morphological changes during the flocculation process, significantly improving response speed and control accuracy under complex operating conditions. To overcome the shortcomings of existing neural network predictive control, such as ignoring flocculation features, weak generalization ability of single models, and high computational cost of fixed grid search, this invention employs a multi-model collaborative prediction architecture, effectively improving the prediction accuracy and generalization of multi-objective effluent water quality. Simultaneously, it dynamically constructs a hypothesis space based on the fluctuation characteristics of the actual dosing sequence, adaptively adjusting the search range and step size, avoiding full-space enumeration, effectively reducing computational load, and achieving real-time optimization.
[0252] like Figure 5 As shown, this application also provides a water treatment dosing optimization system based on multi-model collaboration and dynamic hypothesis space, comprising:
[0253] The acquisition module is used to acquire water quality data and underwater image sequences within a target time period, and to acquire the actual dosage sequence of multiple time points before the current time point. The target time period includes the current time point and multiple time points before the current time point. The water quality data includes the values of various water quality parameters, and the actual dosage sequence includes the actual dosage of various agents at multiple time points. The water quality data and the actual dosage sequence are aligned through pool capacity lag compensation.
[0254] The feature extraction module is used to extract flocculation feature data from multiple frames of underwater images in the underwater image sequence, wherein the flocculation feature data includes the values of various flocculation parameters;
[0255] The hypothesis space simulation module is used to calculate the fluctuation characteristics of the actual dosage sequence, construct a dynamic hypothesis space based on the actual dosage and fluctuation characteristics of multiple agents at the previous time point, extract multiple dosage combinations from the dynamic hypothesis space, and construct multiple hypothesis input vectors based on multiple dosage combinations, water quality data and flocculation characteristic data.
[0256] The optimization module is used to predict the predicted water quality index for each hypothetical input vector based on multiple pre-built water quality prediction models, and to select the target input vector and the target delivery quantity combination of the target input vector based on the cost of multiple hypothetical input vectors and the predicted water quality index. Each water quality prediction model predicts one water quality index.
[0257] This application presents a water treatment dosing optimization system based on multi-model collaboration and a dynamic hypothesis space. Addressing the challenges of traditional PID control in handling large time delays, multivariate coupling, and delayed responses to sudden changes in water quality, this invention introduces flocculent image features (such as particle size and fractal dimension) to enable the model to perceive microscopic morphological changes during the flocculation process, significantly improving response speed and control accuracy under complex operating conditions. To overcome the shortcomings of existing neural network predictive control, such as ignoring flocculation features, weak generalization ability of single models, and high computational cost of fixed grid search, this invention employs a multi-model collaborative prediction architecture, effectively improving the prediction accuracy and generalization of multi-objective effluent water quality. Simultaneously, it dynamically constructs a hypothesis space based on the fluctuation characteristics of the actual dosing sequence, adaptively adjusting the search range and step size, avoiding full-space enumeration, effectively reducing computational load, and achieving real-time optimization.
[0258] This embodiment also provides an electronic terminal, including: a processor and a memory;
[0259] The memory is used to store computer programs, and the processor is used to execute the computer programs stored in the memory to cause the terminal to perform any of the methods in this embodiment.
[0260] As will be understood by those skilled in the art, the computer-readable storage medium described in this embodiment allows for the implementation of all or part of the steps in the above method embodiments by computer program-related hardware. The aforementioned computer program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0261] The electronic terminal provided in this embodiment includes a processor, a memory, a transceiver, and a communication interface. The memory and the communication interface are connected to the processor and the transceiver and complete communication between them. The memory is used to store computer programs, the communication interface is used to perform communication, and the processor and the transceiver are used to run the computer programs, so that the electronic terminal performs the steps of the above method.
[0262] In this embodiment, the memory may include random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage device.
[0263] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0264] In the above embodiments, although the present application has been described in conjunction with specific embodiments thereof, many substitutions, modifications, and variations of these embodiments will be apparent to those skilled in the art based on the foregoing description. The embodiments of the present application are intended to cover all such substitutions, modifications, and variations falling within the broad scope of the appended claims.
[0265] The above embodiments are merely illustrative of the principles and effects of this application and are not intended to limit this application. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of this application. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in this application should still be covered by the claims of this application.
Claims
1. A water treatment chemical dosing optimization method based on multi-model collaboration and dynamic hypothesis space, characterized in that, Including the following steps: The system acquires water quality data and underwater image sequences within a target time period, and obtains actual chemical dosing sequences for multiple time points prior to the current time point. The target time period includes the current time point and multiple time points prior to the current time point. The water quality data includes values of various water quality parameters of the influent, and the actual chemical dosing sequences include the actual dosage of various chemicals at multiple time points. The water quality data and the actual chemical dosing sequences are aligned using pool capacity lag compensation. Flocculation feature data is extracted from multiple frames of underwater images in the underwater image sequence, wherein the flocculation feature data includes values of various flocculation parameters; The fluctuation characteristics of the actual dosage sequence are calculated. A dynamic hypothesis space is constructed based on the actual dosage and fluctuation characteristics of multiple agents at the previous time point. Multiple dosage combinations are extracted from the dynamic hypothesis space. Multiple hypothesis input vectors are constructed based on multiple dosage combinations, water quality data, and flocculation characteristic data. The system predicts the water quality index for each hypothetical input vector based on multiple pre-built water quality prediction models. It also selects the target input vector and the target delivery quantity combination of the target input vector based on the cost of multiple hypothetical input vectors and the predicted water quality index. Each water quality prediction model predicts one water quality index.
2. The water treatment chemical dosing optimization method based on multi-model collaboration and dynamic hypothesis space according to claim 1, characterized in that, Extracting flocculation feature data from multiple frames of the underwater image sequence includes: Each frame of the underwater image in the underwater image sequence is preprocessed to obtain a preprocessed image, wherein the preprocessing includes grayscale conversion, Gaussian filtering, and contrast enhancement. The preprocessed image is binarized based on an adaptive threshold to obtain a binarized image; Perform a morphological closing operation on the binarized image to obtain a morphologically processed image; From the morphologically processed image, connected components with an area greater than or equal to a preset area threshold are selected to obtain multiple flocs in the image; Extract the area, perimeter, equivalent diameter, and centroid coordinates of each floc; and count the total number of flocs. The average diameter is calculated based on the equivalent diameter of multiple flocs; the average area is calculated based on the area of multiple flocs; the average perimeter is calculated based on the perimeter of multiple flocs; and the number of fine particles with an equivalent diameter less than a preset threshold is selected. The fractal dimension of the morphologically processed image is extracted based on box counting; and the gray-level variance, average gradient, kurtosis, and entropy of the preprocessed image are calculated. Flocculation feature data are constructed based on the total number of flocs, average diameter, average perimeter, number of fine particles, fractal dimension, gray-level variance, average gradient, kurtosis, and entropy.
3. The water treatment chemical dosing optimization method based on multi-model collaboration and dynamic hypothesis space according to claim 1, characterized in that, Calculating the fluctuation characteristics of the actual dosage sequence includes: Calculate the coefficient of variation and mean absolute difference of the actual dosage of each agent at multiple time points in the actual dosage sequence; The coefficient of variation and mean absolute difference of the actual dosage of each drug are weighted to obtain a comprehensive volatility score for each drug. The volatility characteristics of the actual dosage sequence are obtained by weighting the comprehensive volatility scores of multiple agents, wherein the weights of multiple agents are based on the correlation evaluation of agent price and flocculation effect.
4. The water treatment chemical dosing optimization method based on multi-model collaboration and dynamic hypothesis space according to claim 1, characterized in that, A dynamic hypothesis space is constructed based on the actual dosage and fluctuation characteristics of various agents at the previous time point, and multiple dosage combinations are extracted from the dynamic hypothesis space, including: calculating the amplification coefficient based on the fluctuation characteristics. and step scaling factor Wherein, the expansion coefficient and the step scaling factor The mathematical expression is: In the formula, Indicates fluctuation characteristics, Indicates the maximum expansion coefficient. Indicates the maximum fluctuation score. Indicates the minimum fluctuation score. This represents the maximum reduction factor; based on the actual dosage of various agents at the previous time point and the expansion factor. Calculate the search half-width, determine the search boundary based on the search half-width and the actual dosage of various agents at the previous time point, and determine the search boundary based on the step size scaling factor. Determine the search step size, wherein the mathematical expressions for the search boundary and the search step size are: In the formula, Indicates the first The lower limit of the search for a certain drug. Indicates the first The actual amount of the pesticide applied at the previous time point. Indicates the first The search half-width of the drug. Indicates the first The upper limit of the search for a certain drug. Indicates the first The search step size for each drug Indicates the minimum allowable step size. The search is performed within the search boundary using the search step size to obtain a set of candidate values for multiple agents; and the Cartesian product of the set of candidate values for multiple agents is performed to obtain multiple dosage combinations.
5. The water treatment chemical dosing optimization method based on multi-model collaboration and dynamic hypothesis space according to claim 1, characterized in that, Based on the actual dosage of various agents at the previous time point and the aforementioned expansion coefficient Calculate the search half-width, including: When the dosage of the agent at a previous time point satisfy: At that time, calculate the search half-width. The mathematical expression for the search half-width is: In the formula, For drug type index, Indicates the base half-width factor; When the dosage of the agent at a previous time point satisfy: or At that time, calculate the search half-width. The mathematical expression for the search half-width is: In the formula, This indicates the absolute baseline half-width.
6. The water treatment chemical dosing optimization method based on multi-model collaboration and dynamic hypothesis space according to claim 1, characterized in that, Multiple hypothesis input vectors are constructed based on various dosage combinations, water quality data, and flocculation characteristic data, including: The water quality data and the flocculation characteristic data are preprocessed to obtain preprocessed water quality data and preprocessed flocculation characteristic data. The preprocessing includes outlier handling, filtering, resampling, hysteresis compensation, normalization, and time series reconstruction. Multiple dosage combinations are concatenated with the pretreated water quality data and the pretreated flocculation characteristic data to obtain the feature vector at the current time point; and a hypothesis input vector is constructed based on the feature vectors at multiple time points and the feature vector at the current time point.
7. The water treatment chemical dosing optimization method based on multi-model collaboration and dynamic hypothesis space according to claim 1, characterized in that, Based on the cost and predicted water quality indicators of multiple hypothetical input vectors, target input vectors and target dosage combinations of target input vectors are selected, including: The predicted water quality indicators corresponding to multiple hypothetical input vectors are compared with the preset minimum indicators. When multiple hypothetical input vectors predict water quality indicators that are less than or equal to the minimum indicator, the total cost of the reagents for the multiple hypothetical input vectors is calculated, and the hypothetical input vector with the lowest total cost is taken as the target input vector. When there is only one hypothetical input vector whose predicted water quality index is less than or equal to the minimum index, the hypothetical input vector that is less than or equal to the minimum index shall be used as the target input vector. When there is no hypothetical input vector whose predicted water quality index is less than or equal to the minimum index, calculate the difference between the predicted water quality index of multiple hypothetical input vectors and the minimum index, and take the hypothetical input vector with the smallest difference as the target input vector. The dosage of various agents is extracted from the target input vector to obtain the target dosage combination.
8. The water treatment chemical dosing optimization method based on multi-model collaboration and dynamic hypothesis space according to claim 1, characterized in that, The multiple water quality prediction models include a turbidity prediction model and a total phosphorus and chemical oxygen demand prediction model, which are trained from labeled training samples.
9. The water treatment chemical dosing optimization method based on multi-model collaboration and dynamic hypothesis space according to claim 1, characterized in that, Also includes: The target delivery quantity combination determined at the current time point is sent to the drug delivery execution module so that the drug delivery execution module can execute the target delivery quantity combination.
10. A water treatment dosing optimization system based on multi-model collaboration and dynamic hypothesis space, characterized in that, include: The acquisition module is used to acquire water quality data and underwater image sequences within a target time period, and to acquire the actual dosage sequence of multiple time points before the current time point. The target time period includes the current time point and multiple time points before the current time point. The water quality data includes the values of various water quality parameters, and the actual dosage sequence includes the actual dosage of various agents at multiple time points. The water quality data and the actual dosage sequence are aligned through pool capacity lag compensation. The feature extraction module is used to extract flocculation feature data from multiple frames of underwater images in the underwater image sequence, wherein the flocculation feature data includes the values of various flocculation parameters; The hypothesis space simulation module is used to calculate the fluctuation characteristics of the actual dosage sequence, construct a dynamic hypothesis space based on the actual dosage and fluctuation characteristics of multiple agents at the previous time point, extract multiple dosage combinations from the dynamic hypothesis space, and construct multiple hypothesis input vectors based on multiple dosage combinations, water quality data and flocculation characteristic data. The optimization module is used to predict the predicted water quality index for each hypothetical input vector based on multiple pre-built water quality prediction models, and to select the target input vector and the target delivery quantity combination of the target input vector based on the cost of multiple hypothetical input vectors and the predicted water quality index. Each water quality prediction model predicts one water quality index.