Sewage data processing method and device and electronic equipment

CN123012778APending Publication Date: 2026-10-30WUCHAN ZHONGDA (TONGXIANG) WATER TREATMENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611505284.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-24
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

该方式存在三方面不足:其一,采样粒度全局统一,平稳时段浪费资源,相位切换关键时段又因采样过疏丢失拐点;其二,相位划分依赖预设寄存器,无法根据实际水质曲线动态确认边界,进水波动或设备衰减时相位偏差难以及时感知;其三,控制参数设定后长期不变,缺乏基于当前工艺状态的在线优化机制,出水达标率与能耗药耗间难以动态平衡

Benefits of technology

[0014]上述设置中,通过构建水质特征、控制状态、相位位置三维相态耦合张量,将三者耦合为统一概率表示,为状态识别与偏离判定提供数学基础。基于张量控制状态维度概率分布求状态熵,据此动态调整二阶差分阈值与采样粒度,实现不确定时精细、确定时宽松的自适应采集策略,保证关键数据完整性并降低系统负载。经多特征点校验确认相位边界后,提取各相位水质统计、能耗、时长及相位偏差、释吸差分特征拼接为周期特征向量,实现运行周期多维度结构化表征。经指数衰减更新张量后以贝叶斯推断识别控制状态,状态熵回传形成采集、识别闭环,工艺偏离度为优化提供依据。最终以相位编码遗传算法每周期滚动求解最优配置,兼顾出水达标率与能耗药耗,适应进水波动与设备衰减等时变因素。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123012778A_ABST
    Figure CN123012778A_ABST
Patent Text Reader

Abstract

The application discloses sewage data processing method, device and electronic equipment, the sewage data processing method includes: constructing three-dimensional phase state coupling tensor, obtaining state entropy according to the phase state coupling tensor, and calculating the second-order difference of the water quality signal sliding window and comparing with the current threshold to obtain structured data; obtain the periodic characteristic vector based on the structured data; the phase state coupling tensor is updated according to the exponential decay of the periodic characteristic vector and the corresponding control state sequence, the joint probability density vector is obtained according to the updated tensor, the maximum likelihood control state is taken as the current state recognition result, the current state corresponding value in the joint probability density vector is compared with the preset reference value to obtain the process deviation degree; based on the current state recognition result and the process deviation degree, the fitness is corrected according to the process deviation degree penalty to obtain the optimal phase configuration, and sewage data processing is realized. Through the above setting, the recognition accuracy of sewage process state and the optimization accuracy of operating parameters can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing, and in particular to wastewater data processing methods, apparatus and electronic equipment. Background Technology

[0002] Current wastewater treatment data processing methods often employ controllers with fixed sampling cycles to collect water quality signals. After simple filtering, phase switching and equipment control are performed according to a preset time sequence. This approach has three main drawbacks: First, the sampling granularity is globally uniform, wasting resources during stable periods and missing inflection points during critical phase switching periods due to insufficient sampling. Second, phase division relies on preset registers, making it impossible to dynamically confirm boundaries based on actual water quality curves, and phase deviations are difficult to detect in a timely manner when influent fluctuations or equipment degradation occur. Third, control parameters remain unchanged after being set, lacking an online optimization mechanism based on the current process status, making it difficult to dynamically balance effluent compliance rate with energy and chemical consumption. Furthermore, existing methods treat water quality observation, equipment status, and process phase as independent variables, lacking a unified probabilistic coupling modeling method. This makes it impossible to quantify the uncertainty of status identification and to feed it back to the front-end acquisition, resulting in a disconnect between acquisition, identification, and optimization, failing to form a closed loop. Summary of the Invention

[0003] To address the shortcomings of existing technologies, the purpose of this application is to provide wastewater data processing methods, apparatus, and electronic equipment, which can improve the accuracy of wastewater process status identification and the accuracy of operating parameter optimization.

[0004] In a first aspect, embodiments of this application provide a wastewater data processing method, comprising the following steps: Construct a three-dimensional phase-state coupling tensor of water quality characteristics, control state, and phase position. Each element is the conditional probability density of the water quality characteristics in the quantization interval under the corresponding phase and control state. The state entropy is obtained by controlling the state dimension probability distribution based on the phase coupling tensor. If the state entropy exceeds the upper limit, the trigger threshold is shrunk; if it is below the lower limit, the trigger threshold is relaxed. The second-order difference of the water quality signal sliding window is calculated and compared with the current threshold. If the threshold is exceeded, the sampling interval is shrunk from the basic granularity to the fine granularity; otherwise, the original granularity is maintained to obtain structured data. Candidate switching points are extracted from the phase-time topological features of structured data. The phase boundaries are confirmed by multi-feature point verification and correction using redox potential, pH, and dissolved oxygen curves. Functional phases such as anaerobic phosphorus release and anoxic denitrification phosphorus uptake are divided. Water quality statistics, cumulative energy consumption, and time features of each phase are extracted to form a phase feature vector. The phase deviation vector is obtained by comparing the actual boundary with the preset time series. The phase difference features of anaerobic phosphorus release and anoxic denitrification phosphorus uptake are extracted to form a release and uptake phase feature vector. The periodic feature vector is then spliced ​​together to obtain the periodic feature vector. The phase coupling tensor is updated exponentially by using the periodic feature vector and the corresponding control state sequence. The likelihood vector of the current water quality feature vector under each control state is obtained from the updated tensor. The joint probability density vector is obtained by multiplying the prior probability. The control state with the highest likelihood is taken as the current state identification result. The Shannon entropy is obtained by normalizing the likelihood vector and the state entropy is returned to dynamic acquisition. The process deviation is obtained by comparing the current state corresponding value in the joint probability density vector with the preset benchmark value. Based on the current state identification results and process deviation, the duration of each phase and key process parameters for future multi-cycles are determined, and an initial solution benchmark is generated according to the phase deviation vector. Carbon and nitrogen phase encoding is used to jointly encode the phosphorus uptake phase duration of anoxic denitrification and the amount of carbon source added. The fitness is adjusted according to the process deviation penalty based on the fitness of the multi-objective weighted value of effluent compliance rate, aeration energy consumption and carbon source chemical consumption. After the feature vector of each cycle is generated, the optimal phase configuration is obtained by rolling solution using a phase encoding genetic algorithm to realize wastewater data processing.

[0005] Preferably, the specific steps for constructing a three-dimensional phase-state coupling tensor of water quality characteristics, control state, and phase position are as follows: The five analog signals of pH, dissolved oxygen, oxidation-reduction potential, liquid level and sludge concentration are divided into N quantization intervals according to their respective ranges. Each quantization interval corresponds to a discrete value of a water quality characteristic dimension. The on / off states of the influent pump, anaerobic tank mixer, sequencing batch tank mixer, nitrification liquor return pump, sludge return pump, aerator, and two dosing pumps are encoded as control state dimensions using binary combinations. The constraints of interlocking between the influent valve and the sludge return valve, between the pump and the valve, and between the mixer and the aeration valve are directly reflected in the set of valid control state codes. The anaerobic phosphorus release phase, anoxic denitrification phosphorus uptake phase, aerobic aeration phase, and sedimentation drainage phase in the dual half-cycle alternating operation structure are encoded as phase position dimensions in chronological order. The first half-cycle and the second half-cycle are switched by word exchange instructions and mapped to the same phase position index. A three-dimensional tensor is constructed with water quality characteristics as the first dimension, control state as the second dimension, and phase position as the third dimension. The initial value of each element of the tensor is set to 1 divided by the uniform distribution conditional probability density of the total number of quantization intervals under the corresponding control state. Five raw signals acquired by the analog input module of the programmable logic controller are first compared with their respective preset lower limits. Raw signals below the input lower limit are clamped to the input lower limit. Then, they are converted into engineering quantity values ​​according to the linear scaling formula, which is the output lower limit plus the difference between the output upper limit and the output lower limit multiplied by the original signal minus the input lower limit and divided by the input upper limit minus the input lower limit. The converted engineering quantity values ​​are compared with their respective preset output upper limits. Engineering quantity values ​​above the output upper limit are clamped to the output upper limit. Finally, the clamped engineering quantity values ​​are placed into the corresponding quantization intervals according to their numerical range, completing the discretization mapping of the water quality characteristic dimension.

[0006] Preferably, the specific steps for obtaining the state entropy based on the probability distribution of the control state dimension using the phase coupling tensor, and then shrinking the trigger threshold if the state entropy exceeds the upper limit and relaxing the trigger threshold if it falls below the lower limit, are as follows: Summing the elements of all water quality feature quantization intervals and phase positions under the same control state along the control state dimension of the phase coupling tensor yields the unnormalized marginal probability of each control state. Dividing each unnormalized marginal probability by the sum of the marginal probabilities of all control states yields the normalized marginal probability distribution. The state entropy is calculated using the Shannon entropy formula for the normalized marginal probability distribution. The state entropy is equal to the sum of the negative values ​​of the logarithms of each control state probability. The higher the state entropy, the greater the uncertainty in identifying the current control state. The upper and lower thresholds of the state entropy are preset. When the state entropy is higher than the upper threshold, the second-order difference trigger threshold is multiplied by a contraction coefficient less than 1. When the state entropy is lower than the lower threshold, the second-order difference trigger threshold is multiplied by a relaxation coefficient greater than 1. After the trigger threshold is contracted or relaxed, it is compared with the preset minimum threshold lower bound and maximum threshold upper bound. If it is lower than the lower bound, it is clamped to the lower bound; if it is higher than the upper bound, it is clamped to the upper bound. The clamped trigger threshold is used as the benchmark for the second-order difference comparison in the current cycle.

[0007] Preferably, the specific steps for calculating the second-order difference of the water quality signal sliding window and comparing it with the current threshold are as follows: If the threshold is exceeded, the sampling interval is reduced from the basic granularity to the fine granularity; otherwise, the original granularity is maintained. The fixed scan cycle of the main loop of the programmable logic controller is used as the basic granularity, and the interrupt cycle of the programmable logic controller's periodic interrupt is used as the fine granularity. For the scaled analog engineering quantity values ​​of each channel, take a sliding window of length W, and calculate the second difference value of three adjacent points in the window according to the second difference recursive formula. The second difference value is equal to the current sample value minus twice the previous sample value plus the previous two sample values. The absolute value of the second-order difference of each channel is compared with the current trigger threshold channel by channel. If the value of the channel exceeds the threshold, the fine acquisition flag is set and the sampling interval of the channel is switched from the basic scan cycle to the interrupt cycle. If the value of the channel does not exceed the threshold, the fine acquisition flag is cleared and the basic scan cycle is maintained. Each channel collects data at its own sampling interval, carrying a timestamp of the collection time. At the end of each basic scan cycle, the data is arranged in a structured data matrix with a fixed number of columns according to the timestamps. Missing times are filled with previous values. The structured data matrix serves as the input for phase-series topological feature extraction.

[0008] Preferably, the specific steps for extracting candidate switching points from the phase-time topological features of structured data, confirming phase boundaries through multi-feature point verification and correction using redox potential, pH, and dissolved oxygen curves, and dividing functional phases such as anaerobic phosphorus release and anoxic denitrification phosphorus uptake are as follows: The slope change rate of the three signals of redox potential, acidity and alkalinity and dissolved oxygen in the structured data matrix is ​​calculated respectively. The moment when the slope change rate exceeds the preset slope threshold is marked as a candidate phase switching point. The candidate switching points of the three signals are merged and deduplicated to obtain the candidate switching point sequence. On the redox potential curve, the moment when the first derivative changes from negative to positive is determined as the inflection point; on the pH curve, the moment when the first derivative changes from positive to negative or from negative to positive is determined as the extreme point; on the dissolved oxygen curve, the moment when the first derivative exceeds a preset jump threshold is determined as the jump point. These three types of feature points form a multi-feature point set. For each candidate point in the candidate switching point sequence, count the number of multiple feature points within an interval centered on the candidate point and with a width of a preset time window. When the number is greater than or equal to 2, the candidate point is confirmed as an effective phase boundary and its time is recorded. When the number is less than 2, the candidate point is discarded. The effective phase boundaries are arranged in chronological order. The time interval between two adjacent effective phase boundaries is marked as a functional phase. Based on the mean range of redox potential, pH, and dissolved oxygen within that time interval, it is determined to be an anaerobic phosphorus release phase, anoxic denitrification phosphorus uptake phase, aerobic aeration phase, or sedimentation and drainage phase, respectively.

