Risk‐Constrained Optimal Scheduling in Water Distribution Systems Toward Real‐Time Pricing Electricity Market

In recent years, as a result of emerging renewable energy markets, several developed regions have already launched Real‐Time Pricing (RTP) strategies for electricity markets. Establishing optimal pump operation for water companies in RTP electricity markets presents a challenging problem. In a RTP market, both positive and negative electricity prices are possible. These negative prices create economically attractive opportunities for Water Distribution System (WDS) to dispatch their energy consumption. On the other hand, excessively high prices may put WDS at risk of supply disruptions and reduced service levels. However, the continuous development of wind power and photovoltaics results in more volatile and unpredictable fluctuations in the price of renewable energy. The risk arising from uncertainty in electricity prices can lead to a significant increase in actual costs. To address this issue, this paper develops an a posteriori random forest (AP‐RF) approach to forecast the probability density function of electricity prices for the next day and provide a risk‐constrained pump scheduling method toward RTP electricity market. The experimental results demonstrate that the developed method effectively addresses the issue of increased costs caused by inaccurate electricity price forecasting.


Introduction
With the rapid development of the renewable energy industry, the energy structure of society is undergoing substantial changes (Carrasco et al., 2006;Yang et al., 2023).Although renewable energy is clean and regenerative, the significant uncertainties in wind and solar power generation can result in a mismatch between supply and demand of electricity, which impose challenges for utilizing energy sources (Zakeri & Syri, 2015).The demand side of power system management or demand response (DR) that actively adjust electricity consumption on the demand side to match the electricity supply is an important means to provide balancing services to the energy system (Al-Nory & Brodsky, 2014).Several studies have explored the participation of water companies in DR by procuring electricity from the energy spot market to manage energy cost.For instance, Zimmermann et al. (2018) investigated the potential cost savings at water treatment and pumping stations by procuring power from the day-ahead German energy spot market.At the incentives of grid, Liu et al. (2020) proposed incorporating DR scheme frame into the operation of Water Distribution System (WDS) to earn compensation.
In addition to that, implementing Real-Time Pricing (RTP) strategies on the supply side is another important reform (Li et al., 2022;Wang et al., 2018).RTP diverges from traditional tiered or fixed electricity price (Broad et al., 2005(Broad et al., , 2010;;Kurek & Ostfeld, 2014), which are based on prices that are fixed for months or years at a time to reflect average.Under RTP, electricity consumers face prices that fluctuate over short intervals, typically on an hourly basis.Quotations are provided in advance, a day ahead, or in even shorter timeframes, to reflect the contemporaneous marginal supply costs.Several developed regions, such as the United States, Australia, and European countries, have already launched RTP strategies (Allcott, 2011;Fernandez et al., 2017;Khezri et al., 2021;Wang et al., 2015).A survey of utility experience indicated that more than 70 utility companies in the United States have voluntarily adopted RTP tariffs on a pilot or permanent basis, spanning fields such as gas, heating, cooling, transportation, and electricity (Barbose et al., 2004).The motivations for participating in RTP tariffs are manifold.Primarily, the introduction of RTP aims to provide electricity consumers the opportunity to reduce their bills.In certain scenarios, this can even result in negative electricity prices, where consuming electricity leads to additional financial returns from the power grid.Participation in RTP requires capabilities to either curtail demand during peak electricity usage times or the shifting of energy consumption to periods with lower demand.Utilities generally possess energy storage facilities to facilitate load shifting.
Water Distribution Systems (WDS) are an important component of urban infrastructures, accounting for approximately 2%-3% of global energy consumption (James et al., 2002) with up to 70% of energy consumption being used to maintain WDS operations (Nault & Papa, 2015).The water company, being a major consumer of energy, is ideally positioned to capitalize on favorable pricing conditions during periods of energy surplus, and to strategically avoid the risks associated with energy shortages, and associated high energy prices.Possessing the strategic capability to modify pumping schedules by using storage infrastructure, water companies are wellequipped to participate in the competitive energy marketplace.This engagement has the potential to substantially reduce operational expenditures and bolster their financial margins.The financial benefits can be directed toward infrastructure investment, thereby improving service and benefiting water users (Housh et al., 2022).
By conducting several unstructured interviews with water network managers, a forum pointed out new opportunities in the energy spot market for water utilities (Housh et al., 2022).For instance, in Belgium, water companies have the option to purchase electricity from suppliers in the futures market (e.g., Ice Endex), and profit from real-time energy balancing prices, while assisting in the equilibrium of energy supply and demand.In Berlin, water companies can secure long-term energy contracts that extend for several years into the future.In Australia, water utilities can purchase energy on the spot market.Xcel Energy (Public Service Company of Colorado) also has one large customer, a municipal water board, who is receiving service under a special contract that incorporates RTP-based pricing features (Barbose et al., 2004).A positive example of utilizing spot pricing for energy procurement is the case of South Australian Water Corporation, which has significantly reduced its pumping costs by 20% annually, from 15 million to 12 million AUD (GE, 2015).However, electricity markets that rely on RTP within the renewable energy sector can display a dynamic range of electricity costs, occasionally dipping into negative prices during periods of excess supply.Especially, the negative prices construct economically attractive opportunities for energy consumers, who can adjust and change their energy demand on the fly.Conversely, these markets may also experience substantial price spikes during times of energy scarcity.Such volatility inherent in RTP can lead to instability, where excessively high energy costs pose a significant risk to consumers, potentially leading to supply interruptions and a decline in service quality.Despite an increasing awareness among water utilities of the potential benefits offered by new market dynamics, there remains a prevalent gap in the requisite knowledge and technical capabilities to effectively engage with RTP model.
Electricity consumption is one of the largest operational costs for water utilities and a primary cost associated with operating WDS (Mala-Jetmarova et al., 2017).Thus, pump scheduling optimization is an effective approach to save operating costs, manage network pressure, and provide good water service for users.Pump optimization involves either direct or indirect control over pump scheduling, such as setting the times for on/off states or modifying the pump speed within given scheduling period (Ormsbee et al., 2009).Optimal pump scheduling under the tiered or fixed electricity price has attracted considerable attention from researchers who have considered various modeling approaches (such as hydraulics and water quality), optimization formulations (i.e., decision variables, objectives, and constraints), and solution methods (i.e., classical, evolutionary, or hybrid algorithms) (Dini et al., 2022;Lopez-Ibanez et al., 2008;Luna et al., 2019;Mehzad et al., 2019).Research in the field of water system analysis has primarily focused on the modeling aspects and algorithmic complexity in addressing the pump scheduling problem.Various approaches have been proposed to deal with the non-linear and integer variable problems of pump scheduling (Alvisi & Franchini, 2017;Housh & Salomons, 2019;Marchi et al., 2016;Salomons et al., 2020;Wang et al., 2021).The above research adopts the Mixed-Integer Linear Programming (MILP) method to solve the issue.Compared to heuristic algorithms, MILP methods use explicit mathematical programming formulas to solve the WDS operation problem.By describing the problem as a MILP model, these methods offer several advantages, including (a) avoiding complex parameters optimization as in the heuristic algorithm.(b) eliminating the non-convexity of original problem and providing a lower bound.The lower bound offers an estimation of the minimal objective function value attainable by the optimal solution, thereby assessing the solution's quality.(c) providing stable results that facilitate sensitivity analysis, avoiding the inherent disadvantage of heuristic algorithms where it is challenging to distinguish whether changes are caused by inside randomness of the method or sensitivity of the model variables or parameters.MILP approach is not without its drawbacks.The necessity for primary problem to complete linear relaxation introduces computational inaccuracies.Moreover, the MILP method often encounters computational inefficiency when applied to largescale problems, reflecting limitations in its scalability and efficiency.But the long running time is also a drawback of heuristic algorithms, and its scaling is even a more difficult challenge.
Previous research has largely circumvented the volatility of electricity prices in the spot energy market, assuming predetermined and deterministic electricity pricing.It is apparent that the highly volatile real-time prices pose a significant challenge for the optimization of WDS.If these opportunities are fully leveraged and the challenges adeptly navigated, water companies can become active participants in the RTP model.In the study of optimal scheduling for WDS, water companies generate dispatch plans based on predicted electricity prices from Day-Ahead Markets (DAM).However, the dispatch plan is contingent on the actual electricity prices on the following day.If the forecast price curve is inaccurate, the actual real-time price curve could deviate substantially from the predicted one.This discrepancy can result in the actual costs of the dispatch plan for the next day being higher than its forecast.Consequently, the risk associated with the uncertainty of electricity price forecasting should be considered in dispatch planning (Eck et al., 2014;Perelman et al., 2023).Yet, the domain of WDS scheduling lacks comprehensive research in this area, particularly in accounting for the intricacies of price prediction risks within dispatch strategies.
The establishment of an electricity price uncertainty model is crucial for water companies to control risk cost.Conditional value-at-risk (CVaR) is a widely used risk assessment measure in finance and economics (Rockafellar & Uryasev, 2002).It estimates the potential losses that may occur beyond a certain threshold and measures the expected value of the worst-case losses that exceed a given confidence level.CVaR is commonly used in portfolio optimization and risk management to control the downside risk of a portfolio (Zhu & Fukushima, 2009).Subsequent literature has extensively studied commodity or energy trading (Dahgren et al., 2003), operational optimization of microgrid aggregators (Nguyen & Le, 2015), and uncertain trading of renewable energy power generation (Botterud et al., 2012).The CVaR approach prioritizes worst-case scenarios instead of minimizing energy consumption costs based on probabilistic expectations.This helps prevent unexpected and unacceptable outcomes in highly risky situations.This study has applied the CVaR method to manage risks in water distribution network scheduling within the context of the RTP electricity market.
This study proposes a framework to assess the risk cost brought by the prediction uncertainty of the electricity price, and provide a risk-constrained optimal WDS scheduling method for water companies to make informed decisions.Specifically, this paper develops an A Posteriori Random Forest (AP-RF) to forecast the Probability Density Function (PDF) of electricity prices for the following day.Sampling and clustering on the PDF are then conducted to generate typical scenarios, which are fed into a risk-constrained optimization scheduling model.The model achieves the assessment of cost expectations and CVaR under various risk preferences within the optimal scheduling framework.This paper is structured as follows: Section 2 describes the research method for developing a risk assessment framework for the optimal operation of a WDS under uncertain electricity prices.Section 3 presents data set description of electricity market and WDS, and the simulation results of two networks.Section 4 provides a discussion about the uncertainty of water demand and the characteristics of the water supply system.Finally, Section 5 provides a summary and conclusions of the study.

Materials and Methods
The risk management framework is comprised of two parts: (a) the electricity price forecast model and (b) the risk-constrains optimal scheduling model, as shown in Figure 1.In a RTP electricity market, accurate electricity price forecasting has become a crucial requirement.However, since the impact of natural factors, the uncertainty of renewable energy power generation makes it harder to predict electricity prices accurately.To address this issue, this study developed AP-RF approach to forecast the PDF of electricity prices for the next day.Considering the trade-off between computational complexity and model accuracy, 100 electricity prices scenarios are sampled from the PDF, and these scenarios are fed to risk-constrains optimal scheduling model to optimize the scheduling solution.For simplicity, the notations associated with the optimization model are summarized in Table 1.The maximum number of switches

Electricity Price Forecast
In this section, this study generates the PDF of electricity prices for the next day using AP-RF approach based on the historical price data set.Then using a Latin Hypercube Sampling (LHS) method to sample a large number of scenarios from the PDF.Each electricity scenario is used to generate a scheduling plan through the optimization model described in Section 2.2, which can be a time-consuming process.To improve computation efficiency, we develop a scenario reduction strategy to reduce the number of scenarios.
The historical data set can be derived from a real or simulated electricity market, which includes demand load, renewable energy output (weather), day-ahead market (DAM) prices, balancing market (BM) prices, historical electricity price and DAM Bid/Ask Curves.These data sets should include the main historical electricity market characteristics in order to accurately forecast electricity price for next scheduling period.

A Posteriori Random Forest Approach (AP-RF)
Random Forest (RF) is a predictive algorithm based on tree structure (James et al., 2021), which is based on two main techniques, Classification and Regression Tree (CART) and bagging (Mei et al., 2014).A simple diagram of CART can be found in Figure 2, illustrating if-else logical decision in each node.The advantage of CART is to fit the data well, but its disadvantage is low deviation and high variance.To solve the problem, RF refines CART by introducing bagging, specifically: (a) RF fits numerous CART models using bootstrap sets sampled from the original data set through the sampling with replacement strategy; (b) it aggregates all trees to generate forecast values on average.The brief pseudo-code of the RF algorithm is as follows: 2. m features are randomly selected from d. Based on the m features randomly selected from Η t , a decision tree h t (x) is obtained by using decision tree model.
Let Ŷi (x) be the prediction of the i th random forest tree.Then output Ŷ However, simple numerical forecast cannot provide a probability forecasting of the electricity price, which can estimate the risk of decision-making.To address this issue, the approach of AP-RF is used.This approach introduces the distribution that can provide confidence intervals from the forecast.Specifically, for the prediction variable X, a RF with N trees will produce N prediction observation subsets {y ∈ Y|T i (x)}.Instead of using the average approach to calculate the aggregate measures of each tree {y ∈ Y|T i (x)}, this approach aggregate them into {y ∈ Y|T i (x) } , to estimate the parameters of PDF for the predicted values, as in Equation 1: where Θ represents a kernel density approach to estimate the electricity price Y, using the value observed by each decision tree.The AP-RF employs Gaussian estimation (Y|x = X ) for a multitude of prediction decision trees (x = X ), which enables representation of greater amounts of information and uncertainty.For the price density distribution, it can not only calculate the expectation to represent the predictive value, but also utilize random sampling for scenarios simulation.Figure 3 illustrates the principle of AP-RF.
The traditional RF approach generates an average value of the predictions.
Comparatively, a AP-RF generates a set of observations Y, which is used to describe a posteriori distribution Θ(y) based on a bootstrap set sample.
Therefore, the predictions of these decision trees ).These can then be used to build confidence intervals according to the prediction.Specifically, it can estimate the PDF of the predicted variable Y using the kernel density approach, and then obtain the corresponding confidence interval based on the confidence level α and probability distribution function, as in Equations 2 and 3. (2) It is worth noting that bagging samples are employed to train the AP-RF approach.The advantage is that only 63.2% of the original data samples are used for training, while the remaining 36.8% of the samples are automatically turned into test sets.This approach avoids unnecessary repetition and overfitting in the training data, and reduces the computational cost.

