Ultrasonic water meter zero flow detection method and device based on machine learning
Through machine learning methods, the flow detection model of ultrasonic water meter is optimized, and the zero flow data is identified and eliminated, which solves the metering error problem caused by pressure fluctuations, and realizes the precise flow detection of ultrasonic water meter.
Patent Information
- Application Number
- CN202510494049.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-19
- Publication Date
- 2025-08-01
AI Technical Summary
In actual working conditions, the existing ultrasonic water meter has caused pressure fluctuations caused by pipeline vibration and valve operation, resulting in zero flow being misrecorded as effective flow, causing metering errors.
Using a machine learning-based method, data is collected through the time difference ultrasonic flowmeter, and using improved subtraction average optimizer and support vector machine, the kernel function parameters and punishment factors are optimized, and the model is trained to identify and eliminate zero flow data.
The precise measurement of ultrasonic water meter is achieved, which reduces measurement errors caused by pressure fluctuations and ensures the accuracy of flow detection.
Smart Images

Figure CN120403815A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of flow detection, and particularly to a zero-flow detection method, device, electronic device, and storage medium for an ultrasonic water meter based on machine learning. Background Art
[0002] The accurate measurement of water flow is of great significance for urban water supply, industrial process control, and pipe network monitoring. The measurement principle of an ultrasonic water meter based on the time difference method is to use a pair of ultrasonic transducers to alternately transmit and receive ultrasonic waves in opposite directions, and indirectly measure the water flow velocity by detecting the time difference between the downstream and upstream propagation times of ultrasonic waves in water, and finally achieve the measurement of water flow. Ultrasonic water meters are widely used due to their advantages such as a wide range ratio, high sensitivity, and small starting flow. However, in actual working conditions, the vibration of pipelines, sudden closing or rapid operation of valves will cause instantaneous high-amplitude pressure fluctuations in the pipeline, resulting in oscillation and forward and reverse flow phenomena of the water flow in the pipeline, which may lead to misrecording the actual zero flow as an effective flow, thereby causing a large measurement error.
[0003] Regarding the problem of large measurement errors in related technologies, no effective solution has been proposed yet. Summary of the Invention
[0004] In this embodiment, a zero-flow detection method, device, electronic device, and storage medium for an ultrasonic water meter based on machine learning are provided to solve the problem of large measurement errors in related technologies.
[0005] In the first aspect, in this embodiment, a zero-flow detection method for an ultrasonic water meter based on machine learning is provided, and the method includes:
[0006] Based on the measurement principle of a time difference method ultrasonic flowmeter, collect the time difference data of each channel before and after closing the valve at different flow points of a multi-channel ultrasonic water meter, and classify the time difference data;
[0007] Preprocess the original data, calculate the statistic of each group of time difference data, and construct the statistic into a feature data set;
[0008] Initialize the parameters of the improved subtraction average optimizer, and set the maximum number of iterations, population size, and chaotic mapping parameters;
[0009] Determine the value ranges of the penalty parameter c and the Gaussian kernel function parameter g of the support vector machine;
[0010] Divide the feature data set into a training set and a test set, use the root mean square error between the predicted value and the actual value as the fitness function, and the parameters corresponding to the lowest fitness value are the optimal solutions;
[0011] Iteratively search for the optimal solutions of the penalty parameter c and the Gaussian kernel function parameter g until the maximum number of iterations is reached;
[0012] Output the optimal solutions of the penalty parameter c and the Gaussian kernel function parameter g after iteration, and use the optimized parameters to train the support vector machine to obtain the zero-flow detection model for ultrasonic water meters;
[0013] Based on the zero-flow detection model for ultrasonic water meters, perform zero-flow detection on ultrasonic water meters.
[0014] In some embodiments, the statistic includes the mean of absolute values, the mean absolute deviation, the standard deviation, the skewness coefficient, and the kurtosis coefficient.
[0015] In some embodiments, the method further includes:
[0016] Set the number of iterations, the number of populations, and the parameter search range;
[0017] Use the data generated by the chaotic mapping as the initial position information of the population;
[0018] Calculate the fitness values of the initial population, use the root mean square error between the predicted value and the actual value as the fitness value for evaluating each individual in the initial population, and record the current optimal solution and the worst solution;
[0019] Dynamically update the particle positions;
[0020] Update the population fitness values, reorder and update the global optimal solution.
[0021] In some embodiments, based on the zero-flow detection model for ultrasonic water meters, performing zero-flow detection on ultrasonic water meters includes:
[0022] Collect the time difference data of each channel of the multi-channel ultrasonic water meter to be detected;
[0023] Input the time difference data into the zero-flow detection model for ultrasonic water meters;
[0024] According to the result output by the zero-flow detection model for ultrasonic water meters, remove the zero-flow data from the time difference data.
[0025] In some embodiments, classifying the time difference data includes: according to the recorded time of closing the valve and the time stamp of collecting the data, dividing the time difference data into the time difference data before closing the valve and the time difference data after closing the valve.
[0026] In some embodiments, the improved subtraction mean optimizer is a subtraction mean optimizer improved based on chaotic mapping and dynamic perturbation.
[0027] In some embodiments, the time difference data is the time difference between the downstream and upstream propagation times of ultrasonic waves in water.
[0028] In a second aspect, in this embodiment, an ultrasonic water meter zero-flow detection device based on machine learning is provided, and the device includes:
[0029] A data processing module, configured to collect the time difference data of each channel before and after closing the valve at different flow points of a multi-channel ultrasonic water meter based on the measurement principle of a time-difference method ultrasonic flowmeter, classify the time difference data; preprocess the original data, calculate the statistic of each group of time difference data, and construct the statistic into a feature data set;
[0030] A model training module, configured to perform parameter initialization on an improved subtraction mean optimizer, set the maximum number of iterations, population size, and chaotic mapping parameters; determine the value ranges of the penalty parameter c and the Gaussian kernel function parameter g of a support vector machine; divide the feature data set into a training set and a test set, use the root mean square error between the predicted value and the actual value as a fitness function, and use the parameters corresponding to the lowest fitness value as the optimal solution; iteratively search for the optimal solutions of the penalty parameter c and the Gaussian kernel function parameter g until the maximum number of iterations is reached; output the optimal solutions of the penalty parameter c and the Gaussian kernel function parameter g after iteration, and use the optimized parameters to train the support vector machine to obtain an ultrasonic water meter zero-flow detection model;
[0031] A flow detection module, configured to perform ultrasonic water meter zero-flow detection based on the ultrasonic water meter zero-flow detection model.
[0032] In a third aspect, in this embodiment, an electronic device is provided, including a memory and a processor. A computer program is stored in the memory, and the processor is configured to run the computer program to execute a method for detecting zero flow of an ultrasonic water meter based on machine learning in the first aspect.
[0033] In a fourth aspect, in this embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of a method for detecting zero flow of an ultrasonic water meter based on machine learning in the first aspect are implemented.
[0034] Compared with the related technologies, a method, device, electronic device, and storage medium for zero-flow detection of an ultrasonic water meter based on machine learning provided in this embodiment collect the time-difference data of each channel before and after closing the valve at different flow points of a multi-channel ultrasonic water meter according to the measurement principle of a time-difference method ultrasonic flowmeter, and classify the time-difference data; preprocess the original data, calculate the statistics of each group of time-difference data, and construct the statistics into a feature data set; initialize the parameters of the improved subtraction mean optimizer, set the maximum number of iterations, population size, and chaotic mapping parameters; determine the value ranges of the penalty parameter c and the Gaussian kernel function parameter g of the support vector machine; divide the feature data set into a training set and a test set, use the root mean square error between the predicted value and the actual value as the fitness function, and the parameters corresponding to the lowest fitness value are the optimal solutions; iteratively search for the optimal solutions of the penalty parameter c and the Gaussian kernel function parameter g until the maximum number of iterations is reached; output the optimal solutions of the penalty parameter c and the Gaussian kernel function parameter g after iteration, and use the optimized parameters to train the support vector machine to obtain an ultrasonic water meter zero-flow detection model; based on the ultrasonic water meter zero-flow detection model, perform zero-flow detection of the ultrasonic water meter, solve the problem that in actual working conditions, the vibration of the pipeline, the sudden closing or rapid operation of the valve will cause instantaneous high-amplitude pressure fluctuations in the pipeline, resulting in oscillation and forward and reverse flow phenomena of the water flow in the pipeline, which will cause the actual zero flow to be misrecorded as an effective flow, and thus cause a large measurement error, and achieve accurate measurement of the ultrasonic water meter.
[0035] Details of one or more embodiments of this application are set forth in the following drawings and description to make other features, objects, and advantages of this application more concise and understandable. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The drawings described herein are used to provide a further understanding of this application and constitute a part of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an improper limitation of this application. In the drawings:
[0037] Figure 1 is a hardware structure block diagram of a terminal of a method for zero-flow detection of an ultrasonic water meter based on machine learning provided in this embodiment;
[0038] Figure 2 is a flowchart of a method for zero-flow detection of an ultrasonic water meter based on machine learning provided in an embodiment of this application;
[0039] Figure 3 is a schematic diagram of an algorithm for improving the subtraction mean optimizer based on the Logistic chaotic mapping provided in an embodiment of this application;
[0040] Figure 4It is a flowchart of a method for constructing a zero - flow detection model of an ultrasonic water meter based on an improved optimization algorithm provided by an embodiment of the present application;
[0041] Figure 5 It is a schematic diagram of a confusion matrix provided by an embodiment of the present application;
[0042] Figure 6 It is another schematic diagram of a confusion matrix provided by an embodiment of the present application;
[0043] Figure 7 It is a structural block diagram of a zero - flow detection device for an ultrasonic water meter based on machine learning in this embodiment. Detailed implementation manners
[0044] To more clearly understand the purpose, technical solution, and advantages of the present application, the present application will be described and illustrated below in conjunction with the accompanying drawings and embodiments.
[0045] Unless otherwise defined, the technical terms or scientific terms involved in the present application shall have the general meaning understood by those with ordinary skills in the technical field to which the present application belongs. In the present application, words such as "a", "one", "a kind of", "the", "these", etc. do not indicate a limitation in quantity, and they can be singular or plural. The terms "including", "comprising", "having" and any variants thereof involved in the present application are intended to cover non - exclusive inclusion; for example, a process, method, system, product, or device including a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent in these processes, methods, products, or devices. The terms "connected", "coupled", etc. involved in the present application do not limit to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The term "a plurality of" involved in the present application means two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, "A and / or B" can represent: A exists alone, A and B exist simultaneously, and B exists alone. Usually, the character " / " indicates that the objects associated before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in the present application only distinguish similar objects and do not represent a specific sorting for the objects.
[0046] In actual working conditions, the vibration of pipelines, the sudden closing or rapid operation of valves will cause instantaneous high-amplitude pressure fluctuations in the pipelines. As a result, the water flow in the pipelines will generate oscillations and forward and reverse flow phenomena, which will lead to misrecording the actual zero flow as the effective flow, and thus cause relatively large measurement errors. Traditional methods usually use digital filtering and data smoothing to alleviate this problem. However, these methods have some deficiencies: 1) Improper selection of filtering parameters may lead to delays or data distortion; 2) Excessive smoothing may lose the real instantaneous flow change information.
[0047] Support Vector Machine (SVM) has the advantages of strong classification ability, strong generalization ability and good robustness. However, its performance highly depends on the selection of kernel function parameters and penalty factors. Manual parameter tuning is inefficient and prone to falling into local optima. Subtraction Averaging Optimizer (SABO) is based on mathematical subtraction operations and the concept of average value, and drives position update by searching the difference signs between agents. It has the characteristics of low computational complexity, fast convergence speed and strong global search ability. This application will improve SABO to optimize the kernel function parameters and penalty factors of SVM, train the support vector machine model by optimizing the parameters, and finally use the model to identify and eliminate the misread flow generated thereby to ensure the accurate measurement of ultrasonic water meters.
[0048] The method embodiments provided in this embodiment can be executed in a terminal, a computer or a similar computing device. For example, running on a terminal, Figure 1 is the hardware structure block diagram of a terminal for an ultrasonic water meter zero flow detection method based on machine learning provided in this embodiment. As Figure 1 shown, the terminal may include one or more ( Figure 1 only one is shown in the figure) processors 102 and a memory 104 for storing data. Among them, the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA. The above terminal may also include a transmission device 106 for communication functions and an input / output device 108. Those of ordinary skill in the art can understand that, Figure 1 the structure shown is only schematic and does not limit the structure of the above terminal. For example, the terminal may also include more or fewer components than Figure 1 shown in the figure, or have a different configuration from Figure 1 shown in the figure.
[0049] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to a machine learning-based zero-flow detection method for ultrasonic water meters in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implements the above method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memories. In some instances, the memory 104 may further include a memory remotely disposed relative to the processor 102, and these remote memories can be connected to the terminal through a network. Examples of the above network include but are not limited to the Internet, enterprise intranet, local area network, mobile communication network, and combinations thereof.
[0050] The transmission device 106 is used to receive or send data via a network. The above network includes the wireless network provided by the communication provider of the terminal. In one instance, the transmission device 106 includes a network adapter (Network Interface Controller, abbreviated as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one instance, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0051] In this embodiment, a machine learning-based zero-flow detection method for ultrasonic water meters is provided. Figure 2 It is a flowchart of a machine learning-based zero-flow detection method for ultrasonic water meters provided by an embodiment of the present application, as Figure 2 shown, this process includes the following steps:
[0052] Step S210, based on the measurement principle of the time-difference method ultrasonic flowmeter, collect the time-difference data of each channel before and after closing the valve at different flow points of the multi-channel ultrasonic water meter, and classify the time-difference data.
[0053] In this step, based on the measurement principle of the time-difference method ultrasonic flowmeter, collect the time-difference data of each channel before and after closing the valve at different flow points of the multi-channel ultrasonic water meter. According to the recorded time of closing the valve and the time stamp of collecting data, divide the time-difference data into two categories. One category is: the time-difference data before closing the valve, denoted as label 1 (normal flow); the other category is: the time-difference data after closing the valve, denoted as label 2 (zero flow).
[0054] Step S220, preprocess the original data, calculate the statistics of each group of time-difference data, and construct the statistics into a feature data set.
[0055] In this step, the original data is preprocessed, and the statistics of the time difference for each group (corresponding to the measured values of all measurement channels in one instantaneous flow measurement) are calculated, including: mean absolute value, mean absolute deviation, standard deviation, skewness coefficient, and kurtosis coefficient. These statistics are integrated to construct a new feature dataset.
[0056] Step S230: Initialize the parameters of the improved subtraction mean optimizer, and set the maximum number of iterations, population size, and chaotic mapping parameters.
[0057] Step S240: Determine the value ranges of the penalty parameter c and the Gaussian kernel function parameter g of the support vector machine.
[0058] Step S250: Divide the feature dataset into a training set and a test set, and use the root mean square error between the predicted value and the actual value as the fitness function. The parameters corresponding to the lowest fitness value are the optimal solutions.
[0059] In this step, the newly created feature dataset is divided into a training set and a test set at a ratio of 7:3, and the root mean square error (RMSE) between the predicted value and the actual value is used as the fitness function. The parameters corresponding to the lowest fitness value are the optimal solutions.
[0060] Step S260: Iteratively search for the optimal solutions of the penalty parameter c and the Gaussian kernel function parameter g until the maximum number of iterations is reached.
[0061] Step S270: Output the optimal solutions of the penalty parameter c and the Gaussian kernel function parameter g after iteration, and use the optimized parameters to train the support vector machine to obtain the zero-flow detection model for ultrasonic water meters.
[0062] Step S280: Based on the zero-flow detection model for ultrasonic water meters, perform zero-flow detection for ultrasonic water meters.
[0063] Through the above steps, the kernel function parameters and penalty factors of the SVM are optimized by improving the SABO, the support vector machine model is trained with the optimized parameters, and finally the model is used to identify and eliminate the misread flow rates generated thereby, ensuring the accurate measurement of ultrasonic water meters.
[0064] In one of the embodiments, based on the zero-flow detection model for ultrasonic water meters, zero-flow detection for ultrasonic water meters is performed, including: collecting the time difference data of each channel of the multi-channel ultrasonic water meter to be detected; inputting the time difference data into the zero-flow detection model for ultrasonic water meters; and removing the zero-flow data in the time difference data according to the result output by the zero-flow detection model for ultrasonic water meters.
[0065] In this embodiment, a method for improving the subtraction mean optimizer based on the Logistic chaotic mapping and dynamic perturbation is also provided, where Logistic is a type of chaotic mapping. The specific steps are as follows:
[0066] Step 1: Set the number of iterations, the size of the population, and the parameter search range.
[0067] Step 2: Use the data generated by the Logistic chaotic map as the initial position information of the population.
[0068] Step 3: Calculate the fitness values of the initial population. Use the root mean square error between the predicted value and the actual value as the fitness value to evaluate each individual in the initial population, and record the current optimal solution and the worst solution.
[0069] Step 4: Dynamically update the particle positions.
[0070] Step 5: Update the population fitness values, reorder, and update the global optimal solution.
[0071] Step 6: If the maximum number of iterations is reached, output the optimal parameters c and g; otherwise, return to Step 4.
[0072] This embodiment optimizes the SVM algorithm based on the improved SABO and proposes a zero-flow detection model of a support vector machine ultrasonic flowmeter based on the improved optimization algorithm. The specific steps are as follows:
[0073] Step 1: Preprocess the original data of the multi-channel ultrasonic water meter, and calculate the statistics of each group of time differences (corresponding to the measured values of all measurement channels in a single instantaneous flow measurement), including: absolute value mean, mean absolute deviation, standard deviation, skewness coefficient, and kurtosis coefficient. Integrate these statistics to construct a new feature dataset.
[0074] Step 2: Divide the newly created feature dataset into a dataset and a test set at a ratio of 7:3. Use the root mean square error between the predicted value and the actual value as the fitness function, and the optimal solution is obtained when the fitness reaches the lowest.
[0075] Step 3: Initialize the LSABO (Logistic-SABO) parameters, set the number of iterations and the size of the population, and determine the value ranges of the penalty parameter c and the g of the Gaussian kernel function.
[0076] Step 4: Search for the optimal c and g through LSABO until the maximum number of iterations is reached.
[0077] Step 5: Output the optimal solution within the number of iterations, and use the optimized parameters to train the support vector machine to obtain a zero-flow detection model of the ultrasonic water meter.
[0078] This embodiment proposes an improved subtraction average optimizer. This algorithm uses the data generated by the Logistic chaotic map as the initial position information of the population and performs adaptive chaotic perturbation on individuals with poor fitness values, reducing the possibility of falling into local optima. The relevant parameters of the support vector machine are optimized using the LSABO search algorithm, improving the generalization ability of the vector machine. The LSABO-SVM algorithm can identify whether the time difference data of the multi-channel ultrasonic water meter is zero-flow time difference data through the statistics of the time difference data. When it is identified as zero-flow time difference, this time difference is excluded to prevent the ultrasonic water meter from generating incorrect measurements and ensure the accurate measurement of the ultrasonic water meter.
[0079] The following describes and illustrates this embodiment through specific examples.
[0080] This embodiment also provides an improved subtraction average optimizer algorithm based on the Logistic chaotic map, as Figure 3 shown below:
[0081] Step S310, set the number of iterations, the number of the population, and the parameter search range.
[0082] Step S320, according to Equation (1), use the data generated by the Logistic chaotic map as the initial position information of the population, which can improve the search diversity, global search ability, and the ability to jump out of local optimal solutions, that is
[0083] X i = ω + (μ - ω) · y i , i = 1, 2,..., N (1)
[0084] In the formula, ω and μ respectively represent the lower and upper limits of the entire search space, yi is the chaotic perturbation vector, and N is the population size.
[0085] Step S330, calculate the fitness values of the initial population and determine the position of the current optimal individual.
[0086] Step S340, update the position according to Equation (2) based on individual differences, that is
[0087]
[0088] In the formula, is the position of the i-th particle after update, N is the population size, is the random perturbation factor, F(X i ) is the fitness function value of the i-th particle, sign is the signum function, dynamic weight coefficient.
[0089] Step S350: Apply perturbations to the individuals with fitness values greater than the median according to Equation (3), where the perturbation intensity decays with iteration, i.e.,
[0090]
[0091] In the formula, α0 is the initial chaotic perturbation intensity, T is the maximum number of iterations, t is the current number of iterations, y i is the chaotic perturbation vector, and N is the population size.
[0092] Step S360: Update the particle positions according to Equation (4), i.e.,
[0093]
[0094] In the formula, is the position of the i-th particle after update, F i new is the fitness value of the i-th particle after update, and F i is the fitness value of the i-th particle before update.
[0095] Step S370: If the maximum number of iterations is reached, output the optimal c and g with the best fitness value; otherwise, continue the iteration.
[0096] This embodiment also provides a method for constructing a zero-flow detection model of a support vector machine ultrasonic water meter based on an improved optimization algorithm, as Figure 4 shown below:
[0097] Step S410: Preprocess the original data of the multi-channel ultrasonic water meter.
[0098] Calculate the statistical quantities of each group of time differences, including: mean absolute value, mean absolute deviation, standard deviation, skewness coefficient, and kurtosis coefficient. Their meanings and calculation methods are as follows:
[0099] Mean absolute value (AM): Measure the average level of each group of time differences and the degree of difference between different time difference data.
[0100]
[0101] In the formula, x i is the value of the i-th sample point, and N is the total number of samples.
[0102] Mean absolute deviation (MAD): Measure the degree of change of each group of time differences and describe the non-stationarity or volatility of each group of time differences.
[0103]
[0104] In the formula, x i is the value of the i-th sample point, and N is the total number of samples.
[0105] Standard Deviation (S): It measures the dispersion degree of each group of time differences, indicating the fluctuation range of each group of time differences relative to the mean value.
[0106]
[0107] Where x i is the value of the i-th sample point, and N is the total number of samples.
[0108] Skewness: The skewness coefficient measures the symmetry of the distribution of each group of time differences. When the skewness is greater than zero, the tail of the distribution is on the right side. When the skewness is less than zero, the tail of the distribution is on the left side. When the skewness is equal to zero, it is close to the normal distribution.
[0109]
[0110] Where x i is the value of the i-th sample point, is the sample mean value, N is the total number of samples, and S is the standard deviation.
[0111] Kurtosis: The kurtosis coefficient measures the steepness of the distribution of each group of time differences. When the kurtosis is greater than 3, there are many outliers. When the kurtosis is less than 3, there are few outliers. When the kurtosis is equal to 3, it is the standard normal distribution.
[0112]
[0113] Where x i is the value of the i-th sample point, is the sample mean value, and N is the total number of samples.
[0114] These statistics are combined into a 5-dimensional feature vector to form a new feature dataset.
[0115] Step S420: Divide the newly created feature dataset into a dataset and a test set according to 7:3. Use the root mean square error between the predicted value and the actual value as the fitness function, and the optimal solution is obtained when the fitness reaches the lowest value.
[0116] Step S430: Initialize the LSABO parameters, and set the maximum number of iterations, population size, and chaos mapping parameters.
[0117] Step S440: Determine the value ranges of the penalty parameter c and the g of the Gaussian kernel function. These two parameter values are closely related to the anti-interference ability and generalization ability of the support vector machine.
[0118] Among them, the basic process of support vector machine classification is as follows:
[0119] (1) Set the penalty parameter C, and the function distance is y i =(ωx i+b) and select an appropriate kernel function K(x,z), that is
[0120]
[0121] 0 ≤ α i ≤ C, i = 1, 2,..., n (10)
[0122] Obtain the Lagrange multipliers α * =(α1 * , α2 * ,..., α n * ) T
[0123] In the formula, α * is the Lagrange multiplier, y i is the function distance, x i is the input feature vector, and C is the penalty factor.
[0124] (2) Calculate
[0125]
[0126] In the formula, ω * is the weight vector, α * is the Lagrange multiplier, y i is the function distance
[0127] Select the components of α * in a certain range between 0 and C Calculate
[0128]
[0129] In the formula, b[[ID=5x]] * is the threshold, α * is the Lagrange multiplier, y i is the function distance.
[0130] (3) Find the hyperplane to obtain the decision function, that is
[0131]
[0132] In the formula, f(x) is the decision function, b * is the threshold, α * is the Lagrange multiplier, y i is the function distance.
[0133] Since the Gaussian kernel function has strong learning ability, a wide convergence domain, and is not affected by the dimension and the number of samples, the kernel functions mentioned in the present invention are all Gaussian kernel functions, that is
[0134]
[0135] In the formula, z is the center of the kernel function, and |x - z| 2 is the Euclidean distance between vector x and vector z, and g is the width parameter of the Gaussian kernel.
[0136] Step S450: The LSABO algorithm is iterated to approach the optimal solutions of the two parameters until the maximum number of iterations is reached.
[0137] Step S460: Output the optimal solution within the number of iterations, and use the optimized parameters to train the support vector machine to obtain the zero-flow detection model for the ultrasonic water meter.
[0138] Identify the oscillations and reverse flow phenomena generated in the pipeline caused by the valve closing in the collected data. Part of the information of the time difference data set is listed in Table 1, and part of the information of the statistic is listed in Table 2.
[0139] Table 1 Time difference data set
[0140]
[0141]
[0142] Table 2 Statistic data set
[0143]
[0144]
[0145] Among them, label 1 is the time difference data before closing the valve, which is non-zero flow; label 2 is the time difference data after closing the valve, which is zero flow.
[0146] (2) Divide the data set
[0147] Take 70% of the data in the data set as the training set, and the remaining 30% as the test set.
[0148] (3) Model prediction
[0149] Perform zero-flow detection on the time difference statistics of the two categories using the LSABO-SVM algorithm. The confusion matrices of the prediction results of the training set and the test set are as Figure 5 and Figure 6 shown.
[0150] (4) Model comparison
[0151] Compare the zero-flow detection method using the LSABO-SVM algorithm with the zero-flow detection methods using other algorithms. Among them, the algorithms include SVM, ISSA-SVM, and SABO-SVM, and the results are summarized in Table 3.
[0152] Table 3 Comparison of Zero-Flow Detection Model Accuracy
[0153] SVM ISSA - SVM SABO - SVM LSABO - SVM Training set 94.2085% 95.1737% 94.5946% 99.8069% Test set 92.7928% 94.1441% 93.4685% 98.1982%
[0154] (5) Test Results
[0155] Under different flow conditions, compare the cumulative flow results of the zero-flow detection method using the LSABO-SVM algorithm and the ultrasonic water meter without using this detection algorithm when the valve is closed 12 times during the metering period. For specific results, please refer to Table 4:
[0156] Table 4 Test Results
[0157] Flow rate (L / h) Accumulated flow of SW1 (L) Accumulated flow of SW2 (L) Metering error flow (L) 20000 1827.62 1825.57 2.05 6000 575.76 573.83 1.93 800 58.67 57.83 0.84
[0158] Among them, SW1 is the ultrasonic water meter without using the zero-flow detection algorithm, and the cumulative flow is the flow calculated directly from the collected time difference data through flow calculation; SW2 is the ultrasonic water meter using the zero-flow detection algorithm, and the cumulative flow is the flow calculated from the collected time difference data after passing through the zero-flow detection model, identifying the zero-flow time difference and removing it through flow calculation. It can be seen from the table that using this zero-flow detection algorithm can reduce the mismeasurement of the ultrasonic water meter.
[0159] It should be noted that the steps shown in the above process or the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. And although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0160] In this embodiment, a zero-flow detection device for ultrasonic water meters based on machine learning is also provided. This device is used to implement the above embodiment and the preferred implementation manners, and those that have been described will not be repeated. The following terms such as "module", "unit", "sub-unit", etc. can be a combination of software and / or hardware that can achieve a predetermined function. Although the device described in the following embodiments is preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.
[0161] Figure 7 is the structural block diagram of a zero-flow detection device for ultrasonic water meters based on machine learning in this embodiment, as Figure 7 shown, this device includes:
[0162] A data processing module 710, which is used to collect the time difference data of each channel before and after closing the valve at different flow points of a multi-channel ultrasonic water meter based on the measurement principle of a time-difference method ultrasonic flowmeter, classify the time difference data; preprocess the original data, calculate the statistics of each group of time difference data, and construct the statistics into a feature data set;
[0163] The model training module 720 is used to initialize the parameters of the improved subtraction average optimizer, set the maximum number of iterations, population size, and chaotic mapping parameters; determine the value ranges of the penalty parameter c and the Gaussian kernel function parameter g of the support vector machine; divide the feature data set into a training set and a test set, use the root mean square error between the predicted value and the actual value as the fitness function, and the parameters corresponding to the lowest fitness value are the optimal solutions; iteratively search for the optimal solutions of the penalty parameter c and the Gaussian kernel function parameter g until the maximum number of iterations is reached; output the optimal solutions of the penalty parameter c and the Gaussian kernel function parameter g after iteration, and use the optimized parameters to train the support vector machine to obtain the zero-flow detection model of the ultrasonic water meter;
[0164] The flow detection module 730 is used to perform zero-flow detection of the ultrasonic water meter based on the zero-flow detection model of the ultrasonic water meter.
[0165] It should be noted that the above-mentioned various modules can be functional modules or program modules, and can be implemented either by software or by hardware. For the modules implemented by hardware, the above-mentioned various modules can be located in the same processor; or the above-mentioned various modules can also be located in different processors in any combined form.
[0166] In this embodiment, an electronic device is further provided, including a memory and a processor. A computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0167] Optionally, the above-mentioned electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the above-mentioned processor, and the input / output device is connected to the above-mentioned processor.
[0168] Optionally, in this embodiment, the above-mentioned processor may be configured to execute the following steps through a computer program:
[0169] S1. Based on the measurement principle of the time-difference method ultrasonic flowmeter, collect the time-difference data of each channel before and after closing the valve at different flow points of the multi-channel ultrasonic water meter, and classify the time-difference data;
[0170] S2. Preprocess the original data, calculate the statistics of each group of time-difference data, and construct the statistics into a feature data set;
[0171] S3. Initialize the parameters of the improved subtraction average optimizer, set the maximum number of iterations, population size, and chaotic mapping parameters;
[0172] S4. Determine the value ranges of the penalty parameter c and the Gaussian kernel function parameter g of the support vector machine;
[0173] S5. Divide the feature data set into a training set and a test set, use the root mean square error between the predicted value and the actual value as the fitness function, and the parameters corresponding to the lowest fitness value are the optimal solutions.
[0174] S6. Iteratively search for the optimal solutions of the penalty parameter c and the Gaussian kernel function parameter g until the maximum number of iterations is reached.
[0175] S7. Output the optimal solutions of the penalty parameter c and the Gaussian kernel function parameter g after iteration, and use the optimized parameters to train the support vector machine to obtain an ultrasonic water meter zero flow detection model.
[0176] S8. Based on the ultrasonic water meter zero flow detection model, perform ultrasonic water meter zero flow detection.
[0177] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation manners, and will not be elaborated in this embodiment.
[0178] In addition, in combination with the ultrasonic water meter zero flow detection method based on machine learning provided in the above embodiments, a storage medium can also be provided in this embodiment to implement it. A computer program is stored on the storage medium; when the computer program is executed by a processor, any one of the ultrasonic water meter zero flow detection methods based on machine learning in the above embodiments is implemented.
[0179] It should be understood that the specific embodiments described here are only used to explain this application, rather than to limit it. According to the embodiments provided in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the protection scope of the present application.
[0180] Obviously, the accompanying drawings are only some examples or embodiments of the present application. For those of ordinary skill in the art, the present application can also be applied to other similar situations according to these drawings without creative efforts. In addition, it can be understood that although the work done during this development process may be complex and time-consuming, for those of ordinary skill in the art, certain design, manufacturing, or production changes based on the technical content disclosed in the present application are only conventional technical means and should not be regarded as insufficient disclosure of the present application.
[0181] As used in this application, the term "embodiment" means that the specific features, structures or characteristics described in connection with an embodiment may be included in at least one embodiment of this application. The phrase appears in various places in the specification and does not necessarily mean the same embodiment, nor does it mean being independent or alternative to other embodiments and mutually exclusive. Those of ordinary skill in the art can clearly or implicitly understand that the embodiments described in this application can be combined with other embodiments without conflict.
[0182] The above-described embodiments merely represent several implementation manners of this application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation on the scope of patent protection. It should be noted that for those of ordinary skill in the art, without departing from the concept of this application, several variations and improvements can still be made, and these all fall within the protection scope of this application. Therefore, the protection scope of this application shall be subject to the appended claims.
Claims
1. An ultrasonic water meter zero flow detection method based on machine learning, characterized in that, The method includes: Based on the measurement principle of the time-difference ultrasonic flowmeter, collect the time-difference data of each channel before and after closing the valve at different flow points of the multi-channel ultrasonic water meter, and classify the time-difference data; Preprocess the original data, calculate the statistics of each group of time-difference data, and construct the statistics into a feature data set; Initialize the parameters of the improved subtraction average optimizer, and set the maximum number of iterations, population size, and chaotic mapping parameters; Determine the value ranges of the penalty parameter c and the Gaussian kernel function parameter g of the support vector machine; Divide the feature data set into a training set and a test set, use the root mean square error between the predicted value and the actual value as the fitness function, and the parameters corresponding to the lowest fitness value are the optimal solutions; Iteratively search for the optimal solutions of the penalty parameter c and the Gaussian kernel function parameter g until the maximum number of iterations is reached; Output the optimal solutions of the penalty parameter c and the Gaussian kernel function parameter g after iteration, and use the optimized parameters to train the support vector machine to obtain a zero-flow detection model for the ultrasonic water meter; Based on the zero-flow detection model of the ultrasonic water meter, perform zero-flow detection of the ultrasonic water meter.
2. The ultrasonic water meter zero flow detection method based on machine learning according to claim 1, characterized in that The statistics include the mean absolute value, mean absolute deviation, standard deviation, skewness coefficient, and kurtosis coefficient.
3. A zero-flow detection method for an ultrasonic water meter based on machine learning according to claim 1, characterized in that, The method further includes: Set the number of iterations, the number of the population, and the parameter search range; Use the data generated by the chaotic mapping as the initial position information of the population; Calculate the fitness value of the initial population, use the root mean square error between the predicted value and the actual value as the fitness value for evaluating each individual in the initial population, and record the current optimal solution and the worst solution; Dynamically update the particle positions; Update the population fitness value, reorder and update the global optimal solution.
4. A zero-flow detection method for an ultrasonic water meter based on machine learning according to claim 1, characterized in that, The performing zero-flow detection of the ultrasonic water meter based on the zero-flow detection model of the ultrasonic water meter includes: Collect the time-difference data of each channel of the multi-channel ultrasonic water meter to be detected; Input the time-difference data into the zero-flow detection model of the ultrasonic water meter; According to the result output by the zero-flow detection model of the ultrasonic water meter, remove the zero-flow data from the time-difference data.
5. A zero-flow detection method for an ultrasonic water meter based on machine learning according to claim 1, characterized in that, The classifying the time-difference data includes: according to the recorded valve closing time and the time stamp of the collected data, divide the time-difference data into the time-difference data before closing the valve and the time-difference data after closing the valve.
6. The ultrasonic water meter zero flow detection method based on machine learning according to claim 1, characterized in that, The improved subtraction average optimizer is a subtraction average optimizer improved based on chaotic mapping and dynamic perturbation.
7. A zero-flow detection method for an ultrasonic water meter based on machine learning according to claim 1, characterized in that The time-difference data is the time difference between the downstream and upstream propagation times of ultrasonic waves in water.
8. An ultrasonic water meter zero flow detection device based on machine learning, characterized in that, The device includes: A data processing module, configured to collect the time-difference data of each channel before and after closing the valve at different flow points of the multi-channel ultrasonic water meter based on the measurement principle of the time-difference ultrasonic flowmeter, classify the time-difference data; preprocess the original data, calculate the statistics of each group of time-difference data, and construct the statistics into a feature data set; The model training module is used to initialize the parameters of the improved subtraction average optimizer, set the maximum number of iterations, population size, and chaotic mapping parameters; determine the value ranges of the penalty parameter c and the Gaussian kernel function parameter g of the support vector machine; divide the feature data set into a training set and a test set, use the root mean square error between the predicted value and the actual value as the fitness function, and the parameters corresponding to the lowest fitness value are the optimal solutions; iteratively search for the optimal solutions of the penalty parameter c and the Gaussian kernel function parameter g until the maximum number of iterations is reached; output the optimal solutions of the penalty parameter c and the Gaussian kernel function parameter g after iteration, and use the optimized parameters to train the support vector machine to obtain the zero-flow detection model of the ultrasonic water meter. The flow detection module is used to perform zero-flow detection of the ultrasonic water meter based on the zero-flow detection model of the ultrasonic water meter.
9. An electronic device, comprising a memory and a processor, characterized in that, A computer program is stored in the memory, and the processor is configured to run the computer program to execute a machine learning-based ultrasonic water meter zero-flow detection method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of a machine learning-based ultrasonic water meter zero-flow detection method according to any one of claims 1 to 7.
Citation Information
Cited By
Flow measurement method based on support vector machine and electromagnetic flowmeter
CN121140887A