[0009] Preferably, the specific steps for extracting phase feature vectors from water quality statistics, cumulative energy consumption, and time characteristics of each phase, comparing the actual boundary with the preset time series to obtain the phase deviation vector, extracting the phase difference features of anaerobic phosphorus release and anoxic denitrification phosphorus uptake to form the release and uptake phase feature vector, and concatenating them to obtain the periodic feature vector are as follows: For each functional phase, the mean, standard deviation, maximum and minimum values ​​of the five water quality signals within that phase are calculated as water quality statistical features. The cumulative energy consumption feature is obtained by multiplying the running time of the aerator, each mixer and each pump within that phase by their corresponding rated power. The duration feature is obtained by subtracting the start time from the end time of that phase. The three types of features are arranged in a fixed order to form the phase feature vector of that phase. Subtract the set time of the corresponding phase boundary in the preset timing sequence from the actual time of each effective phase boundary to obtain the time deviation of each phase boundary. Arrange the time deviations of all phase boundaries in phase order to form a phase deviation vector. Subtract the corresponding dimensions of the anaerobic phosphorus release phase feature vector from the anoxic denitrification phosphorus uptake phase feature vector to obtain the cross-phase difference features. Arrange the cross-phase difference features in dimensional order to form the release and uptake phase feature vector. The phase feature vectors of all functional phases are concatenated end to end in phase order, and then the phase deviation vector and the release phase feature vector are concatenated to obtain a fixed-dimensional periodic feature vector. The periodic feature vector serves as the common input for phase coupling tensor update and rolling optimization.

[0010] Preferably, the phase coupling tensor is updated exponentially by updating the periodic feature vector and the corresponding control state sequence. The likelihood vector of the current water quality feature vector under each control state is calculated based on the updated tensor. This likelihood vector is then multiplied by the prior probability to obtain the joint probability density vector. The control state with the highest likelihood is taken as the current state identification result. The likelihood vector is normalized, and the Shannon entropy is calculated to obtain the state entropy, which is then dynamically collected and fed back. The process deviation is obtained by comparing the current state value in the joint probability density vector with a preset benchmark value. The specific steps are as follows: The water quality statistical features in the periodic feature vector are mapped to the corresponding quantization interval. Combined with the control state sequence and phase position corresponding to the period, the target element in the phase coupling tensor is located and the target element is updated according to the exponential decay formula. From the updated phase coupling tensor, extract the conditional probability density values ​​corresponding to each control state according to the quantization interval to which the current water quality feature vector belongs and the current phase position, and arrange them in order of control state to form a likelihood vector. Multiply each element in the likelihood vector by the prior probability of the corresponding control state to obtain the joint probability density vector. The prior probability is obtained by statistical analysis of the historical marginal probability of the control state dimension of the phase coupling tensor. The control state corresponding to the maximum value in the likelihood vector is taken as the current state identification result. After normalizing the likelihood vector, the state entropy is calculated according to the Shannon entropy formula. The state entropy is fed back to the dynamic acquisition step to trigger the shrinking or widening of the threshold. The process deviation is obtained by dividing the value in the joint probability density vector corresponding to the current state identification result by the joint probability density benchmark value of the preset benchmark period template.

[0011] Preferably, based on the current state identification results and process deviation, the duration of each phase and key process parameters for future multi-cycles are determined, and an initial solution benchmark is generated according to the phase deviation vector; carbon and nitrogen phase encoding is used to jointly encode the phosphorus uptake phase duration of anoxic denitrification and the carbon source dosage, and the fitness is corrected according to the process deviation penalty based on the fitness of the multi-objective weighted value of effluent compliance rate, aeration energy consumption, and carbon source chemical consumption; after the feature vector of each cycle is generated, the optimal phase configuration is obtained by rolling solution using a phase encoding genetic algorithm. The specific steps for wastewater data processing are as follows: Using the current state identification result and process deviation as state input, the anaerobic phosphorus release phase duration, anoxic denitrification phosphorus uptake phase duration, aerobic aeration phase duration, sedimentation and drainage phase duration, as well as carbon source dosage and aeration intensity in each of the next K cycles are set as decision variables. The deviation values ​​of each phase boundary in the phase deviation vector are mapped proportionally to the initial offset of the decision variables to generate the initial solution benchmark of the genetic algorithm. Carbon-nitrogen phase coding is used to encode the phosphorus uptake phase duration of anoxic denitrification and the carbon source dosage into the same chromosome segment. The denitrification carbon requirement is obtained by multiplying the phosphorus uptake phase duration of anoxic denitrification by the denitrification rate constant. The effective carbon content corresponding to the carbon source dosage must be greater than or equal to the denitrification carbon requirement and less than or equal to its preset multiple, thereby constructing the feasible domain constraint. The multi-objective weighted fitness is obtained by multiplying the effluent compliance rate by the first weight, the aeration energy consumption by the second weight, and the carbon source and chemical consumption by the third weight. When the process deviation is less than the preset deviation threshold, the fitness is multiplied by the process deviation as a penalty correction. After the generation of the feature vector in each cycle, the phase-encoded genetic algorithm is started to generate an initial population with the initial solution benchmark as the center. After selection, crossover and mutation operations and iteration for a preset number of generations, the individual with the highest fitness is selected as the optimal phase configuration. The duration of each phase in the optimal phase configuration is written into the half-cycle time setting register of the programmable logic controller, and the carbon source dosage is written into the dosing pump time period setting register. After conversion between minutes and seconds and comparison with the real-time clock, the half-cycle switching, equipment interlocking and dosing pump execution are driven to realize wastewater data processing.

[0012] Secondly, embodiments of this application provide a wastewater data processing apparatus for a wastewater data processing method, comprising: a data acquisition section, a data processing section, and a result output section.

[0013] Thirdly, embodiments of this application provide an electronic device, which includes: The memory, the processor, and the computer program stored on the memory, wherein the processor is configured to run the computer program to perform a wastewater data processing method.

[0014] In the above setup, a three-dimensional phase-state coupling tensor is constructed, encompassing water quality characteristics, control state, and phase position. This coupling of the three elements into a unified probabilistic representation provides a mathematical foundation for state identification and deviation judgment. State entropy is calculated based on the probability distribution of the control state dimension of the tensor. This allows for dynamic adjustment of the second-order difference threshold and sampling granularity, achieving an adaptive acquisition strategy that is precise in uncertain situations and lenient in certain situations, ensuring the integrity of key data and reducing system load. After confirming the phase boundary through multi-feature point verification, water quality statistics, energy consumption, duration, phase deviation, and release / absorption differential features for each phase are extracted and concatenated into a periodic feature vector, achieving a multi-dimensional structured representation of the operating cycle. After updating the tensor through exponential decay, Bayesian inference is used to identify the control state. The state entropy is fed back to form a closed loop of acquisition and identification, and the process deviation provides a basis for optimization. Finally, a phase-encoded genetic algorithm is used to solve for the optimal configuration every cycle, taking into account both effluent compliance rate and energy and chemical consumption, adapting to time-varying factors such as influent fluctuations and equipment degradation. Attached Figure Description

[0015] Figure 1 This is a structural block diagram of an electronic device according to an embodiment of this application.

[0016] Figure 2 This is a flowchart of a wastewater data processing method according to an embodiment of this application.

[0017] Figure Labels 100. Electronic device; 11. Processor; 12. Memory. Detailed Implementation

[0018] To enable those skilled in the art to better understand the present application, the technical solutions in specific embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.

[0019] It should be noted that the terms "first," "second," and similar terms used in this application specification and claims do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Similarly, "one" or "a similar term" does not indicate a quantity limitation, but rather indicates the presence of at least one. "Multiple" indicates at least two. Terms such as "including" mean that the elements or objects appearing before "including" encompass the elements or objects listed after "including" and their equivalents, and do not exclude other elements or objects. Terms such as "connection" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect.

[0020] The singular form used in this application specification and appended claims, and the plural form, are also intended to include the plural form, unless the context clearly indicates otherwise.