Latin Hypercube Sampling and Scenario Reduction
This study adopts the AP-RF to forecast the PDF of the electricity prices.LHS is utilized to generate a sufficient number of scenarios by sampling from the PDF of electricity prices (Shields & Zhang, 2016).Each electricity scenario can be used to generate a scheduling plan.The core idea of sampling is to divide the cumulative probability curve into several equal intervals on the [0,1] scale, and then randomly sampling from each interval.It can ensure that every interval of samples is taken to ensure the comprehensiveness of the samples, without ignoring the small probability risk scenarios.Each electricity scenario will be used to generate a scheduling plan by the method illustrated in Section 2.2.This can be very time-consuming due to the large of number of electricity scenarios.To address this problem, this study develops a scenario reduction strategy to reduce the number of scenarios.The large number of scenarios generated by LHS are fed to the K-means clustering algorithm to output a certain typical scenarios and probability.
The principle of the scenario reduction strategy is to reduce the number of scenario sets ϕ generated by LHS to a representative subset φ that contains as much statistical information as possible.This is achieved by iteratively assigning each scenario to a cluster based on the proximity of its features to the cluster center.The K-means algorithm then recalculates the cluster center based on the new assignments and repeats the process until convergence.The objective function of K-means is to minimize the sum of squared distances between each scenario and its assigned cluster center.The expression for this objective function Equation 4 is as follows: Where u i is a vector of price scenario; ρ i is the probability density value of u i ; d(u i ,u j ) is the Euclidean distance between two scenario.After calculating the sum of Euclidean distances between each pair of scenarios, the scenarios with the smallest sum of distances are selected for retention.These reduced scenarios have different significant characteristics, and the sum of probabilities for all scenarios is 1.

