Flow prediction method and model
Through the LSTM model combining flow, water level, temperature and other parameters, the downstream water level changes are predicted in real time, solving the problem of regulation delay in long-distance water transmission, and achieving rapid and accurate water volume regulation.
Patent Information
- Application Number
- CN202510474551.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-16
- Publication Date
- 2025-07-29
AI Technical Summary
In the prior art, the upstream gate opening adjustment during long-distance water transfer process requires waiting for downstream water level feedback, resulting in time delay and affecting the regulation timeliness.
The flow prediction method based on the LSTM model is adopted, and the upstream historical data and real-time conditions are used to predict downstream water level changes through the LSTM model, and combined with the flowmeter, water level meter and temperature, evaporation, rainfall and other parameters to achieve real-time flow prediction and regulation.
The closed-loop time is shortened, from hours or days to several minutes, improving the timeliness and accuracy of water volume regulation.
Smart Images

Figure CN120387069A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a flow prediction method and model. Of course, the downstream flow can also be predicted simultaneously. Background Art
[0002] For the regulation of water volume in artificial channels, the opening of the upstream gate is mainly determined by observing the actual downstream water level. If the observation point is far from the gate, it may take a long time, which could be several hours or even many days, depending on the water flow distance between the two. If it takes 2 days for the water to flow from the upstream to the downstream, then it takes 2 to 3 days to stabilize in the closed-loop from opening the gate to data collection. Additionally, for accurate measurement, the water flow needs to be adjusted to the accurate water level, and this process also requires repeated adjustment until the desired effect is achieved. Subsequently, the problem is that to achieve the above effect, a large amount of time is required, but the delay time is long, so it lacks timeliness. Summary of the Invention
[0003] Generally speaking, the technical problem to be solved by the present invention is to provide a flow prediction method and model, which cleverly utilizes the correlation between the upstream and downstream of the channel and the influence of upstream condition changes on the downstream water level, to eliminate the time difference between the upstream and downstream of long-distance water conveyance, predict the downstream water level change in advance, and thus better regulate the water volume of the upstream.
[0004] To solve the above problems, the technical solution adopted by the present invention is as follows:
[0005] For real-time flow prediction of water diversion in a closed long-distance artificial channel, a flow prediction method for an artificial channel with an upstream gate; the method includes the following steps;
[0006] Step 1: First, obtain input parameters, and the input parameters are obtained based on time series;
[0007] The input parameters include: timestamp, historical water levels of upstream and downstream, actual measured water levels of upstream and downstream, historical gate opening time events, actual measured gate opening time events, historical water temperature, actual measured water temperature, historical rainfall and evaporation, actual measured rainfall and actual measured evaporation, and the distance between upstream and downstream measuring stations;
[0008] Step 2: Determine the LSTM model: call the LSTM model algorithm in Python;
[0009] Step 3: Traverse the loss function and loss metrics of the LSTM model; the loss function is based on the mean square error MSE and the mean absolute error MAE;
[0010] Step 4: Adjust the LSTM model in Step 2 according to the set indicators to make the LSTM model optimal; if the set requirements are met, execute Step 5, otherwise return to Step 2 to readjust the LSTM model;
[0011] Step 5: Output real-time information with timestamps according to the conditions input by the LSTM model; the real-time information includes timestamps, real-time upstream and downstream water levels; obtain the real-time flow based on the real-time upstream and downstream water levels.
[0012] For accurate and real-time measurement, the timestamp recording frequency is in minutes.
[0013] Furthermore, for model establishment, in Step 2, first, the LSTM model has the number of units in the LSTM model and the size of the fully connected layer, and is modeled based on the historical data of the input parameters in Step 1; then, call the LSTM model for dataset training; among them, when pre-training the model, determine the optimal values of the number of units and the size of the layer in the LSTM model and use them as preset fixed values.
[0014] Furthermore, for optimal value determination, when determining the optimal value, first, use the same historical data; then, by adjusting the parameters C of the LSTM unit and the parameters D of the layer, whenever one parameter is adjusted, there is a corresponding prediction value, and a total of C*D deviations are obtained; secondly, take the minimum deviation value: Min[a1,a2....ai], i = C*D; thirdly, by comparing the prediction value obtained in Step 5 with the measured value, calculate the deviation, and the closer it is to 0, the better the effect, so as to obtain the optimal LSTM model, and at the same time, the minimum deviation value of the optimal model should meet the set deviation threshold K.
[0015] Furthermore, for LSTM model processing, in Step 4, when comparing whether the set requirements are met, obtain the actual deviation value by comparing the predicted downstream flow with the measured downstream flow based on the historical data, so as to determine whether the correction of the prediction model meets the requirements; if the actual deviation value is less than the set deviation threshold K, it is considered qualified; otherwise, update it to the measured downstream flow and input it into the LSTM model for self-correction of the LSTM model;
[0016] First, based on the LSTM model, obtain the flow prediction value L of the acquirer;
[0017] Secondly, make a judgment based on (L - A) / A = Q;
[0018] where A is the measured downstream flow value;
[0019] If Q <= K, it is determined that the model is established;
[0020] If Q > K, if so, calibrate the measured value A of the downstream flow rate, then return (L - A) / A = Q for re-judgment, if not, return to the initial state and correct the historical data in Step 1.
[0021] In order to provide a prediction device, a flow prediction model includes a flow meter, a water level meter arranged in an artificial channel of a sluice gate, and a model established by the above method.
[0022] Furthermore, in order to realize data acquisition, a thermometer, an evaporation monitoring instrument and / or a rainfall monitoring instrument are provided in the artificial channel;
[0023] The flow meter is electrically connected to the server.
[0024] The beneficial effect of the present invention is that the present invention uses historical data to drive the model, which is a model based on statistics and machine learning. The water level is predicted by analyzing the observed historical data and related historical events. This model uses a large amount of historical data and statistical methods to learn the relationships and laws of the model from the data, directly studies the potential connection between the input data and the output data, and omits the need to focus on the complex hydrological physical processes of the basin.
[0025] Due to the closed artificial channel, its parameter factors are limited, and the model can be corrected by the later measured data. The new model is constantly self-optimizing. With the continuously optimized model and limited influencing factors, the downstream water level change can be accurately predicted using historical data.
[0026] The original adjustment of the sluice gate opening required the feedback of the measured downstream water level. This closed-loop time needed to be determined according to the distance between the upstream and downstream, and the time was in hours or even in days. After using the prediction model of the present invention, it is no longer limited by the distance between the upstream and downstream, and the closed-loop time is extremely short, only taking a few minutes. Description of the Drawings
[0027] Figure 1 It is a schematic diagram of the model establishment steps of the present invention.
[0028] Figure 2 It is a schematic diagram of the system self-optimization and correction training of the present invention.
[0029] Figure 3 It is a schematic diagram of the loss function process of the present invention. Detailed Embodiments
[0030] As Specific Embodiment 1, as Figures 1 - 3 , the model establishment steps: First, obtain a data record of the input quantity. The data record includes: timestamp, rainfall, evaporation, distance between upstream and downstream measurement stations, sluice gate opening, measured water levels of upstream and downstream, and historical water levels of upstream and downstream;
[0031] Recording frequency: One data record can be obtained per minute;
[0032] Then, use the LSTM prediction model: directly call the AI model LSTM in Python;
[0033] Secondly, the output information includes: timestamp, water level, and flow rate;
[0034] The limited parameters of the upstream and downstream channels include: rainfall, evaporation, distance between upstream and downstream gauging stations, gate opening, measured flow rates of upstream and downstream, and historical flow rates of upstream and downstream;
[0035] Data correction: including downstream measured data. Since the model can continuously predict the downstream flow rate based on historical data, the downstream measured data can be compared with the predicted data to determine whether the correction of the prediction model meets the requirements; a deviation of ±10% can be set as qualified. If the deviation is greater than this deviation value, continue to input the newly obtained measured data into the model to complete the self-correction of the model.
[0036] Such as Figure 2 , on the basis of Embodiment 1, in the system self-optimization and correction training, the following steps are included; first, build a model based on historical data; then, call the LSTM model; obtain the predicted value L of the flow rate; secondly, make a judgment based on (L - A) / A = Q; if Q <= 10%, it is determined that the model is established. If Q > 10%, the measured value of the downstream flow rate: A; if it is calibration data, return (L - A) / A = Q for judgment. If not, return to the initial stage and correct the historical data;
[0037] Time series data: A data that exists at each time. For example, in a day with 1440 minutes, there are corresponding water level, flow rate, rainfall, evaporation, and gate opening data for each minute. Such data with timestamps is collectively called time series data;
[0038] In the LSTM model, the number of LSTM model units and the size of the layers are determined to be optimal values during the pre-training of the model, and the subsequent parameters are fixed with the optimal values.
[0039] For example: When using historical data for prediction, when the number of LSTM units is set to 2000 and the number of layers is designed to be 20, the deviation between the predicted value and the measured value is the smallest. Then 2000 and 20 will be used as the fixed values for the entire LSTM production model structure;
[0040] Definition of the optimal value for using the LSTM model for prediction: For the same historical data, then by adjusting the LSTM units and layers, whenever a parameter is adjusted, a corresponding predicted value will be obtained. By comparing the predicted value with the measured value and calculating the deviation, the closer to 0, the better the effect, so as to obtain the optimal LSTM model.
[0041] For example: Under the condition that the input historical data is the same, adjust the LSTM units and layers. The number of units is adjusted from 50 to 60, and the number of layers is adjusted from 10 to 20. Then, 10 * 10 prediction results are used, so there are 100 prediction results. Calculate 100 deviations, and then take the minimum deviation value: Min[a1, a2....a100]. The parameter model that generates the minimum deviation is the optimal model. At the same time, the minimum deviation value of the optimal model must meet the set deviation of ±10% to use this model.
[0042] Example 3 can be based on Example 2, such as Figure 3 mainly for the training of the model, then input the relevant input parameters of Example 1, and finally realize water level prediction.
[0043] Implementation step 1: First, obtain the relevant input parameters of Example 1. The input parameters include: historical water levels of upstream and downstream, historical gate opening time events, historical water temperatures, historical rainfall and evaporation, and the distance between upstream and downstream. The relevant input parameters of Example 1 are obtained based on time series.
[0044] Implementation step 2: First, determine the LSTM model, including the number of LSTM units, the size of the fully connected layer, etc.; perform dataset training;
[0045] Implementation step 3: Traverse its own loss function and loss metrics; the loss function mainly uses mean squared error (MSE) and mean absolute error (MAE);
[0046] Among them, the loss metric is an index used to evaluate the model performance during the training process. Commonly used loss metrics include root mean squared error (RMSE), mean absolute error (MAE), etc. Through these metrics, the performance and optimization direction of the model can be obtained.
[0047] The loss metric is an index used to evaluate the model performance during the training process, while the loss function is the objective function used to train the model. The loss metric is usually used to evaluate the model performance, while the loss function is used to optimize the model parameters to minimize the value of the loss function. The loss metric and the loss function are both indices used to evaluate the model performance, but their purposes and usage scenarios are different.
[0048] Implementation step 4: Adjust the LSTM model according to the set metrics to make the LSTM model reach the optimal; if the set requirements are met, execute step 5, otherwise return to step 2 to readjust the LSTM model;
[0049] Implementation Step Five: Predict the downstream water level according to the real-time conditions input into the LSTM model (including upstream and downstream water levels, upstream gate opening, weather, water level, etc.).
[0050] The present invention is fully described for a clearer disclosure, and the prior art will not be enumerated one by one.
[0051] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; it is obvious for those skilled in the art to combine multiple technical solutions of the present invention. And these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention. The technical content not elaborated in the present invention is all well-known technology.
Claims
1. A traffic prediction method, characterized in that: Prediction method for an artificial channel with a gate upstream; method Comprises the following steps; Step 1: First, obtain input parameters, and the input parameter acquisition is based on a time series; The input parameters include: timestamp, historical water levels upstream and downstream, measured water levels upstream and downstream, historical gate opening time events, measured gate opening time events, historical water temperatures, measured water temperatures, historical rainfall and evaporation, measured rainfall and measured evaporation, and the distance between upstream and downstream measuring stations; Step 2: Determine the LSTM model: Call the LSTM model algorithm in Python; Step 3: Traverse the loss function of the LSTM model; the loss function is based on the mean square error MSE and the mean absolute error MAE; Step 4: Adjust the LSTM model in Step 2 according to the set indicators so that the LSTM model reaches the optimal; if the set requirements are met, execute Step 5, otherwise return to Step 2 and readjust the LSTM model; Step 5: Output real-time information with a timestamp according to the conditions input by the LSTM model; the real-time information includes timestamp, real-time upstream and downstream water levels; obtain the real-time flow based on the real-time upstream and downstream water levels; In Step 2, first, the LSTM model has the number of LSTM model units and the size of the fully connected layer, and is modeled based on the historical data of the input parameters in Step 1; then, call the LSTM model to perform dataset training; among them, when performing pre-training of the model, determine the optimal values of the number of LSTM model units and the size of the layer, and use them as preset fixed values; When determining the optimal values, first, use the same historical data; Then, by adjusting the parameters C of the LSTM unit and the parameter D of the layer, whenever one parameter is adjusted, there is a corresponding prediction value, and a total of C*D deviations are obtained; Secondly, take the minimum deviation value: Min[a1,a2....ai], i = C*D; Thirdly, by comparing the prediction value obtained in Step 5 with the measured value, calculate the deviation, and the closer to 0, the better the effect, so as to obtain the optimal LSTM model, and at the same time, the minimum deviation value of the optimal model should meet the set deviation threshold K; In Step 4, when comparing whether the set requirements are met, compare the predicted downstream flow obtained from the historical data with the measured downstream flow to obtain the actual deviation value, so as to determine whether the correction of the prediction model meets the requirements; if the actual deviation value is less than the set deviation threshold K, it is considered qualified; otherwise, update it to the measured downstream flow and input it into the LSTM model for self-correction of the LSTM model; First, based on the LSTM model, obtain the flow prediction value L; Secondly, make a judgment based on (L - A) / A = Q; Wherein, A is the measured downstream flow value; If Q <= K, it is determined that the model is established; If Q > K, if so, calibrate the measured downstream flow value A, then return to (L - A) / A = Q for re-judgment, if not, return to the initial and correct the historical data in Step 1.
2. The traffic prediction method according to claim 1, wherein: The timestamp recording frequency is in minutes.
3. A traffic prediction model, characterized in that: Includes a flowmeter, a water level gauge in the artificial channel provided with a gate, and a model built based on the method described in claim 1 or 2.
4. The traffic prediction model according to claim 3, wherein: A thermometer, an evaporation monitoring instrument, and / or a rainfall monitoring instrument are provided in the artificial channel; The flowmeter is electrically connected to the server.