[0021] The wastewater data processing method provided in this embodiment can be executed in electronic device 100 or similar device. Figure 1 This is a hardware structure block diagram of an electronic device 100 that implements an embodiment of this application. For example... Figure 1 As shown, the electronic device 100 may include one or more ( Figure 1 (Only one is shown) Memory 12 and processor 11. This electronic device 100 is a control terminal for wastewater data processing. It is used to calculate relevant parameters of wastewater data, thereby improving the accuracy of wastewater process status identification and the accuracy of operating parameter optimization.

[0022] The memory 12 stores program instructions, such as application software programs and modules, like the computer program for a wastewater data processing method in this embodiment. The processor 11 executes the program instructions stored in the memory 12. By running the computer program stored in the memory 12, it can perform various functional applications and data processing, namely, acquiring relevant wastewater data.

[0023] The processor 11 may include, but is not limited to, a microprocessor 11 (Microcontroller Unit, abbreviated as MCU) or a programmable gate array (Field Programmable Gate Array, abbreviated as FPGA).

[0024] Those skilled in the art will understand that Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the electronic device 100 described above. For example, the electronic device 100 may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown are illustrated.

[0025] In some embodiments, a portion of the wastewater data processing method described below is executed in the electronic device 100, while the remainder of the wastewater data processing method is executed in the background control terminal, in order to improve the accuracy of wastewater process status identification and the accuracy of operating parameter optimization.

[0026] This embodiment also provides a wastewater data processing method, such as... Figure 2 As shown, Figure 2 This is a flowchart of a wastewater data processing method according to an embodiment of this application. This method aims to improve the accuracy of wastewater process status identification and the optimization accuracy of operating parameters. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without inventive effort are within the scope of protection of this invention. The specific steps of this wastewater data processing method are as follows: S1 constructs a three-dimensional phase-state coupling tensor of water quality characteristics, control state, and phase position. Each element is the conditional probability density of the water quality characteristics in the quantization interval under the corresponding phase and control state. S2 obtains the state entropy based on the probability distribution of the control state dimension according to the phase coupling tensor. If the state entropy exceeds the upper limit, the trigger threshold is shrunk; if it is below the lower limit, the trigger threshold is relaxed. The second-order difference of the water quality signal sliding window is calculated and compared with the current threshold. If the threshold is exceeded, the sampling interval is shrunk from the basic granularity to the fine granularity; otherwise, the original granularity is maintained to obtain structured data. S3 extracts candidate switching points from the phase-time topological features of structured data. The phase boundaries are confirmed by multi-feature point verification and correction using redox potential, pH, and dissolved oxygen curves. Functional phases such as anaerobic phosphorus release and anoxic denitrification phosphorus uptake are divided. Water quality statistics, cumulative energy consumption, and time features of each phase are extracted to form a phase feature vector. The phase deviation vector is obtained by comparing the actual boundary with the preset time series. The phase difference features of anaerobic phosphorus release and anoxic denitrification phosphorus uptake are extracted to form a release and uptake phase feature vector. The periodic feature vector is then spliced ​​together to obtain the periodic feature vector. S4 updates the phase coupling tensor with the periodic feature vector and the corresponding control state sequence in an exponential decay manner. Based on the updated tensor, the likelihood vector of the current water quality feature vector under each control state is calculated. Multiplying the prior probability yields the joint probability density vector. The control state with the highest likelihood is taken as the current state identification result. The Shannon entropy is calculated by normalizing the likelihood vector to obtain the state entropy and the dynamic acquisition is back-transmitted. The process deviation is obtained by comparing the current state corresponding value in the joint probability density vector with the preset benchmark value. Based on the current state identification results and process deviation, S5 determines the duration of each phase and key process parameters for future multi-cycles, and generates an initial solution benchmark based on the phase deviation vector. Carbon and nitrogen phase encoding is used to jointly encode the phosphorus uptake phase duration of anoxic denitrification and the amount of carbon source added. The fitness is adjusted according to the process deviation penalty based on the fitness of the multi-objective weighted value of effluent compliance rate, aeration energy consumption and carbon source chemical consumption. After the feature vector of each cycle is generated, the optimal phase configuration is obtained by rolling solution using a phase encoding genetic algorithm, thus realizing wastewater data processing.

[0027] In the above steps, the phase coupling tensor is a three-dimensional probabilistic data structure. Its first dimension is the water quality characteristic dimension, encompassing key water quality parameters monitored online during wastewater treatment and discretized into several quantization intervals. The second dimension is the control state dimension, corresponding to the on / off states of various actuators in the reactor. The third dimension is the phase position dimension, corresponding to the temporal position of different functional stages in the wastewater treatment cycle. Each element in the tensor represents the conditional probability density of observing a corresponding water quality characteristic within a certain quantization interval when the control state is a certain combination in the corresponding phase. This tensor is used to couple the originally independent water quality observations, equipment states, and process phases into a unified probabilistic representation. It should be noted that this tensor is not static after construction but is incrementally updated based on new observation data after each subsequent cycle, thus continuously reflecting the slow drift of the process state.

[0028] Based on the tensor construction, the dynamic acquisition step begins. This step first obtains the state entropy based on the probability distribution of the phase coupling tensor along the control state dimension. The state entropy reflects the degree of uncertainty in identifying the current control state. The higher the entropy, the more uniform the probability distribution of each control state, and the more difficult it is for the system to determine the current control state. Based on the comparison between the state entropy and preset upper and lower thresholds, the trigger threshold of the second-order difference is dynamically adjusted. When the state entropy is higher than the upper limit, the trigger threshold is narrowed, making the system more sensitive to small changes in the water quality signal and avoiding missing phase switching information when the state is uncertain. When the state entropy is lower than the lower limit, the trigger threshold is widened to avoid unnecessary communication and computational overhead caused by frequent triggering of fine acquisition due to signal noise when the state is relatively certain.

[0029] Subsequently, the second-order difference of the water quality signal within the sliding window is calculated. This second-order difference can capture abrupt changes in signal curvature, which often correspond to water quality inflection points at the moment of process phase switching. Compared to the first-order difference, it has stronger anti-interference capability against slow drift. The second-order difference is compared with the current trigger threshold. If the threshold is exceeded, the sampling interval is reduced from the basic granularity to a finer granularity to collect key data near the phase switching at a higher density; if the threshold is not exceeded, the basic granularity is maintained, ensuring data integrity while reducing system load. The final output is time-aligned structured data, which serves as input for subsequent phase feature extraction. This forms a positive synergy with tensor construction. The state entropy provided by the tensor determines the sensitivity of the acquisition strategy, while the differentially acquired data provides higher-quality observation samples for subsequent tensor updates and state identification.

[0030] After acquiring structured data, phase-time topological feature extraction and periodic feature vector construction are performed. First, phase-time topological features are extracted from the structured data to obtain a sequence of candidate phase switching points, aiming to initially locate the possible time points of process phase switching from multi-dimensional water quality time-series data. Since candidate switching points based on a single signal may produce false alarms due to sensor noise or local disturbances, multiple feature points from three curves—oxidation-reduction potential, pH, and dissolved oxygen—are introduced to verify and correct the candidate switching points. These three curves exhibit characteristic inflection points, extreme values, or jumps at different phase switching points in wastewater treatment. Multi-signal cross-validation can eliminate false switching points, confirm true phase boundaries, and improve the reliability of phase division. After confirming the phase boundaries, a complete operating cycle is divided into an anaerobic phosphorus release phase, an anoxic denitrification phosphorus uptake phase, and other functional phases. Among these, anaerobic phosphorus release and anoxic denitrification phosphorus uptake are two crucial stages in the biological phosphorus removal process that are interconnected and mechanistically related.

[0031] Based on this, water quality statistical characteristics, cumulative energy consumption characteristics, and duration are extracted for each phase to form a phase feature vector, characterizing the operational status of each phase from three dimensions: water quality, energy consumption, and time. Simultaneously, the actual phase boundaries are compared with the preset time sequence to obtain a phase deviation vector, reflecting the degree of deviation between the actual operating rhythm and the set process rhythm. Furthermore, cross-phase difference features between the anaerobic phosphorus release phase and the anoxic denitrification phosphorus uptake phase are extracted to form a release-uptake phase feature vector, which helps capture the characteristic differences between the two key stages of phosphorus release and uptake in biological phosphorus removal, thereby indirectly reflecting the metabolic activity of polyphosphate-accumulating bacteria. Finally, the phase feature vectors, phase deviation vector, and release-uptake phase feature vector are concatenated to form a periodic feature vector. In this application, the periodic feature vector is a multi-dimensional digital representation of a complete operating cycle, including not only the operational status within each phase but also the temporal deviations between phases and the differences between key functional phases.

[0032] After obtaining the periodic feature vector, the phase-state coupling tensor is updated and its state is identified. The corresponding elements of the phase-state coupling tensor are updated with the periodic feature vector and its corresponding control state sequence in an exponential decay manner. This exponential decay mechanism ensures that recent observation data has a greater impact on the tensor than long-term data, allowing the tensor to track the slow drift of process characteristics while avoiding excessive influence from individual anomalous observations. After the update, the likelihood vector of the current observed water quality feature vector under each control state is calculated based on the new tensor. The likelihood vector gives the conditional probability distribution of each control state under the current water quality observation. The likelihood vector is multiplied by the prior probability of each control state to obtain the joint probability density vector, a process that can be achieved through Bayesian inference. Observational evidence is fused with historical prior knowledge to obtain a more reliable state estimate. The control state corresponding to the maximum value in the likelihood vector is taken as the current state identification result, realizing online determination of the process state. Simultaneously, the Shannon entropy is calculated after normalizing the likelihood vector to obtain the state entropy, which is then fed back to the dynamic acquisition step. This forms a complete closed loop encompassing tensor probability distribution, state entropy, trigger threshold adjustment, acquisition granularity switching, structured data, feature extraction, tensor update, and state entropy. State entropy acts as a feedback bridge connecting state identification and acquisition strategies. Furthermore, the value corresponding to the current state identification result in the joint probability density vector is compared with a preset benchmark value to obtain the process deviation, which reflects the degree of difference between the current cycle's process state and the historical best benchmark.

[0033] Finally, the rolling optimization step begins. Using the current state identification result and process deviation as state input, the duration of each phase and key process parameters for multiple future cycles are determined as decision variables. An initial solution benchmark is generated based on the phase deviation vector, allowing the optimization search to start from a position close to the current actual operating state, avoiding slow convergence caused by random initialization. Carbon and nitrogen phase encoding is used to jointly encode the anoxic denitrification phosphorus uptake phase duration and carbon source dosage. This encoding method binds the two strongly coupled variables of carbon source demand and anoxic duration in the same encoding segment, avoiding the generation of many infeasible solutions from independent encoding. Simultaneously, a feasible region constraint is constructed based on the denitrification stoichiometry, ensuring the physical rationality of the solution results in terms of carbon and nitrogen balance. A multi-objective weighted value of effluent compliance rate, aeration energy consumption, and carbon source chemical consumption is used as the fitness, balancing treatment effect and operating cost. A penalty correction is applied to the fitness based on the process deviation, ensuring that solutions with large deviations from the benchmark receive lower fitness, guiding the optimization towards process stability rather than simply pursuing the lowest cost. After each periodic feature vector is generated, a phase-encoded genetic algorithm is used to solve for the optimal phase configuration and write it back to the control terminal for execution.

[0034] The rolling optimization mechanism allows the system to recalculate the optimal configuration based on the latest process state at the end of each cycle, rather than setting it once and keeping it unchanged for a long time. This enables it to adapt to time-varying factors such as fluctuations in influent water quality and degradation of equipment performance. This step, together with the preceding tensor update and state recognition steps, forms a continuous iterative closed loop of recognition, optimization, execution, and re-recognition. The state recognition result determines the starting state of optimization, the process deviation determines the penalty intensity of optimization, and the phase deviation vector determines the initial search position of optimization.

[0035] As one implementation method, the specific steps for constructing a three-dimensional phase-state coupling tensor of water quality characteristics, control state, and phase position are as follows: The five analog signals of pH, dissolved oxygen, oxidation-reduction potential, liquid level and sludge concentration are divided into N quantization intervals according to their respective ranges. Each quantization interval corresponds to a discrete value of a water quality characteristic dimension. The on / off states of the influent pump, anaerobic tank mixer, sequencing batch tank mixer, nitrification liquor return pump, sludge return pump, aerator, and two dosing pumps are encoded as control state dimensions using binary combinations. The constraints of interlocking between the influent valve and the sludge return valve, between the pump and the valve, and between the mixer and the aeration valve are directly reflected in the set of valid control state codes. The anaerobic phosphorus release phase, anoxic denitrification phosphorus uptake phase, aerobic aeration phase, and sedimentation drainage phase in the dual half-cycle alternating operation structure are encoded as phase position dimensions in chronological order. The first half-cycle and the second half-cycle are switched by word exchange instructions and mapped to the same phase position index. A three-dimensional tensor is constructed with water quality characteristics as the first dimension, control state as the second dimension, and phase position as the third dimension. The initial value of each element of the tensor is set to 1 divided by the uniform distribution conditional probability density of the total number of quantization intervals under the corresponding control state. Five raw signals acquired by the analog input module of the programmable logic controller are first compared with their respective preset lower limits. Raw signals below the input lower limit are clamped to the input lower limit. Then, they are converted into engineering quantity values ​​according to the linear scaling formula, which is the output lower limit plus the difference between the output upper limit and the output lower limit multiplied by the original signal minus the input lower limit and divided by the input upper limit minus the input lower limit. The converted engineering quantity values ​​are compared with their respective preset output upper limits. Engineering quantity values ​​above the output upper limit are clamped to the output upper limit. Finally, the clamped engineering quantity values ​​are placed into the corresponding quantization intervals according to their numerical range, completing the discretization mapping of the water quality characteristic dimension.

[0036] In the above steps, during the operation of the denitrification and phosphorus removal bioreactor, the key water quality parameters that need to be monitored online include five analog signals: pH, dissolved oxygen, redox potential, liquid level, and sludge concentration. These five signals reflect the reactor's operating status from five perspectives: pH environment, aerobic level, redox state, reactor liquid level, and sludge concentration. To incorporate the continuous analog signals into a discrete probability tensor for unified modeling, each signal needs to be divided into N quantization intervals at equal intervals according to its own range. Each quantization interval corresponds to a discrete value of a water quality characteristic dimension. This equal-interval division ensures that the physical quantity range corresponding to each quantization interval is the same, avoiding probability distribution bias caused by uneven interval widths. In this application, the ranges of the five signals differ significantly. The ranges of pH and dissolved oxygen are relatively small, the range of redox potential is in the middle, and the range of liquid level is large. Therefore, dividing them according to their respective ranges can ensure that each signal has similar quantization resolution within its effective range. This is beneficial for providing a consistent discretization basis for subsequent multi-signal joint probabilistic modeling and also makes different water quality parameters have comparable probabilistic granularity in the tensor.

[0037] Secondly, the reactor's operating equipment may include an influent pump, an anaerobic tank mixer, a sequencing batch reactor mixer, a nitrification liquor return pump, a sludge return pump, an aerator, and two chemical dosing pumps. The combination of these devices' on / off states determines the reactor's current hydraulic flow regime and biochemical reaction conditions. The on / off states of each device are binary-coded and combined into a single value for the control state dimension, allowing all the devices to form a complete coding space. Strict interlocking constraints exist between the devices: an interlock between the influent valve and the sludge return valve to prevent hydraulic short circuits; interlocks between pumps and their corresponding valves to prevent pumps from running dry when valves are closed; and a timing interlock between the mixer and the aeration valve to ensure coordinated mixing and aeration. Interlocking constraints ensure that all binary combinations are physically realizable legal states. Therefore, interlocking constraints are directly reflected in the set of legal control state codes. This means that only device combinations satisfying all interlocking conditions are included in the valid value range of the control state dimension. This helps eliminate interference from infeasible states on probabilistic modeling, ensuring that each element corresponding to a control state in the tensor has practical physical meaning and avoiding wasting probabilistic mass on impossible states. Furthermore, it reduces the effective state space and improves the statistical reliability of conditional probability density estimation under finite observation samples. The encoding of the control state dimension directly corresponds to the device output registers in the reactor's programmable logic controller, allowing the control state index in the tensor to be directly mapped to actual device control.

[0038] Furthermore, the denitrification phosphorus removal bioreactor employs a dual-half-cycle alternating operation structure. This means the reactor is divided into two half-cycles that alternately execute different functional phase combinations to coordinate continuous influent and intermittent treatment. Each half-cycle sequentially includes an anaerobic phosphorus release phase, an anoxic denitrification phosphorus uptake phase, an aerobic aeration phase, and a sedimentation and effluent phase. These functional phases are encoded as discrete values ​​in the phase position dimension in chronological order. The two half-cycles are switched via word-swapping instructions, which interchange the contents of the control registers of the two half-cycles, thus enabling alternating operation of the two batches of equipment. Although the two half-cycles physically correspond to different batches of equipment, they execute the same sequence of functional phases in terms of process mechanism. Therefore, mapping the half-cycle switched by the word-swapping instructions to the same phase position index allows data of the same functional phase in the two half-cycles to share elements in the same phase position dimension within the tensor. Unifying the physically alternating dual-half-cycle structure into a single phase sequence at the probabilistic modeling level significantly increases the effective observation samples at each phase position, accelerates the convergence speed of the tensor conditional probability density, and ensures that the process states of the two half-cycles are compared and identified within the same probabilistic framework. The encoding of the phase position dimension is linked to the timing reference of the half-cycle timing register, and the switching time of the phase position index corresponds to the actual phase boundary time, providing a unified time reference for subsequent phase deviation calculation and comparison of preset timing sequences.

[0039] After constructing the three dimensions, a three-dimensional phase-state coupling tensor is built, with water quality characteristics as the first dimension, control state as the second dimension, and phase position as the third dimension. The initial values ​​of each element of the tensor are set to a uniformly distributed conditional probability density, i.e., the initial value of each element equals 1 divided by the total number of quantization intervals under the corresponding control state. This initialization method ensures that, in the absence of historical observation data, the tensor assigns the same prior probability to all water quality characteristic intervals, avoiding systematic deviations in early state identification due to initial bias, and ensuring that the identification results of each control state are not dominated by unreasonable initial probabilities in the early stages of system startup. During system operation, the five analog signals are acquired by the analog input module of the programmable logic controller and require a series of signal conditioning steps before being mapped to the quantization interval. First, the original signals are compared with their respective preset input lower limits. Original signals below the input lower limit are clamped to the input lower limit. This step handles abnormal situations such as sensor disconnection or signals below the effective range, preventing negative or out-of-range values ​​from entering subsequent calculations and causing distortion in the scaling results.

[0040] Then, the original signal is converted into engineering quantity values ​​using a linear scaling formula. This formula uses the lower and upper input limits as scaling references and the lower and upper output limits as target ranges. Linear interpolation converts the original integer values ​​of the analog module into engineering quantities with physical units. This conversion allows signals from different sensors to be compared and modeled under a unified physical dimension. The converted engineering quantity values ​​are then compared with their respective preset output limits. Engineering quantity values ​​exceeding the output limit are clamped to the output limit to prevent sensor over-range or electromagnetic interference spikes from causing the quantization interval to exceed the limit. Finally, the engineering quantity values ​​after lower limit clamping, linear scaling, and upper limit clamping are placed into the corresponding quantization interval according to their numerical range, completing the discretization mapping of the water quality characteristic dimensions. These settings ensure the linearity of the signal conversion and the accuracy of its physical meaning. Furthermore, the upper and lower limit clamping improves the system's robustness to sensor anomalies and electromagnetic interference. The final output discretized water quality characteristics provide a reliable and stable input for the statistical update of the conditional probability density in the tensor.

[0041] As one implementation method, the specific steps for obtaining the state entropy based on the probability distribution of the control state dimension using the phase coupling tensor, and for narrowing the trigger threshold when the state entropy exceeds the upper limit and widening the trigger threshold when it falls below the lower limit, are as follows: Summing the elements of all water quality feature quantization intervals and phase positions under the same control state along the control state dimension of the phase coupling tensor yields the unnormalized marginal probability of each control state. Dividing each unnormalized marginal probability by the sum of the marginal probabilities of all control states yields the normalized marginal probability distribution. The state entropy is calculated using the Shannon entropy formula for the normalized marginal probability distribution. The state entropy is equal to the sum of the negative values ​​of the logarithms of each control state probability. The higher the state entropy, the greater the uncertainty in identifying the current control state. The upper and lower thresholds of the state entropy are preset. When the state entropy is higher than the upper threshold, the second-order difference trigger threshold is multiplied by a contraction coefficient less than 1. When the state entropy is lower than the lower threshold, the second-order difference trigger threshold is multiplied by a relaxation coefficient greater than 1. After the trigger threshold is contracted or relaxed, it is compared with the preset minimum threshold lower bound and maximum threshold upper bound. If it is lower than the lower bound, it is clamped to the lower bound; if it is higher than the upper bound, it is clamped to the upper bound. The clamped trigger threshold is used as the benchmark for the second-order difference comparison in the current cycle.

[0042] In the above setup, the phase coupling tensor is a three-dimensional probability structure with water quality feature dimension as the first dimension, control state dimension as the second dimension, and phase position dimension as the third dimension. Each element represents the conditional probability density of the observed water quality feature quantization interval under the corresponding phase and control state. To assess the uncertainty of the current control state identification, a one-dimensional probability distribution relating only to the control state needs to be extracted from the three-dimensional tensor. Specifically, along the control state dimension of the phase coupling tensor, the elements of all water quality feature quantization intervals and all phase positions under the same control state are summed, that is, all elements with the same control state index in the tensor are accumulated to obtain the unnormalized marginal probability of the control state. In this way, the probability quality of a specific control state under all water quality conditions and all phases can be summarized to obtain a measure of the overall frequency of occurrence of the control state. After performing the above summation on all control states, a set of unnormalized marginal probability values ​​is obtained. Since the cumulative value of the tensor elements may not strictly satisfy probability normalization during incremental updates, each unnormalized marginal probability needs to be divided by the sum of the marginal probabilities of all control states to obtain a normalized marginal probability distribution. In the normalized marginal probability distribution, the sum of all elements is 1. Each element represents the probability that the system is in the corresponding control state within the process history reflected by the current tensor. Therefore, reducing the three-dimensional coupled probability structure to a one-dimensional control state probability distribution provides a standardized input for subsequent entropy calculation. At the same time, the normalization process ensures the comparability of probability distributions at different update stages, avoiding meaningless drift in entropy values ​​due to changes in the overall magnitude of the tensor.

[0043] Then, the state entropy is calculated using the Shannon entropy formula for the normalized marginal probability distribution. The specific calculation process is as follows: Suppose there are M legal control states in the control state dimension. The probability of the i-th control state in the normalized marginal probability distribution is p_i, where i ranges from 1 to M, and the sum of all p_i equals 1. The state entropy H is equal to the sum of the negative values ​​of the logarithm of p_i (base 2) for all control states, i.e., H = -Σ(p_i × log2(p_i)). In the process of calculating each item, if the probability p_i of a certain control state is 0, it is agreed that 0 multiplied by log2(0) equals 0 to avoid undefined cases in logarithmic operations. The value range of the state entropy is from 0 to log2(M): when all probability masses are concentrated in a certain control state, that is, when a certain p_i equals 1 and the rest are 0, the state entropy H equals 0, indicating that the system's judgment of the current control state is completely deterministic.

[0044] When the probabilities of all control states are uniformly distributed, i.e., each p_i equals 1 / M, the state entropy H reaches its maximum value log2(M), indicating that the system cannot distinguish the current control state at all. Therefore, the higher the state entropy, the greater the uncertainty in identifying the current control state, and the more uniform the probability distribution of each control state. Conversely, the lower the state entropy, the significantly higher the probability of a certain control state compared to the others, and the more certain the system's judgment of the current control state. The above formula quantifies the concentration of the multidimensional probability distribution using a scalar value, allowing complex control state uncertainties to be concisely represented and used for subsequent threshold decisions. Furthermore, the logarithmic property of Shannon entropy makes it highly sensitive to changes in the probability distribution from a small probability concentration to a uniform distribution, enabling it to promptly capture the upward trend of control state uncertainty.

[0045] Furthermore, preset upper and lower threshold values ​​for state entropy correspond to the high and low limits of control state uncertainty, respectively. Their values ​​are determined based on the process requirements for state identification reliability and sensor noise levels. An unadjusted interval is formed between the upper and lower thresholds to avoid frequent threshold changes triggered by small fluctuations in state entropy near critical values. When the calculated state entropy exceeds the upper threshold, it indicates significant uncertainty in the current control state, making it difficult for the system to reliably determine the current control state. In this case, it is necessary to increase the detection sensitivity of water quality signal changes to capture phase switching characteristic signals earlier, thereby providing more observational information for state identification.

[0046] Specifically, the second-order differential trigger threshold is multiplied by a contraction coefficient less than 1. The contraction coefficient ranges from 0 to 1; the smaller the coefficient, the more drastic the threshold contraction and the higher the detection sensitivity. The contracted threshold is equal to the original threshold multiplied by the contraction coefficient. When the state entropy is below the lower threshold, it indicates that the uncertainty of the current control state is relatively small, and the system can reliably determine the control state. At this time, there is no need to be overly sensitive to small fluctuations in the water quality signal. Appropriately relaxing the trigger threshold can reduce false triggering caused by noise. Furthermore, the second-order differential trigger threshold is multiplied by a relaxation coefficient greater than 1. The relaxation coefficient is greater than 1; the larger the coefficient, the more obvious the threshold relaxation and the lower the detection sensitivity. The relaxed threshold is equal to the original threshold multiplied by the relaxation coefficient. When the state entropy is between the upper and lower thresholds, the trigger threshold remains unchanged. By feeding back the uncertainty of the control state to the sensitivity of signal detection, an adaptive strategy of fine detection under uncertainty and relaxed detection under certainty is formed. This reduces unnecessary fine acquisition overhead while ensuring the reliability of phase switching detection, and realizes on-demand allocation of detection resources.

[0047] Finally, after the trigger threshold is contracted or relaxed, it needs to be compared with the preset lower limit of the minimum threshold and the upper limit of the maximum threshold: if it is lower than the lower limit, the trigger threshold is clamped to the lower limit; if it is higher than the upper limit, the trigger threshold is clamped to the upper limit; if it is between the upper and lower limits, the adjusted value remains unchanged. The purpose of this clamping operation is to prevent the trigger threshold from being excessively contracted or relaxed under extreme state entropy conditions. Excessive contraction will cause the trigger threshold to approach zero, making it possible for any tiny noise to trigger fine acquisition, resulting in the exhaustion of system communication and computing resources; excessive relaxation will cause the trigger threshold to be too large, making it impossible to detect the real phase switching signal, resulting in missed phase boundary detection.

[0048] As one implementation method, the second-order difference of the water quality signal sliding window is calculated and compared with the current threshold. If the threshold is exceeded, the sampling interval is reduced from the basic granularity to the fine granularity; otherwise, the original granularity is maintained. The specific steps to obtain structured data are as follows: The fixed scan cycle of the main loop of the programmable logic controller is used as the basic granularity, and the interrupt cycle of the programmable logic controller's periodic interrupt is used as the fine granularity. For the scaled analog engineering quantity values ​​of each channel, take a sliding window of length W, and calculate the second difference value of three adjacent points in the window according to the second difference recursive formula. The second difference value is equal to the current sample value minus twice the previous sample value plus the previous two sample values. The absolute value of the second-order difference of each channel is compared with the current trigger threshold channel by channel. If the value of the channel exceeds the threshold, the fine acquisition flag is set and the sampling interval of the channel is switched from the basic scan cycle to the interrupt cycle. If the value of the channel does not exceed the threshold, the fine acquisition flag is cleared and the basic scan cycle is maintained. Each channel collects data at its own sampling interval, carrying a timestamp of the collection time. At the end of each basic scan cycle, the data is arranged in a structured data matrix with a fixed number of columns according to the timestamps. Missing times are filled with previous values. The structured data matrix serves as the input for phase-series topological feature extraction.

[0049] In the above steps, the fixed scan cycle of the programmable logic controller (PLC) main loop is used as the basic granularity. The main loop is the continuously executed program scan cycle of the PLC, in which input sampling, program execution, and output refresh are completed sequentially within each scan cycle. Therefore, the basic granularity corresponds to the system's default regular data acquisition rhythm, which is stable and predictable, suitable for periods when water quality signals change steadily. The interrupt cycle of the PLC's periodic interrupt is used as the fine granularity. Periodic interrupts are interrupt service routines triggered by the PLC's timer interrupt mechanism. Their interrupt cycles can be set independently of the main loop scan cycle, and are typically shorter than the main loop scan cycle. Therefore, the fine granularity corresponds to a high-frequency data acquisition rhythm, suitable for periods requiring intensive observation of rapid changes in water quality signals. The setting of both basic and fine granularity needs to consider the PLC's communication load and computing power. Too short a fine granularity will lead to excessively frequent bus communication, affecting the main program execution; too long a basic granularity will result in the loss of critical data points near phase switching. The coexistence of these two granularities allows the system to operate at a lower basic granularity most of the time to save resources, only switching to fine granularity locally when a signal mutation is detected to ensure the integrity of critical data.

[0050] Then, for the scaled analog engineering quantities of each channel, a sliding window of length W is taken, and the window slides on the time axis point by point, each time sliding one sampling interval. At each window position, the second-order difference value of three adjacent points within the window is calculated according to the second-order difference recursive formula. The specific calculation process is as follows: Let the current sampling time be t, the current sampling value be x(t), the sampling value of the previous sampling time t-Δt be x(t-Δt), and the sampling value of the two previous sampling times t-2Δt be x(t-2Δt), where Δt is the sampling interval of the current channel; first calculate the first-order forward difference Δx1=x(t)-x(t-Δt), then calculate the first-order forward difference of the previous time Δx0=x(t-Δt)-x(t-2Δt), and finally the second-order difference value is equal to the current first-order difference minus the first-order difference of the previous time, that is, Δ²x=Δx1-Δx0=x(t)-2×x(t-Δt)+x(t-2Δt).

[0051] The above formula performs a second-order numerical differentiation on the discrete sampled signal, aiming to obtain an approximate measure of the signal curvature. When the signal changes linearly and smoothly, the first-order difference is constant, and the second-order difference approaches zero. When the signal experiences an inflection point or a sudden change in slope, the first-order difference changes, and the second-order difference exhibits a significant non-zero peak. The sliding window length W provides a local time range for smoothing noise and confirming the persistence of abrupt changes. If W is too small, it is easily affected by single-point noise, resulting in false second-order difference peaks. If W is too large, it delays the detection of abrupt changes and reduces the temporal resolution. Compared to the first-order difference, the first-order difference is more sensitive to slow signal drift and baseline tilt, easily generating sustained large values ​​during the overall rise or fall of the signal. The second-order difference, however, is only sensitive to changes in slope, accurately locating the moment of a slope change against the backdrop of monotonic signal changes. This characteristic highly matches the inflection point feature of the water quality curve during phase switching in wastewater treatment.

[0052] Furthermore, the absolute value of the second-order difference of each channel is compared with the current trigger threshold channel by channel. For each channel, when the absolute value of the second-order difference exceeds the current trigger threshold, it indicates that the water quality signal of that channel has experienced a significant curvature change at the current moment, possibly corresponding to a phase switch. At this time, the fine acquisition flag of that channel is set, and the sampling interval of that channel is switched from the basic scan period to the interrupt period, that is, the data of that channel is acquired at a higher frequency. When the absolute value of the second-order difference does not exceed the current trigger threshold, it indicates that the water quality signal of that channel is in a stable change phase. At this time, the fine acquisition flag of that channel is cleared, and the basic scan period is maintained. The granularity switching of each channel is performed independently, that is, different channels can be in the basic granularity or fine granularity according to the change of their own signals. This mechanism of independent switching channel by channel avoids all channels from entering fine acquisition at the same time due to a signal change in one channel, thereby controlling the overall communication and computing overhead. Once the abrupt change period triggering the second-order difference exceeding the threshold has passed, the absolute value of the second-order difference of the channel falls back below the threshold, the fine acquisition flag is cleared, and the sampling interval automatically recovers to the basic granularity, thus achieving automatic recovery of granularity switching.

[0053] Finally, the data collected by each channel at its respective sampling interval carries a timestamp of the acquisition time. The timestamp is provided by the programmable logic controller's internal clock or run counter, marking the precise acquisition time of each sample value. Since different channels may have different sampling granularities, their sampling times are not perfectly aligned. Therefore, at the end of each basic scan cycle, the data collected by each channel needs to be arranged into a structured data matrix with a fixed number of columns, aligned by timestamps. Each row of the matrix corresponds to a unified time reference point, and each column corresponds to a water quality channel. For data points additionally collected between two basic cycles by fine-grained channels, their timestamps are retained and inserted into the corresponding positions in the matrix. If any channel lacks sampled data at a certain time reference point, previous values ​​are used to fill the missing positions, i.e., the previously acquired sampled value from that channel is used to fill the missing positions, ensuring that the number of columns in the structured data matrix is ​​fixed and there are no gaps. By assuming that the water quality signal maintains the value of the previous moment during the short missing period, the error introduced by this assumption is small when the sampling interval is short, and it also avoids calculation anomalies in subsequent phase feature extraction algorithms due to data gaps. The final output structured data matrix serves as the input for phase-time topology feature extraction. Its fixed column structure and unified time reference provide a standardized data format for subsequent multi-signal joint analysis.

[0054] As one implementation method, candidate switching points are extracted from the phase-time topological features of structured data. The phase boundaries are then confirmed through multi-feature point verification and correction using redox potential, pH, and dissolved oxygen curves. The specific steps for dividing functional phases such as anaerobic phosphorus release and anoxic denitrification phosphorus uptake are as follows: The slope change rate of the three signals of redox potential, acidity and alkalinity and dissolved oxygen in the structured data matrix is ​​calculated respectively. The moment when the slope change rate exceeds the preset slope threshold is marked as a candidate phase switching point. The candidate switching points of the three signals are merged and deduplicated to obtain the candidate switching point sequence. On the redox potential curve, the moment when the first derivative changes from negative to positive is determined as the inflection point; on the pH curve, the moment when the first derivative changes from positive to negative or from negative to positive is determined as the extreme point; on the dissolved oxygen curve, the moment when the first derivative exceeds a preset jump threshold is determined as the jump point. These three types of feature points form a multi-feature point set. For each candidate point in the candidate switching point sequence, count the number of multiple feature points within an interval centered on the candidate point and with a width of a preset time window. When the number is greater than or equal to 2, the candidate point is confirmed as an effective phase boundary and its time is recorded. When the number is less than 2, the candidate point is discarded. The effective phase boundaries are arranged in chronological order. The time interval between two adjacent effective phase boundaries is marked as a functional phase. Based on the mean range of redox potential, pH, and dissolved oxygen within that time interval, it is determined to be an anaerobic phosphorus release phase, anoxic denitrification phosphorus uptake phase, aerobic aeration phase, or sedimentation and drainage phase, respectively.

[0055] In the above setup, the slope change rate is first calculated for the three signals of redox potential, pH, and dissolved oxygen in the structured data matrix. The specific calculation process is as follows: For each signal, the sampled value x(t) at the current time t and the sampled value x(t-Δt) at the previous time t-Δt are taken. First, the first-order slope k(t) = (x(t) - x(t-Δt)) / Δt is calculated at the current time, where Δt is the sampling interval of the channel. Then, the first-order slope k(t-Δt) = (x(t-Δt) - x(t-2Δt)) / Δt is calculated at the previous time. The slope change rate is the change in slope, which is equal to the current slope minus the previous slope, i.e., Δk = k(t) - k(t-Δt). This value reflects the magnitude of the change in the signal slope over time, which is equivalent to the second derivative approximation of the signal.

[0056] The above formula compares the absolute value of the slope change rate of each signal with a preset slope threshold. When the slope change rate exceeds the preset slope threshold, it indicates that a significant abrupt change in the slope of that signal has occurred at the current moment, and this moment is marked as a candidate phase switching point for that signal. The value of the preset slope threshold is determined based on the slope fluctuation range of each signal within its normal phase. If the threshold is too low, noise fluctuations in the steady phase will be mistakenly marked as candidate points; if the threshold is too high, the actual abrupt change in the phase switching slope will be missed. After the slope change rate calculation and candidate point marking are performed independently for each of the three signals, the candidate switching points marked by each of the three signals are merged. Candidate points that overlap in time or are less than a preset merging interval are deduplicated. That is, if multiple signals are marked simultaneously near the same moment, only one candidate point is retained. After deduplication, the candidate switching points are arranged in chronological order to obtain a sequence of candidate switching points. By utilizing the sensitivity of the slope change rate to signal trend abrupt changes, all possible phase switching time positions can be quickly located from the three signals. Merging and deduplication avoids the same physical event being counted repeatedly by multiple signals.

[0057] Then, on the redox potential curve, the moment when the first derivative changes from negative to positive is determined as the inflection point, that is, the turning point where the downward trend of redox potential changes to the upward trend. This type of inflection point usually corresponds to the phase switching moment when the anaerobic stage ends and the oxidation environment begins to be established. On the pH curve, the moment when the first derivative changes from positive to negative or from negative to positive is determined as the extreme point, that is, the moment when the pH curve reaches a local maximum or local minimum. This type of extreme point usually corresponds to the phase switching moment when the phosphorus release or phosphorus uptake reaction rate changes. On the dissolved oxygen curve, the moment when the first derivative exceeds the preset jump threshold is determined as the jump point, that is, the moment when the dissolved oxygen concentration rises rapidly. This type of jump point usually corresponds to the switching moment when aeration starts and the aerobic phase begins. The determination of the three types of feature points is based on the sign change or amplitude abrupt change of the first derivative, which complements the slope change rate (second derivative) used for candidate switching points: the second derivative is sensitive to any abrupt change in the slope, including spurious abrupt changes caused by noise; the sign change and amplitude jump of the first derivative have a more explicit physical meaning, corresponding to the actual transition of biochemical reaction states. All inflection points, extreme points, and jump points determined from the three signals are summarized to form a multi-feature point set, and the time and type of each feature point in the set are recorded.

[0058] Based on the above steps, for each candidate point in the candidate switching point sequence, a time interval is defined with the time of the candidate point as the center and half the width of the preset time window as the radius. The number of feature points in the multi-feature point set within this time interval is counted. When the number of feature points counted is greater than or equal to 2, it indicates that at least two independent feature signals near the candidate point have simultaneously shown physically significant inflections. The multi-signal cross-validation passes, confirming the candidate point as a valid phase boundary and recording its time. When the number of feature points is less than 2, it indicates that the candidate point is triggered only by a single signal's slope abrupt change and lacks corroboration from other signals. It is likely a false switch caused by noise or local disturbances, and the candidate point is discarded. The width of the preset time window needs to be determined based on the time difference of the feature inflections of the three signals in the same phase switching event. If the window is too narrow, different signal features of the same event will be assigned to different windows due to time differences, reducing the verification pass rate. If the window is too wide, adjacent different phase switching events will be mixed into the same window, resulting in false confirmations. By using the above settings, false phase boundaries caused by noise from a single sensor or local disturbances can be reduced, improving the reliability of phase division while retaining the ability to detect true phase switching.

[0059] Finally, all effective phase boundaries are arranged chronologically, and the time interval between two adjacent effective phase boundaries is marked as a functional phase. Each functional phase has a clear start and end time. The type of functional phase is determined based on the average range of the three signals (oxidation-reduction potential, pH, and dissolved oxygen) within that time interval: when the oxidation-reduction potential is in the low range, the pH shows a slow upward trend, and the dissolved oxygen is near zero, it is determined to be an anaerobic phosphorus release phase. In this stage, polyphosphate-accumulating bacteria release phosphorus and absorb volatile fatty acids under anaerobic conditions. When the oxidation-reduction potential is in the low to medium range, the pH shows a downward trend, and the dissolved oxygen is still near zero, it is determined to be an anoxic denitrification phosphorus uptake phase. In this stage, denitrifying bacteria use nitrate nitrogen as an electron acceptor, and polyphosphate-accumulating bacteria absorb phosphorus under anoxic conditions. When the dissolved oxygen is in the high range and the oxidation-reduction potential is in the high range, it is determined to be an aerobic aeration phase. In this stage, nitrification and aerobic phosphorus uptake occur. When all signals tend to be stable and there is no aeration, it is determined to be a sedimentation and drainage phase. It should be noted that the threshold for determining the above mean range is determined based on process design parameters and historical operating data.

[0060] As one implementation method, the specific steps for extracting water quality statistics, cumulative energy consumption, and time-related features for each phase to form a phase feature vector, comparing the actual boundary with the preset time series to obtain the phase deviation vector, extracting the phase difference features of anaerobic phosphorus release and anoxic denitrification phosphorus uptake to form a release phase feature vector, and concatenating them to obtain the periodic feature vector are as follows: For each functional phase, the mean, standard deviation, maximum and minimum values ​​of the five water quality signals within that phase are calculated as water quality statistical features. The cumulative energy consumption feature is obtained by multiplying the running time of the aerator, each mixer and each pump within that phase by their corresponding rated power. The duration feature is obtained by subtracting the start time from the end time of that phase. The three types of features are arranged in a fixed order to form the phase feature vector of that phase. Subtract the set time of the corresponding phase boundary in the preset timing sequence from the actual time of each effective phase boundary to obtain the time deviation of each phase boundary. Arrange the time deviations of all phase boundaries in phase order to form a phase deviation vector. Subtract the corresponding dimensions of the anaerobic phosphorus release phase feature vector from the anoxic denitrification phosphorus uptake phase feature vector to obtain the cross-phase difference features. Arrange the cross-phase difference features in dimensional order to form the release and uptake phase feature vector. The phase feature vectors of all functional phases are concatenated end to end in phase order, and then the phase deviation vector and the release phase feature vector are concatenated to obtain a fixed-dimensional periodic feature vector. The periodic feature vector serves as the common input for phase coupling tensor update and rolling optimization.

[0061] In the above steps, the mean, standard deviation, maximum, and minimum values ​​of the five water quality signals within each functional phase are calculated as water quality statistical characteristics. The mean reflects the overall level of the water quality parameters within that phase, the standard deviation reflects the degree of fluctuation, and the maximum and minimum values ​​reflect the extreme range of the water quality parameters within that phase. These four statistical measures comprehensively characterize the water quality state within the phase from three dimensions: central tendency, dispersion, and extreme values. The calculation interval for the water quality statistical characteristics is limited by the effective phase boundary, meaning that only the sampled data from the start to the end of that phase is statistically analyzed, thus ensuring that the water quality characteristics of each phase do not overlap and are independent. The cumulative energy consumption characteristic is calculated by multiplying the operating time of the aerators, mixers, and pumps within that phase by their corresponding rated power and then summing the results. The operating time of each device is obtained by multiplying the number of sampling points where the device is in the on state within that phase by the sampling interval. The rated power is the nameplate parameter or the measured power of the device. The cumulative energy consumption characteristic reflects the operating cost and equipment load of that phase from the perspective of energy consumption. The duration characteristic is the difference between the end time and the start time of the phase, reflecting the actual duration of the phase.

[0062] In this process, water quality statistical characteristics, cumulative energy consumption characteristics, and duration characteristics are arranged in a pre-agreed fixed order to form the phase feature vector for that phase. This fixed order ensures that feature vectors from different periods and phases are strictly aligned in dimensions, facilitating subsequent difference calculations and tensor indexing. Through these steps, multidimensional and heterogeneous operational data within a phase can be aggregated into a structured vector, preserving information from the three core dimensions of water quality, energy consumption, and time, while also achieving data dimensionality unification and compression.

[0063] Then, the actual time of each effective phase boundary is subtracted from the set time of the corresponding phase boundary in the preset timing sequence to obtain the time deviation of each phase boundary. A positive time deviation indicates that the actual phase switch is later than the set time, and a negative time deviation indicates that the actual phase switch is earlier than the set time. The absolute value of the deviation reflects the degree of deviation between the actual operating rhythm and the set process rhythm. The preset timing sequence is a sequence of phase switching times pre-set according to the process design requirements, serving as a benchmark reference for the phase operating rhythm. The time deviations of all phase boundaries are arranged in phase order to form a phase deviation vector, with each dimension of the vector corresponding to the deviation value of a phase boundary. This vector quantifies the timing deviation of all phase switching within the entire cycle, reflecting both the advance or lag of a single phase and the drift of the overall cycle rhythm through the cumulative effect of the deviation. This provides a basis for generating the initial solution benchmark in subsequent rolling optimization. Phases with larger deviations mean that the set duration of that phase needs to be adjusted first.

[0064] Based on the above steps, the corresponding dimensions of the anaerobic phosphorus release phase feature vector and the anoxic denitrification phosphorus uptake phase feature vector are subtracted one by one to obtain the cross-phase difference feature. That is, for each dimension in the phase feature vector, the value of that dimension in the anoxic denitrification phosphorus uptake phase is subtracted from the value of that dimension in the anaerobic phosphorus release phase to obtain the cross-phase difference value for that dimension. The cross-phase difference features of all dimensions are arranged in dimensional order to form the release and uptake phase feature vector. The reason for choosing the anaerobic phosphorus release phase and the anoxic denitrification phosphorus uptake phase for difference is that these two phases are key stages in the biological phosphorus removal process that are closely linked and have a related mechanism. Polyphosphate-accumulating organisms (PAOs) release phosphorus and store carbon sources in the anaerobic stage, and use nitrate nitrogen as an electron acceptor to excessively absorb phosphorus in the anoxic stage. The differences in water quality characteristics and energy consumption characteristics between the two phases directly reflect the metabolic activity and phosphorus removal efficiency of PAOs. The difference operation eliminates the baseline components shared by the two phases, highlighting the characteristic changes from phosphorus release to phosphorus uptake. These characteristic changes reflect the conversion efficiency of the biochemical reaction better than the absolute value of a single phase.

[0065] Finally, the phase feature vectors of all functional phases are concatenated end-to-end in phase order. First, all dimensions of the anaerobic phosphorus release phase feature vectors are arranged, followed by all dimensions of the anoxic denitrification phosphorus uptake phase feature vectors, and so on, until all feature vectors of all functional phases are concatenated. After all phase feature vectors, all dimensions of the phase deviation vectors are concatenated. Finally, all dimensions of the release and uptake phase feature vectors are concatenated, resulting in a fixed-dimensional periodic feature vector. The fixed concatenation order is crucial, ensuring that the periodic feature vectors generated in each cycle are completely consistent in dimensional meaning, allowing for direct comparison, statistics, and tensor indexing of feature vectors from different cycles. The periodic feature vectors serve as the common input for phase-state coupling tensor updates and rolling optimization.

[0066] One implementation involves updating the phase coupling tensor with the periodic feature vector and corresponding control state sequence using exponential decay. The likelihood vector of the current water quality feature vector under each control state is calculated from the updated tensor. This likelihood vector is multiplied by the prior probability to obtain the joint probability density vector. The control state with the highest likelihood is taken as the current state identification result. The likelihood vector is normalized, and the Shannon entropy is calculated to obtain the state entropy, which is then dynamically collected and fed back. The process deviation is obtained by comparing the current state value in the joint probability density vector with a preset benchmark value. The specific steps are as follows: The water quality statistical features in the periodic feature vector are mapped to the corresponding quantization interval. Combined with the control state sequence and phase position corresponding to the period, the target element in the phase coupling tensor is located and the target element is updated according to the exponential decay formula. From the updated phase coupling tensor, extract the conditional probability density values ​​corresponding to each control state according to the quantization interval to which the current water quality feature vector belongs and the current phase position, and arrange them in order of control state to form a likelihood vector. Multiply each element in the likelihood vector by the prior probability of the corresponding control state to obtain the joint probability density vector. The prior probability is obtained by statistical analysis of the historical marginal probability of the control state dimension of the phase coupling tensor. The control state corresponding to the maximum value in the likelihood vector is taken as the current state identification result. After normalizing the likelihood vector, the state entropy is calculated according to the Shannon entropy formula. The state entropy is fed back to the dynamic acquisition step to trigger the shrinking or widening of the threshold. The process deviation is obtained by dividing the value in the joint probability density vector corresponding to the current state identification result by the joint probability density benchmark value of the preset benchmark period template.

[0067] First, the water quality statistical features in the periodic feature vector are mapped to the corresponding quantization intervals. Specifically, based on the mean and other statistical quantities of the five water quality signals in the periodic feature vector, and according to the quantization interval division rules, the discrete interval number to which each water quality feature belongs is determined. Then, combining the control state sequence and phase position corresponding to the period—that is, the actual equipment switching combinations executed in each time period and their functional phase indices—the target element to be updated is located in the three-dimensional phase-coupled tensor. The target element is updated using the exponential decay formula, specifically calculated as follows: Let the value of the target element before updating be P_old, the decay coefficient be α (between 0 and 1), and the count of a single observation of the combination corresponding to the target element be 1. Then, the updated value P_new = α × P_old + (1-α) × 1. The contribution weight of recent observation data to the tensor probability is (1-α), and the weight of historical data decays successively by a proportion of α, thus enabling the tensor to track the slow drift of process characteristics while avoiding excessive influence from individual abnormal observations. The magnitude of the attenuation coefficient α determines the memory length. The closer α is to 1, the longer the memory and the slower the response to drift. The closer α is to 0, the shorter the memory and the faster the response to new observations, but the greater the fluctuation.

[0068] Then, from the updated phase coupling tensor, conditional probability density values ​​corresponding to each control state are extracted according to the quantization interval to which the current water quality feature vector belongs and the current phase position. These values ​​are then arranged in order of control state to form a likelihood vector. The specific calculation is as follows: Let the quantization interval to which the current water quality feature vector belongs be q, the current phase position be p, and there be M legal control states in the control state dimension, numbered s1, s2, ..., s M Then the likelihood vector L = [P(q|s1,p),P(q|s2,p),...,P(q|s... M ,p)], where P(q|s_i,p) represents the conditional probability density of observing the water quality feature quantization interval q under phase position p and control state s_i. This value is directly read from the corresponding element of the updated tensor. Each element of the likelihood vector answers "how likely it is to observe the current water quality feature if we are currently in control state s_i".

[0069] Next, the joint probability density vector is calculated by multiplying each element of the likelihood vector by the prior probability of the corresponding control state. Specifically, the calculation is as follows: Let the prior probability of control state s_i be π(s_i), then the joint probability density vector J = [P(q|s1,p)×π(s2)×P(q|s2,p)×π(s2),...,P(q|s_i)]. M ,p)×π(s M The prior probability π(s_i) is obtained by statistically analyzing the historical marginal probabilities along the phase-coupled tensor control state dimension. This involves summing and normalizing the elements along the tensor control state dimension over all water quality characteristic intervals and phase positions, reflecting the relative frequency of each control state in historical operation. The posterior probability P(s_i|q,p) = P(q|s_i,p) × π(s_i) / P(q,p), where the denominator P(q,p) is the same for all control states. Therefore, the relative magnitude of the joint probability density vector is equivalent to the relative magnitude of the posterior probability. By fusing observational evidence (likelihood) with historical experience (priority), a more accurate state probability estimate can be obtained, thus avoiding the bias of relying solely on current observations or historical experience.

[0070] The control state corresponding to the maximum value in the likelihood vector is taken as the current state identification result. That is, the control state s that maximizes L_i is found, and s is determined as the control state of the system at the current moment. The meaning of the maximum likelihood criterion is: select the control state that makes the current observation have the highest probability as the identification result. This is the most commonly used and intuitive decision criterion in statistical inference. At the same time, the state entropy is calculated by normalizing the likelihood vector and then using the Shannon entropy formula. The specific calculation is as follows: first divide each element of the likelihood vector by the sum of the elements of the likelihood vector to obtain the normalized probability distribution. Then the state entropy ,in When the value is 0, the term is defined as 0. The calculated state entropy is fed back to the dynamic acquisition step to trigger threshold contraction or relaxation, i.e., the second-order differential trigger threshold is adjusted based on the comparison between the state entropy and the upper and lower thresholds. By feeding back the uncertainty of state recognition to the front-end acquisition strategy, the system automatically encrypts acquisition to obtain more discrimination information when the state is difficult to distinguish, and reduces the acquisition frequency to save resources when the state is clear.

[0071] Finally, the process deviation is obtained by dividing the value corresponding to the current state identification result in the joint probability density vector by the joint probability density benchmark value of the preset benchmark period template. Specifically, the calculation is as follows: Let the current state identification result be s, the corresponding value in the joint probability density vector be J_, and the joint probability density benchmark value of the preset benchmark period template under the same water quality characteristic interval, the same phase position, and the same control state be J_base. Then, the process deviation D = J_ × / J_base. The preset benchmark period template is a typical period selected from historical operations where the process state is good and the effluent is stably up to standard. Its joint probability density benchmark value represents the probability level under normal process conditions. The meaning of the process deviation D is: the ratio of the probability of the current period's observation occurring under the current identification state to that of the normal benchmark period. The closer D is to 1, the closer the current process state is to the normal benchmark; D less than 1 indicates that the probability of the current observation occurring under normal conditions is low, and the process may have deviated. This scalar value quantifies the degree of deviation between the current period's process state and the historical best benchmark, providing a quantitative basis for fitness penalty correction in subsequent rolling optimization steps.

[0072] As one implementation method, based on the current state identification results and process deviation, the duration of each phase and key process parameters for future multi-cycles are determined, and an initial solution benchmark is generated according to the phase deviation vector. Carbon and nitrogen phase encoding is used to jointly encode the phosphorus uptake phase duration of anoxic denitrification and the carbon source dosage. The fitness is adjusted according to the process deviation penalty, based on the fitness of the multi-objective weighted value of effluent compliance rate, aeration energy consumption, and carbon source chemical consumption. After the feature vector of each cycle is generated, a phase encoding genetic algorithm is used to solve for the optimal phase configuration. The specific steps for wastewater data processing are as follows: Using the current state identification result and process deviation as state input, the anaerobic phosphorus release phase duration, anoxic denitrification phosphorus uptake phase duration, aerobic aeration phase duration, sedimentation and drainage phase duration, as well as carbon source dosage and aeration intensity in each of the next K cycles are set as decision variables. The deviation values ​​of each phase boundary in the phase deviation vector are mapped proportionally to the initial offset of the decision variables to generate the initial solution benchmark of the genetic algorithm. Carbon-nitrogen phase coding is used to encode the phosphorus uptake phase duration of anoxic denitrification and the carbon source dosage into the same chromosome segment. The denitrification carbon requirement is obtained by multiplying the phosphorus uptake phase duration of anoxic denitrification by the denitrification rate constant. The effective carbon content corresponding to the carbon source dosage must be greater than or equal to the denitrification carbon requirement and less than or equal to its preset multiple, thereby constructing the feasible domain constraint. The multi-objective weighted fitness is obtained by multiplying the effluent compliance rate by the first weight, the aeration energy consumption by the second weight, and the carbon source and chemical consumption by the third weight. When the process deviation is less than the preset deviation threshold, the fitness is multiplied by the process deviation as a penalty correction. After the generation of the feature vector in each cycle, the phase-encoded genetic algorithm is started to generate an initial population with the initial solution benchmark as the center. After selection, crossover and mutation operations and iteration for a preset number of generations, the individual with the highest fitness is selected as the optimal phase configuration. The duration of each phase in the optimal phase configuration is written into the half-cycle time setting register of the programmable logic controller, and the carbon source dosage is written into the dosing pump time period setting register. After conversion between minutes and seconds and comparison with the real-time clock, the half-cycle switching, equipment interlocking and dosing pump execution are driven to realize wastewater data processing.

[0073] In the above steps, the current state identification result and process deviation are first used as state inputs. The current state identification result, output by the maximum likelihood criterion, represents the current control state of the system, determining the initial state and constraints for optimization. The process deviation, based on the ratio of the joint probability density to the baseline value, represents the degree to which the current process state deviates from the normal baseline, determining the urgency and penalty of optimization. The duration of the anaerobic phosphorus release phase, the duration of the anoxic denitrification phosphorus uptake phase, the duration of the aerobic aeration phase, the duration of the sedimentation and drainage phase, as well as the carbon source dosage and aeration intensity, are set as decision variables for each of the next K cycles. K is the prediction time domain length for rolling optimization. The value of K balances the foresight of optimization with computational complexity; a larger K results in more forward-looking optimization but higher computational complexity. The decision variables cover both time dimensions (duration of each phase) and operational dimensions (carbon source dosage, aeration intensity), determining both the process rhythm and the input of reagents and energy. The deviation values ​​of each phase boundary in the phase deviation vector are proportionally mapped to the initial offset of the decision variables. That is, for phases with large deviations, the initial values ​​of the corresponding duration decision variables are shifted in the opposite direction of the deviation based on a preset baseline duration, thereby generating the initial solution baseline for the genetic algorithm. By optimizing the search from a position close to the current actual running state, the slow convergence caused by random initialization is avoided. At the same time, the actual running rhythm deviation reflected by the phase deviation vector directly guides the construction direction of the initial solution, enabling knowledge transfer from historical deviations to the optimization starting point.

[0074] Then, carbon-nitrogen phase coding was used to encode the phosphorus uptake phase duration of anoxic denitrification and the amount of carbon source added into the same chromosome segment. This means that these two variables are placed adjacently in the chromosome coding of the genetic algorithm and treated as a whole, rather than being encoded independently. The reason for this is that there is a strong coupled biochemical stoichiometry relationship between the phosphorus uptake phase duration of anoxic denitrification and the amount of carbon source added. The denitrification process requires organic carbon source as an electron donor and nitrate nitrogen as an electron acceptor. The phosphorus uptake phase duration of anoxic denitrification determines the available time for the denitrification reaction, while the amount of carbon source added determines the supply of electron donors. The two must be matched to ensure that the denitrification reaction proceeds fully and that carbon source is not wasted. The feasible region constraint is constructed based on the stoichiometric relationship of denitrification. The specific logic is as follows: the duration of the phosphorus uptake phase in anoxic denitrification is multiplied by the denitrification rate constant to obtain the carbon requirement for denitrification within that phase. The effective carbon quantity corresponding to the carbon source addition must be greater than or equal to the carbon requirement for denitrification to ensure sufficient denitrification, while it must be less than or equal to a preset multiple of the carbon requirement for denitrification to avoid excessive carbon source addition leading to increased load in subsequent aerobic stages. This encoding and constraint can embed biochemical mechanism knowledge into the encoding structure and search space of the genetic algorithm, thereby eliminating infeasible solutions with carbon-nitrogen mismatch, improving search efficiency and the physical rationality of solutions, and thus avoiding the genetic algorithm wasting computational resources in infeasible regions.

[0075] Based on the above steps, the multi-objective weighted fitness is obtained by multiplying the effluent compliance rate by the first weight, the aeration energy consumption by the second weight, and the carbon source and chemical consumption by the third weight. The sum of the three weights is 1, reflecting the relative importance of treatment effect, aeration energy consumption, and chemical cost in the optimization objectives, respectively. The weight values ​​are determined according to the priority of the operation stage. When the effluent quality fluctuates significantly, the weight of the effluent compliance rate is increased; when energy saving and consumption reduction requirements are high, the weights of energy consumption and chemical consumption are increased. The effluent compliance rate can be estimated by using a prediction model or a historical correlation model to estimate the probability of effluent quality compliance under a given phase configuration. The aeration energy consumption is obtained by multiplying and summing the aeration intensity and aeration duration of each phase. The carbon source and chemical consumption is directly determined by the amount of carbon source added. When the process deviation is less than the preset deviation threshold, the fitness is multiplied by the process deviation as a penalty correction. That is, the smaller the process deviation (indicating that the current process deviates more severely from the baseline), the greater the penalty and the lower the fitness, thereby guiding the genetic algorithm to prioritize the phase configuration that can bring the process state back to the baseline.

[0076] Finally, after the generation of the feature vector for each cycle, the phase-encoded genetic algorithm is started, i.e., optimization is triggered on a cycle-by-cycle basis, ensuring that the optimal configuration can be recalculated based on the latest running data after each cycle. An initial population is generated centered on the initial solution benchmark, i.e., individuals in the initial population are randomly perturbed and generated near the initial solution benchmark, so that the search starts from a reasonable region. After iterating through a preset number of generations using selection, crossover, and mutation operations, the individual with the highest fitness is selected as the optimal phase configuration. The selection operation makes it more likely that individuals with high fitness will be retained, the crossover operation exchanges chromosome segments among different individuals to generate new combinations, and the mutation operation randomly changes individual gene loci to maintain population diversity and prevent premature convergence. The duration of each phase in the optimal phase configuration is written into the half-cycle time setting register of the programmable logic controller, and the carbon source dosage is written into the dosing pump time setting register. After conversion from minutes to seconds, the set duration is converted into the timing benchmark of the programmable logic controller. After comparison with the real-time clock, the half-cycle switching, equipment interlocking, and dosing pump operation are triggered at the set time, thereby translating the optimization results into actual control actions.

[0077] This application also includes a wastewater data processing apparatus, which includes a data acquisition section, a data processing section, and a result output section, for performing a wastewater data processing method.

[0078] It should be understood that those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.

Claims

1. A wastewater data processing method, characterized in that, Includes the following steps: Construct a three-dimensional phase-state coupling tensor of water quality characteristics, control state, and phase position. Each element is the conditional probability density of the water quality characteristics in the quantization interval under the corresponding phase and control state. The state entropy is obtained by controlling the state dimension probability distribution based on the phase coupling tensor. If the state entropy exceeds the upper limit, the trigger threshold is shrunk; if it is below the lower limit, the trigger threshold is relaxed. The second-order difference of the water quality signal sliding window is calculated and compared with the current threshold. If the threshold is exceeded, the sampling interval is shrunk from the basic granularity to the fine granularity; otherwise, the original granularity is maintained to obtain structured data. Candidate switching points are extracted from the phase-time topological features of structured data. The phase boundaries are confirmed by multi-feature point verification and correction using redox potential, pH, and dissolved oxygen curves. Functional phases such as anaerobic phosphorus release and anoxic denitrification phosphorus uptake are divided. Water quality statistics, cumulative energy consumption, and time features of each phase are extracted to form a phase feature vector. The phase deviation vector is obtained by comparing the actual boundary with the preset time series. The phase difference features of anaerobic phosphorus release and anoxic denitrification phosphorus uptake are extracted to form a release and uptake phase feature vector. The periodic feature vector is then spliced ​​together to obtain the periodic feature vector. The phase coupling tensor is updated exponentially by using the periodic feature vector and the corresponding control state sequence. The likelihood vector of the current water quality feature vector under each control state is obtained from the updated tensor. The joint probability density vector is obtained by multiplying the prior probability. The control state with the highest likelihood is taken as the current state identification result. The Shannon entropy is obtained by normalizing the likelihood vector and the state entropy is returned to dynamic acquisition. The process deviation is obtained by comparing the current state corresponding value in the joint probability density vector with the preset benchmark value. Based on the current state identification results and process deviation, the duration of each phase and key process parameters for future multi-cycles are determined, and an initial solution benchmark is generated according to the phase deviation vector. Carbon and nitrogen phase encoding is used to jointly encode the phosphorus uptake phase duration of anoxic denitrification and the amount of carbon source added. The fitness is adjusted according to the process deviation penalty based on the fitness of the multi-objective weighted value of effluent compliance rate, aeration energy consumption and carbon source chemical consumption. After the feature vector of each cycle is generated, the optimal phase configuration is obtained by rolling solution using a phase encoding genetic algorithm to realize wastewater data processing.

2. The wastewater data processing method according to claim 1, characterized in that, The specific steps for constructing the three-dimensional phase-state coupling tensor of water quality characteristics, control state, and phase position are as follows: The five analog signals of pH, dissolved oxygen, oxidation-reduction potential, liquid level and sludge concentration are divided into N quantization intervals according to their respective ranges. Each quantization interval corresponds to a discrete value of a water quality characteristic dimension. The on / off states of the influent pump, anaerobic tank mixer, sequencing batch tank mixer, nitrification liquor return pump, sludge return pump, aerator, and two dosing pumps are encoded as control state dimensions using binary combinations. The constraints of interlocking between the influent valve and the sludge return valve, between the pump and the valve, and between the mixer and the aeration valve are directly reflected in the set of valid control state codes. The anaerobic phosphorus release phase, anoxic denitrification phosphorus uptake phase, aerobic aeration phase, and sedimentation drainage phase in the dual half-cycle alternating operation structure are encoded as phase position dimensions in chronological order. The first half-cycle and the second half-cycle are switched by word exchange instructions and mapped to the same phase position index. A three-dimensional tensor is constructed with water quality characteristics as the first dimension, control state as the second dimension, and phase position as the third dimension. The initial value of each element of the tensor is set to 1 divided by the uniform distribution conditional probability density of the total number of quantization intervals under the corresponding control state. Five raw signals acquired by the analog input module of the programmable logic controller are first compared with their respective preset lower limits. Raw signals below the input lower limit are clamped to the input lower limit. Then, they are converted into engineering quantity values ​​according to the linear scaling formula. The linear scaling formula is the output lower limit plus the difference between the output upper limit and the output lower limit multiplied by the original signal minus the input lower limit and divided by the input upper limit minus the input lower limit. The converted engineering quantity values ​​are compared with their respective preset upper limits. Engineering quantity values ​​above the output upper limit are clamped to the output upper limit. Finally, the clamped engineering quantity values ​​are placed into the corresponding quantization intervals according to their numerical ranges, thus completing the discretization mapping of water quality characteristic dimensions.

3. The wastewater data processing method according to claim 2, characterized in that, The specific steps for obtaining the state entropy based on the probability distribution of the control state dimension using the phase coupling tensor, and then shrinking the trigger threshold when the state entropy exceeds the upper limit and relaxing the trigger threshold when it is below the lower limit, are as follows: Summing the elements of all water quality feature quantization intervals and phase positions under the same control state along the control state dimension of the phase coupling tensor yields the unnormalized marginal probability of each control state. Dividing each unnormalized marginal probability by the sum of the marginal probabilities of all control states yields the normalized marginal probability distribution. The state entropy is calculated using the Shannon entropy formula for the normalized marginal probability distribution. The state entropy is equal to the sum of the negative values ​​of the logarithms of each control state probability. The higher the state entropy, the greater the uncertainty in identifying the current control state. The upper and lower thresholds of the state entropy are preset. When the state entropy is higher than the upper threshold, the second-order difference trigger threshold is multiplied by a contraction coefficient less than 1. When the state entropy is lower than the lower threshold, the second-order difference trigger threshold is multiplied by a relaxation coefficient greater than 1. After the trigger threshold is contracted or relaxed, it is compared with the preset minimum threshold lower bound and maximum threshold upper bound. If it is lower than the lower bound, it is clamped to the lower bound; if it is higher than the upper bound, it is clamped to the upper bound. The clamped trigger threshold is used as the benchmark for the second-order difference comparison in the current cycle.

4. The wastewater data processing method according to claim 3, characterized in that, The specific steps for calculating the second-order difference of the water quality signal sliding window and comparing it with the current threshold are as follows: If the threshold is exceeded, the sampling interval is reduced from the basic granularity to the fine granularity; otherwise, the original granularity is maintained. The fixed scan cycle of the main loop of the programmable logic controller is used as the basic granularity, and the interrupt cycle of the programmable logic controller's periodic interrupt is used as the fine granularity. For the scaled analog engineering quantity values ​​of each channel, take a sliding window of length W, and calculate the second difference value of three adjacent points in the window according to the second difference recursive formula. The second difference value is equal to the current sample value minus twice the previous sample value plus the previous two sample values. The absolute value of the second-order difference of each channel is compared with the current trigger threshold channel by channel. If the value of the channel exceeds the threshold, the fine acquisition flag is set and the sampling interval of the channel is switched from the basic scan cycle to the interrupt cycle. If the value of the channel does not exceed the threshold, the fine acquisition flag is cleared and the basic scan cycle is maintained. Each channel collects data at its own sampling interval, carrying a timestamp of the collection time. At the end of each basic scan cycle, the data is arranged in a structured data matrix with a fixed number of columns according to the timestamps. Missing times are filled with previous values. The structured data matrix serves as the input for phase-series topological feature extraction.

5. The wastewater data processing method according to claim 4, characterized in that, The specific steps for extracting candidate switching points from the phase-temporal topological features of structured data, verifying and correcting phase boundaries using multiple feature points such as redox potential, pH, and dissolved oxygen curves, and dividing functional phases such as anaerobic phosphorus release and anoxic denitrification phosphorus uptake are as follows: The slope change rate of the three signals of redox potential, acidity and alkalinity and dissolved oxygen in the structured data matrix is ​​calculated respectively. The moment when the slope change rate exceeds the preset slope threshold is marked as a candidate phase switching point. The candidate switching points of the three signals are merged and deduplicated to obtain the candidate switching point sequence. On the redox potential curve, the moment when the first derivative changes from negative to positive is determined as the inflection point; on the pH curve, the moment when the first derivative changes from positive to negative or from negative to positive is determined as the extreme point; on the dissolved oxygen curve, the moment when the first derivative exceeds a preset jump threshold is determined as the jump point. These three types of feature points form a multi-feature point set. For each candidate point in the candidate switching point sequence, count the number of multiple feature points within an interval centered on the candidate point and with a width of a preset time window. When the number is greater than or equal to 2, the candidate point is confirmed as an effective phase boundary and its time is recorded. When the number is less than 2, the candidate point is discarded. The effective phase boundaries are arranged in chronological order. The time interval between two adjacent effective phase boundaries is marked as a functional phase. Based on the mean range of redox potential, pH, and dissolved oxygen within that time interval, it is determined to be an anaerobic phosphorus release phase, anoxic denitrification phosphorus uptake phase, aerobic aeration phase, or sedimentation and drainage phase, respectively.

6. The wastewater data processing method according to claim 5, characterized in that, The specific steps for extracting phase feature vectors from water quality statistics, cumulative energy consumption, and time characteristics of each phase, comparing the actual boundary with the preset time series to obtain the phase deviation vector, extracting the phase difference features of anaerobic phosphorus release and anoxic denitrification phosphorus uptake to form the release phase feature vector, and concatenating them to obtain the periodic feature vector are as follows: For each functional phase, the mean, standard deviation, maximum and minimum values ​​of the five water quality signals within that phase are calculated as water quality statistical features. The cumulative energy consumption feature is obtained by multiplying the running time of the aerator, each mixer and each pump within that phase by their corresponding rated power. The duration feature is obtained by subtracting the start time from the end time of that phase. The three types of features are arranged in a fixed order to form the phase feature vector of that phase. Subtract the set time of the corresponding phase boundary in the preset timing sequence from the actual time of each effective phase boundary to obtain the time deviation of each phase boundary. Arrange the time deviations of all phase boundaries in phase order to form a phase deviation vector. Subtract the corresponding dimensions of the anaerobic phosphorus release phase feature vector from the anoxic denitrification phosphorus uptake phase feature vector to obtain the cross-phase difference features. Arrange the cross-phase difference features in dimensional order to form the release and uptake phase feature vector. The phase feature vectors of all functional phases are concatenated end to end in phase order, and then the phase deviation vector and the release phase feature vector are concatenated to obtain a fixed-dimensional periodic feature vector. The periodic feature vector serves as the common input for phase coupling tensor update and rolling optimization.

7. The wastewater data processing method according to claim 6, characterized in that, The specific steps for updating the phase coupling tensor with the periodic feature vector and corresponding control state sequence in an exponential decay manner, calculating the likelihood vector of the current water quality feature vector under each control state based on the updated tensor, multiplying it by the prior probability to obtain the joint probability density vector, taking the control state with the highest likelihood as the current state identification result, normalizing the likelihood vector to obtain the Shannon entropy to obtain the state entropy and dynamically collecting it back, and comparing the current state corresponding value in the joint probability density vector with the preset benchmark value to obtain the process deviation are as follows: The water quality statistical features in the periodic feature vector are mapped to the corresponding quantization interval. Combined with the control state sequence and phase position corresponding to the period, the target element in the phase coupling tensor is located and the target element is updated according to the exponential decay formula. From the updated phase coupling tensor, extract the conditional probability density values ​​corresponding to each control state according to the quantization interval to which the current water quality feature vector belongs and the current phase position, and arrange them in order of control state to form a likelihood vector. Multiply each element in the likelihood vector by the prior probability of the corresponding control state to obtain the joint probability density vector. The prior probability is obtained by statistical analysis of the historical marginal probability of the control state dimension of the phase coupling tensor. The control state corresponding to the maximum value in the likelihood vector is taken as the current state identification result. After normalizing the likelihood vector, the state entropy is calculated according to the Shannon entropy formula. The state entropy is fed back to the dynamic acquisition step to trigger the shrinking or widening of the threshold. The process deviation is obtained by dividing the value in the joint probability density vector corresponding to the current state identification result by the joint probability density benchmark value of the preset benchmark period template.

8. The wastewater data processing method according to claim 7, characterized in that, Based on the current state identification results and process deviation, the duration of each phase and key process parameters for future multi-cycle periods are determined, and an initial solution benchmark is generated according to the phase deviation vector. Carbon and nitrogen phase encoding is used to jointly encode the phosphorus uptake phase duration of anoxic denitrification and the carbon source dosage. The fitness is adjusted based on a multi-objective weighted value of effluent compliance rate, aeration energy consumption, and carbon source chemical consumption, with a penalty for process deviation. After the feature vector of each cycle is generated, a phase encoding genetic algorithm is used to continuously solve for the optimal phase configuration. The specific steps for wastewater data processing are as follows: Using the current state identification result and process deviation as state input, the anaerobic phosphorus release phase duration, anoxic denitrification phosphorus uptake phase duration, aerobic aeration phase duration, sedimentation and drainage phase duration, as well as carbon source dosage and aeration intensity in each of the next K cycles are set as decision variables. The deviation values ​​of each phase boundary in the phase deviation vector are mapped proportionally to the initial offset of the decision variables to generate the initial solution benchmark of the genetic algorithm. Carbon-nitrogen phase coding is used to encode the phosphorus uptake phase duration of anoxic denitrification and the carbon source dosage into the same chromosome segment. The denitrification carbon requirement is obtained by multiplying the phosphorus uptake phase duration of anoxic denitrification by the denitrification rate constant. The effective carbon content corresponding to the carbon source dosage must be greater than or equal to the denitrification carbon requirement and less than or equal to its preset multiple, thereby constructing the feasible domain constraint. The multi-objective weighted fitness is obtained by multiplying the effluent compliance rate by the first weight, the aeration energy consumption by the second weight, and the carbon source and chemical consumption by the third weight. When the process deviation is less than the preset deviation threshold, the fitness is multiplied by the process deviation as a penalty correction. After the generation of the feature vector in each cycle, the phase-encoded genetic algorithm is started to generate an initial population with the initial solution benchmark as the center. After selection, crossover and mutation operations and iteration for a preset number of generations, the individual with the highest fitness is selected as the optimal phase configuration. The duration of each phase in the optimal phase configuration is written into the half-cycle time setting register of the programmable logic controller, and the carbon source dosage is written into the dosing pump time period setting register. After conversion between minutes and seconds and comparison with the real-time clock, the half-cycle switching, equipment interlocking and dosing pump execution are driven to realize wastewater data processing.

9. A wastewater treatment apparatus for the wastewater data processing method according to any one of claims 1 to 8, characterized in that, include: The data acquisition section, the data processing section, and the result output section are all separate.

10. An electronic device, characterized in that, include: A memory, a processor, and a computer program stored on the memory, the processor being configured to run the computer program to perform the wastewater data processing method according to any one of claims 1 to 8.