Objective Functions
Given an electricity price scenario, the electricity cost of all pumps in the whole scheduling period is shown in Equation 5. Detailed parameters are shown in table 1.
Equation 5 gives the pump cost under scenario s.Given a set of electricity price scenarios generated by sampling from the forecast PDF, the PDF of the cost of these scenarios is shown as shown in Figure 4.The expectation cost is computed by a weighted sum of the costs (cost s ) based on their probabilities p s , as shown in Equation 6. Existing studies generally use the expectation cost to evaluate the quality of a solution.
However, the uncertainty of the price forecast allows for a certain probability that the electricity actual price will be much higher than the expectation price, making the actual cost much higher than expected (the right-hand tail of the PDF shown in Figure 4), which is commercially unacceptable.In the context of renewable energy power generation, the risk is unavoidable.Therefore, risk management is usually necessary to deal with accidents (moments with failed forecasts) and avoid paying unreasonable fees.Optimal scheduling under electricity price prediction uncertainty is a risk-averse decision-making strategy.
This study adopts CVaR method to measure risk arising from uncertainty in the prediction of the electricity price.The CVaR method is defined as the ultra-expected value of the cost greater than the (1 α) quantile of the cost distribution under α confidence level.Specifically, the value at risk (VaR α ) is defined as the scheduling cost at the (1 α) quantile of the distribution, as shown in Figure 4, representing a cost that will not be exceeded under 1 α probability.A cost exceeding VaR α means a risk, which is quantified by the deviation from the cost to VaR α .
As shown in Equation 7, θ s represents an additional risk costs and cost s is the energy cost of Sth price scenario.If the energy cost exceeds VaR α (cost s ≥ VaR α ), the risk cost θ s is computed by deviation from the cost to VaR α ; otherwise, the risk cost θ s is set to 0, indicating that there is no risk cost.Therefore, the expectation cost of rare risk scenarios in which the cost exceeds the given VaR α criterion can be computed by Equation 8.
The objective function can be written as Equation 9: where β is the risk aversion preference parameter, which is introduced to measure the attitude of WDS operators toward risk.β equals 0 represents risk neutral, where the degree of risk aversion increases with the increase of the parameter.For α confidence level with ∀α ∈ (0,1), objective function Equation 9 minimizes the sum of costs under scenario S and conditional value at risks under the worst scenarios (greater than VaR α ).It can be increased with higher values of β.The first part of the formula represents the operational costs under RF prediction (optimal if predictions are accurate), while the latter part addresses potential risks from uncertainty (extreme scenarios under prediction failure).By employing the same set of decision variables for hedging against prediction inaccuracy, decision makers adjust the risk aversion β to control the weights, with a higher β indicating less reliance on RF predictions to guard against uncertainty.
The objective function Equation 9 aims to minimize the total energy consumption, subject to operation constraints Equations 10-37 to guarantee feasibility.

Constraints and Linearizations
This paper constructs a WDS optimal scheduling model, which is subject to constraints, operation management constraints and CVaR constraints, to minimize the sum of expected costs and potential risks from uncertainty (see Section 4).
The risk-constrained optimization scheduling model, as discussed previously, is a nonlinear mixed integer programming (MINLP) problem.The main nonlinear equations including: (a) the pipe headloss equation, (b) the pump head curve equation, and (c) the pump power equation.It can be solved by linear relaxation as the MILP problem.Then the MILP problem can generally be solved by some commercial solver, such as Gurobi, CPLEX Optimizer and so on.For Details about the MILP model of WDS operation optimization, please refer to the literature (Liu et al., 2020).Briefly, the sets, parameters and variables in MILP operation optimization model are summarized in Table 1.

Pipe Constraints
The flow through an pipe consumes energy and therefore leads to a pressure drop (or headloss) in the pipe.The pipe's headloss (or pressure drop) is described by the Hazen-Williams formula, written as Equation 10.
The Hazen-Williams formula is a nonlinear equation and should be linearized by convex relaxation.The following linear equations and inequalities Equations 11-17 can be adopted to linearized Equation 10.

Pump Constraints
Pump head curve represents energy supply and consumption for the whole WDS.The pump head curve is a nonlinear Equation 18, where λ 1 , λ 2 and λ 3 belong to a pump's characteristics coefficients.
Water Resources Research 10.1029/2023WR035630 ZHOU ET AL.
Similarly, the convex relaxation technique is used to approximate the pump head curve, as the following system of linear equations and inequalities Equations 19-22: In addition, it approximates the pump power Equation 23(i.e., load) as a first-order Equation 24of the pump head by interpolating the head-efficiency curve from the EPANET file.

Check Valve Constraints
The role of the check valve to prevent water backflow from the high head when it is closed.By introducing the binary variable, Z v,t ϵ{0,1} represents the status (i.e., closed, open) and flow directions, as the following constraints Equations 25-27:

Tank Constraints
Tanks have two functions in a WDS.One is water storage and regulation, and the other is their water conservation during the scheduling period.Suppose that WDS is steady state within each time step, this study linearizes tank constraints by using explicit Euler method for integration.Constraints Equations 28-31 represent the functions of the water tank.

Network Constraints
Equations 32 and 33 are constructed to maintain the water flow and energy conservation from the perspective of the whole network, ensuring system balance.
Water Resources Research 10.1029/2023WR035630 ZHOU ET AL.

Operational Constraints
Switching too frequently increases management costs, so it is necessary to limit it.The pump switching is defined as a user-defined constraint, which provides greater flexibility for WDS operators to make real-world decisions using the optimization model.By limiting SW max p , constraints Equations 34-37 can effectively manage pump station.

History Electricity Price Data Set Description and Water Distribution System
The data set utilized in this study is derived from Ireland's Electricity, which is traded on the Integrated Single Electricity Market.This was launched on 01.10.2018 and brought the Irish electricity market in line with the rest of Europe (ElectroRoute, 2019), which can be considered as a blueprint for an integrated electricity market in Europe.The data set is from 12.11.2018 to 12.07.2020,as shown in Figure 5.In addition to Day-Ahead Market (DAM) Prices, DAM Bid/Ask Curves (SEMOpx, 2020), the data set also includes BM Prices, Wind Forecast, Demand Forecast (SEMO, 2020).
In numerical experiments, this study selected two benchmark networks, Richmond Skeleton network and C-Town network, as shown in Figure 6.Richmond Skeleton network consists of 48 nodes, 6 tanks and 51 arcs, including 7 pumps, three valves and a reservoir (van Zyl et al., 2004).The other larger benchmark network is C-Town network (Creaco et al., 2014), which comprises 11 pumps, 7 tanks, 4 valves, 388 nodes, and 429 pipes.Assume that the scheduling period is one day, divided into 24 equal time steps.Computational experiments based on the aforementioned model frame have been conducted, with the results and analysis presented in Section 3.2 and 3.3.
In this section, this study describes the performance of the framework through computational experiments.As discussed previously, optimal scheduling for WDS is a nonconvex mixed-integer nonlinear programming (MINLP) problem, which can be converted into linear relaxation into a MILP problem.The models were programmed in Python, and the MILP formulas were run using GAMS and solved with CPLEX on the machine equipped with Intel(R) Core(TM) i5-6200U CPU @ 2.30 GHz.This study assumed the unit period to be 1 hour and set 24 hr as the full scheduling period.Computational experiments verify the modeling ability of the proposed framework for the power market with uncertainty.We set the convergence criterion with an optimality gap of 10% to improve calculating efficiency.Due to the presence of marginal effects for the confidence level α and risk aversion degree β in this method, the optimal risk preference parameters chosen for this study are α = 0.9 and β = 1.Detailed research on this can be found in the supplementary materials.

Results of Scheduling Costs
This paper applied historical data to predict the electricity price for a week (24.2.2020 to 1.3.2020)using the developed AP-RF approach.The predicted PDF of the electricity price is shown in Figure 7a.As the green color deepens, the probability density increases, indicating high prediction certainty.Red line is the observed actual value and yellow line is the predicted value.It can be observed that the majority of the predictions are highly accurate, but there are several visible predicted deviations within light green box, and greatly increased uncertainty during the tested scheduling period of 72-96 hr (within the red box).This is because electricity prices exhibit a relatively smooth time series most of the time, in which case the proposed price forecast algorithm is effective.However, in the red box, the volatility of electricity prices exceeds that of any other time in history, making it difficult for the forecasting algorithm to accurately predict electricity prices.In the period of 91-93 hr (within the green box), the predicted price is much lower than the actual price.In this case, the scheduling scheme based on the predicted price may tend to increase energy consumption in this period, resulting in the actual costs much higher than expectation and giving rise to significant risks.The proposed risk-constrained optimal scheduling method aims to mitigate this risk.For comparison, Figures 7b and 7c present costs of traditional scheduling method (without CVaR).
As shown in Figures 7b and 7c, the scheduling cost of this study will not deviate significantly from the cost of traditional method (without CVaR) in most time series, but the cost has been significantly reduced in the case of inaccurate electric price prediction.When the prediction is accurate, the proposed method will slightly increase the scheduling cost because of considering risk constraints.However, in the event of inaccurate prediction, using the traditional method will greatly increase the scheduling cost (orange line in Figures 7b and 7c).If the risk constraint is considered, the costs will be significantly reduced (blue line).It is observed that, in instances where the hourly costs are similar, the application of the proposed method significantly reduces the cost in the 92nd hr from €13.36 to €6.81 in the Richmond Skeleton network.In the C-town network, a more substantial reduction is observed for the same hour, with costs decreasing from €984.31 to €284.37, attributed to the network's higher power consumption requirements.Consequently, as depicted in Figure 8, on the fourth day when electricity price prediction fails, the proposed method reduces the cost from €91.13 to €83.84.In the Richmond Skeleton network.In the C-town network, the proposed method's advantage brings the cost down from €2,636.57to €2,338.12.Significant reductions are observed in both cases.s Richmond Skeleton network with and without CVaR are €430.132and €432.154respectively; when no forecast failures occur, the daily average cost using the CVaR approach is €0.9.However, in the event of forecast failures, CVaR approach results in a saving of €7.288.For the C-Town network, the corresponding costs with and without CVaR are €13,531.39and €13,622.86;there be no  forecast failures, the daily average cost using the CVaR approach is €34.5, whereas if prediction failures do take place, CVaR results in savings of €298.45.
However, there are two sides to the coin.Usually high risk means high reward, and when decision makers are too risk-averse, it can lead to an increase in overall costs.Figure 8 shows a comparison of the cost per day of the optimal scheduling method of risk-constrained CVaR in this study, as well as the traditional scheduling method.On six of the 7 days, the costs of this study are higher than traditional scheduling method.Therefore, decision-makers have to weigh up the costs of normal circumstances against the costs of risk.The risk attitude of the decision-makers determines the degree of risk tolerance of the scheduling method.As shown in Equation 9, the objective function consists of two parts.The first part minimizes the scheduling cost (p s • cost s ) in normal circumstances, which is the same as the objective of the traditional method (Equation 6); while the second part minimize the risk cost (β ⋅ CVaR α ) under the worst scenarios.Equation 9 assums that the worst scenario is always a possibility at each time step, and its occurrence probability is quantified by α.In each time step, the optimization objective considers the worst scenario with a weight of β.However, in reality, the occurrence of the worst scenario is rare, resulting in higher scheduling costs for most time steps compared to traditional methods.The advantage of this research method lies in its ability to effectively avoid a sharp increase in costs (representing risks) when the worst scenario occurs.Although the expected cost of the developed method maybe higher than traditional methods, it provides a protective mechanism to cope with potential losses from unexpected events or risks.
Further analysis of the forecasted PDF data reveals further insights, as shown in Table 2, which include Root Mean Square Error (RMSE) and the standard deviation (SD) of sample estimates.Prediction failures are not common and can often be inferred from the dispersion degree of the forecasted PDF.On days 1, 2, and 6, where the SD is relatively low, the RMSE is also typically low, indicating higher prediction accuracy.Conversely, on days 3, 4, 5, and 7, where the SD is higher, the RMSE shows variability, indicating potential unpredictability in forecasts -they could be accurate or not.This variability may be attributed to issues within the decision trees of the RF, such as overfitting or noise generated by certain trees, leading to increased SD in model predictions and the presence of a few outliers.However, the advantage of the AP-RF in predicting the PDF lies in expressing the uncertainty of the forecast values, rather than just providing a point estimate.This allows for easier identification and assessment of potential risks and extreme values.

Analysis of WDS's Characteristics
The previous section discussed the advantages of using CVaR to address the risk of inaccurate price forecasts.The above observations suggest that the introduction of the CVaR method can effectively address the issue of increased costs associated with inaccurate forecasting.This can be explained by the electricity load of the pumps.Figure 9 shows the electricity load comparison between this study and the traditional scheduling method during the period of 72-96 hr.In the 92nd hr, the forecast electricity price is lower due to inaccurate prediction of electricity prices.As a result, the traditional method increases the electricity load to 114 KW, which leads to much  Considering the characteristics of the C-Town network, as shown in Figure 10h, it is observed that the water demand in this network tends to be higher in the latter half of the day than in the first half.However, during the period of 91-93 hr of the fourth day (19:00-21:00), electricity prices are at their peak, indicating that most water tanks should either be in a state of discharging or maintaining their levels.Due to constraints of minimum water levels, tank T6 is required to be gradually filled and experiences a rapid rise in water level after 21:00.The restricted storage capacity of tank T6 limits the performance of scheduling strategy in this scenario.
As shown in Figure 11, the water level of the Richmond Skeleton network, where the trends in water tank levels are inversely related to the water demand patterns, and water is added to the tanks during periods of low water consumption periods.Because some of the water tanks (B,D) in the Richmond Skeleton network located at the pipe section junction, necessitating that pumps initially fill these tanks before they distribute water to subsequent nodes.During periods of high node demand pattern, tanks' level declines when they supply water to the network; conversely, during periods of low demand pattern, pumps refill these tanks.The method proposed specifically avoids the peak electricity prices before 21:00 for water intake in tanks C and F. In general, the proposed method can achieve energy consumption shifting and avoid the risks caused by peak electricity prices.

Discussion
This study aims to minimize expected operational costs and the financial risks due to electricity prediction uncertainty.In addition, the uncertainty of water demand and the characteristics of the water supply system, such as available storage, pumping capacity are another factors that should be considered.
The water demand is influenced by variables such as weather, holidays, and user habits.The failure in water demand prediction can notably increase financial costs in scheduling.However, it has been noted that the level of uncertainty expected in energy commodities is greater than the water demand uncertainty (Housh et al., 2022).
Studies have shown that deterministic model predictive control frameworks are robust against water demand uncertainty (Wang et al., 2021), attributed to the low level of uncertainty in water demand and the low risk of adapting to a water shortage.With different energy sources (wind and light energy, etc) operating over various time scales, the level of uncertainty is expected to be high.Accurate prediction of water demand and quantification of its uncertainty, especially when combined with electricity price uncertainty, is an important research area.For instance, if actual water usage exceeds predicted levels and storage is insufficient, requiring increased pumping during high electricity prices, this can significantly raise financial costs.The risk constraint method introduced with the CVaR method in this study is equally applicable to risk control under water demand uncertainty, paving the way for future research exploring RTP optimization under combined uncertainties of electricity prices and water demand.
The characteristics of the water supply system, such as available storage, pumping capacity, and water demand characteristics, significantly influence the feasibility of participating in RTP electricity market.Participation in RTP tariffs necessitates regulation and storage functions, utilizing forecast electricity prices for WDS scheduling.This involves storing water in tanks during periods of low electricity prices and minimizing pump energy consumption when prices are high.Thus, this strategy is greatly influenced by the characteristics of the WDS, particularly the available storage.For instance, (a) water towers built at higher elevations can better utilize gravitational potential energy.(b) Towers situated near water plants or in regions with high water demand can reduce energy consumption due to head loss.3. Additionally, towers with larger capacity or volume possess enhanced regulation and storage capabilities.Similarly, water treatment plant' production capabilities and pumps' capacities are crucial factors, often requiring production beyond immediate needs during low electricity prices.Therefore, assessing the current production and scheduling capabilities of water systems under RTP is a highly pertinent filed of research.

Conclusions
This paper studies the robust pump scheduling problem in WDS under uncertain electricity price.It proposes a conditional value at risk assessment framework that incorporates the variability of electricity market price into WDS scheduling model.The framework forecasts the PDF of electricity prices and turns the uncertainty into certainty problems through scenario generation method.Then a risk-constrained pump scheduling method toward RTP electricity market is developed.The key features of the method are as follows: 1.An AP-RF has been developed, which obtains the PDF at each time.The strength of AP-RF in predicting the PDF resides in its ability to articulate the uncertainty associated with forecast values, as opposed to merely offering a single point estimate.This feature facilitates a more straightforward approach to identifying and evaluating potential risks and extreme values.2. The conditional value at risk pump scheduling method has been employed to limit the uncertainty.By incorporating risk constraints, this method effectively controls costs in the event of electricity price prediction failures, thereby preventing rapid increases in financial expenditure.Upon observing the water levels and demand pattern, it is indicate that the effectiveness of this method is influenced by the characteristics of the WDS.
Despite the opportunities that the energy market creates, few studies have taken the renewable energy markets into account in WDS optimization.Given these circumstances, the current design of the WDS might be suboptimal and may necessitate re-designing elements such as the tanks and secondary pump stations, if justified by suitable cost-benefit analysis.Finding the optimal design scheme and strategy of WDS under RTP electricity market would be an interesting topic for future research.In addition, the research in this paper only focuses on the uncertainty of energy price, but the uncertainty of water demand also significantly impacts WDS scheduling.Therefore, taking the variability of water demand into model to solve the WDS scheduling problem can be explored in future research.

Figure 1 .
Figure 1.Flow chart of conditional value at risk assessment framework for Water Distribution System optimal operation: (a) Electricity price forecast model; (b) Risk-constrained optimization model.

Algorithm 1 :
Random Forest Algorithm Input: training set Η, feature dimension d, The number of randomly selected features m, Decision tree learning algorithm h Output: the ensemble of trees ⋃ N i=1 { y ∈ Y|T i (x)} For t = 1 to T do 1.Using Bootstrap sampling from training set Η to obtain a sample dataset Η t of size n

Figure 2 .
Figure 2. A schematic diagram of Classification and Regression Tree.

Figure 4 .
Figure 4. VaR α and CVaR α definitions of the scenario cost distribution.

Figure 8 .
Figure 8.Comparison of costs between forecast expectation scheme and CVaR model scheme (a) Richmond Skeleton network; (b) C-Town network.

Figure 7 .
Figure 7.The probability density function (PDF) of forecast electricity price and scheduling scheme costs: (a) PDF of forecast electricity price for a week; (b) scheduling scheme costs of Richmond Skeleton network; (c) scheduling scheme costs of C-Town network.

Figure 9 .
Figure 9.The electricity price and load of the pump for the 4-th day: (a) Richmond Skeleton network; (b) C-Town network.

Figure 10 .
Figure 10.C-Town Network Tank Level and Demand Pattern Chart for the 4-th day: (a) Tank T1; (b) Tank T2; (c) Tank T3; (d) Tank T4; (e) Tank T5; (f) Tank T6; (g) Tank T7; (h) Node Demand Pattern (The upper and lower red lines in the tank level charts represent the maximum and minimum water levels).

Figure 11 .
Figure 11.Richmond Skeleton Network Tank Level and Demand Pattern Chart for the 4-th day: (a) Tank A; (b) Tank B; (c) Tank C; (d) Tank D; (e) Tank E; (f) Tank F; (g) Node Demand Pattern (The upper and lower red lines in the tank level charts represent the maximum and minimum water levels).

Table 1 Continued
λ Pump's character coefficients, including λ 1 , λ 2 , λ 3 γ Unit weight of water (KN/m 3 ) η The power efficiency of a pump a H Slope of convex relaxation of a pump curve (s/m 2 ) b H Intercept of convex relaxation of a pump curve (m) a P Slope of the linear approximation of the power of a pump (kW/m) b P Intercept of the linear approximation of the power of a pump (kW) Ω Incidence matrix dt Length of a time step (h) BA Base area of a tank (m 2 ) TL Water level of a tank (m) RL Water level of a reservoir (m) ep Electricity price (€/kWh) Variables d(u i ,u j ) Euclidean distance between two scenario θ s an additional risk costs exceeds VaR for scenario S C s Cost of scenario S when the solved solution is implemented ≥0 Head difference across an operating pump (m) dh of f ϵR Head difference across a closed pump (m) PHϵR Pressure (m) PPϵR ≥0 Pump Power (kW) WϵR ≥0

Table 2
Root Mean Square Error for AP-RF and Standard Deviation of Probability Density Function