**3.1. Simple Genetic Algorithm (SGA)**

GA is a stochastic method of global search that develop such search through the evolution of a population, where each element (or individual) is the representation of a possible solu‐ tion for the problem. The principle is based on the theory of natural selection and it was firstly presented by Goldberg (1989).

At drinking systems' operation, GA stands out for being very efficient when binary and dis‐ crete variables are used. They represent a set of optimal solutions and not only one. At each new computational step, solutions containing the status of the pumps are evaluated and lat‐ er classified according to its fitness. The tendency is as the running proceeds, the elements with less fitness disappear and the more adapted to the impositions (or constraints) of the problem will arise.

GAs do not deal directly with the optimization problems that contain constraints. This im‐ pediment in the minimization procedure can be overcome employing the Penalty Methods, on which pre-defined constraints are added to the objective function in terms of penalties, turning the solution less apt as much as its violations occur. The Multiplicative Penalty Method (MPM), presented by Hilton & Culver (2000), is then implemented in this model. The penalty function is presented as follows:

$$P\_{TR} = \prod\_{i=1}^{NTR} k \tag{7}$$

where TR: type of constraint; NTR: amount of hydraulic elements (nodes, reservoirs or pumps) which have violated certain constraints; k: coefficient which varies with the hy‐ draulic element and the type of violated constraint.

Table 1 shows the values of k depending on the type of violated constraint.

Energy Efficiency in Water Supply Systems: GA for Pump Schedule Optimization and ANN for Hybrid Energy Prediction http://dx.doi.org/10.5772/50458 83


**Table 1.** Values of k

A flowchart describing the procedures of the designed ANN is shown on Figure 2.

there is energy available in the system.

82 Water Supply System Analysis - Selected Topics

**3.1. Simple Genetic Algorithm (SGA)**

firstly presented by Goldberg (1989).

The penalty function is presented as follows:

draulic element and the type of violated constraint.

**3. Methodology**

problem will arise.

The data used on this study is calculated by means of a CES model that gives an optimized ranking of the best hybrid solution for each particular case, based on an economy analyses for the production and consumption of energy (Figure 2). This data set is organized with the subject that the study is concerned to evaluate the use of hybrid energy solutions in water distribution systems based on micro-hydro, wind turbine and national electric grid. Hence, the range of data is defined in order to adequate the installation of such energy converters. The data range for flow, power head and water levels variation in reservoirs are used in a hydraulic and power simulator (HPS) to determine the power consumed by the pump and the power produced in a micro-hydro turbine installed in a gravity pipe branch whenever

GA is a stochastic method of global search that develop such search through the evolution of a population, where each element (or individual) is the representation of a possible solu‐ tion for the problem. The principle is based on the theory of natural selection and it was

At drinking systems' operation, GA stands out for being very efficient when binary and dis‐ crete variables are used. They represent a set of optimal solutions and not only one. At each new computational step, solutions containing the status of the pumps are evaluated and lat‐ er classified according to its fitness. The tendency is as the running proceeds, the elements with less fitness disappear and the more adapted to the impositions (or constraints) of the

GAs do not deal directly with the optimization problems that contain constraints. This im‐ pediment in the minimization procedure can be overcome employing the Penalty Methods, on which pre-defined constraints are added to the objective function in terms of penalties, turning the solution less apt as much as its violations occur. The Multiplicative Penalty Method (MPM), presented by Hilton & Culver (2000), is then implemented in this model.

> *PTR* <sup>=</sup> ∏ *i*=1 *NTR*

Table 1 shows the values of k depending on the type of violated constraint.

where TR: type of constraint; NTR: amount of hydraulic elements (nodes, reservoirs or pumps) which have violated certain constraints; k: coefficient which varies with the hy‐

*k* (7)

The values of k represent how the energy cost is increased for a particular type of violated restriction (TR). These values were determined from the amount and importance of con‐ straints in the model. Analyzing the extreme values (1.05 and 1.80), for each node that ex‐ ceed their limits, increases 5% to the value of the objective function. It was adopted the lower value for this violation because, commonly, the number of nodes in a WSS is higher the amount of tanks and pumps. However, as the discontinuity of the supply occurs in the system, it has great importance in the feasibility of the solution consequently a maximum value was adopted for this type of violation, increasing by 80% the cost of energy. Following this logic, the remaining violations have intermediate k values. When the constraint is not violated the coefficient k has the unit value.

The first stage of the SGA (Figure 1) process is characterized by the generation of operation‐ al rules (randomly), the demand definition and the tariff costs. Next, these variables are used by the hydraulic simulator (i.e. EPANET), which calculates the pressures in the pipe system nodes, the energy consumed and the levels of the tanks, all of them being necessary for the evaluation of the solution. The following stage is characterized by the calculation of the objective function, which is obtained from the total energy cost and from the penalty function, in case of infeasible solution. The process is repeated until the parameters of the operational control meets the hydraulic requirements with the lowest cost possible.

## **3.2. Hybrid Genetic Algorithm**

SGA makes use of the penalty method becoming the infeasible solutions into solutions with reduced ability. The genetic operators only diversify the solutions, but do not become them feasible. In this case, it can be confirmed the search process for solutions hydraulically feasi‐ ble, with minimum energy costs, is strongly stochastic. During the process of evaluation of the objective function, the explicit restrictive variables can be evaluated every hour. Thus, at this time interval, it is possible to verify the type of constraints that were violated. Because of this, repair algorithms were created, and every hour they try to correct the solutions gen‐ erated by GA, becoming them hydraulically feasible. The HGA layout of the model is also presented at Figure 3. Hence, each solution generated by GA is passed on to the repair algo‐ rithms. After this stage two solutions are stored: the original, generated by GA, and the modified solution, generated after the attempts of correction. If the penalty function of the modified solution is zero, so it will be sent to a data bank, otherwise, this solution will be discarded. Independent on the destiny of the modified solution, the original solution will be conserved and sent to the next generations of the GA, avoiding a premature convergence of the solutions.

egies in real pump systems due to a lesser intervention in the operation and a wear reduc‐

Energy Efficiency in Water Supply Systems: GA for Pump Schedule Optimization and ANN for Hybrid Energy Prediction

http://dx.doi.org/10.5772/50458

85

tion of the pumps.

**Figure 4.** Type of corrections

**Figure 5.** Example of correction – Actuation as start-up of the pumps

The repair algorithms are only a set of rules that modify the decision variables trying to be‐ come solutions hydraulically feasible all hours (Figure 4).

Among the type of corrections presented in Figure 4, the one related to the maximum num‐ ber of pump start-ups is the only one that does not use the EPANET routines. This is the first type of repair that occurs in infeasible solutions and aims mainly the reduction of the pump start-ups, changing as little as possible the original configuration of the solution.

**Figure 3.** Flowcharts: SGA and HGA

Figure 5 illustrates this type of repair to a solution of a pump with six start-ups.

In Figure 5, with only four changes, it was reduced from six to two the number of start-ups. Besides the considerable reduction, in the repaired solution is visible a greater uniformity of pumps' switch-on schedules. The changed solution has presented only two periods with the pump switched-on. The use of long operation periods is a characteristic of commonly strat‐ egies in real pump systems due to a lesser intervention in the operation and a wear reduc‐ tion of the pumps.

**Figure 4.** Type of corrections

rithms. After this stage two solutions are stored: the original, generated by GA, and the modified solution, generated after the attempts of correction. If the penalty function of the modified solution is zero, so it will be sent to a data bank, otherwise, this solution will be discarded. Independent on the destiny of the modified solution, the original solution will be conserved and sent to the next generations of the GA, avoiding a premature convergence of

The repair algorithms are only a set of rules that modify the decision variables trying to be‐

Among the type of corrections presented in Figure 4, the one related to the maximum num‐ ber of pump start-ups is the only one that does not use the EPANET routines. This is the first type of repair that occurs in infeasible solutions and aims mainly the reduction of the pump start-ups, changing as little as possible the original configuration of the solution.

Figure 5 illustrates this type of repair to a solution of a pump with six start-ups.

In Figure 5, with only four changes, it was reduced from six to two the number of start-ups. Besides the considerable reduction, in the repaired solution is visible a greater uniformity of pumps' switch-on schedules. The changed solution has presented only two periods with the pump switched-on. The use of long operation periods is a characteristic of commonly strat‐

come solutions hydraulically feasible all hours (Figure 4).

the solutions.

84 Water Supply System Analysis - Selected Topics

**Figure 3.** Flowcharts: SGA and HGA

**Figure 5.** Example of correction – Actuation as start-up of the pumps

Finishing the iterations of the HGA, the solutions stored at the data bank (feasible solutions) are sent to a process of specialized local search. This search algorithm is an iterative process in which, every hour, the pumps are switched-off one by one, verifying if the constraints re‐ main inviolate. If the solution becomes hydraulically unfeasible, the initial solution is re‐ stored. The selected hour is the one that has the highest energy cost. The process is repeated until there are no alterations that result in feasible solutions.

output matrix of [5 x 19,602] (Table 4), representing the Net Present Value (NPV) of each hy‐

Energy Efficiency in Water Supply Systems: GA for Pump Schedule Optimization and ANN for Hybrid Energy Prediction

http://dx.doi.org/10.5772/50458

87

average (m/s) Flow (l/s) Power net head (m) Gross Head (m)

brid solution configuration, as well as the number of wind turbines to be installed.

Wind speed annual

**Table 2.** Basic data set range used in CES.

With the utilization of the specialized local search algorithm it is possible to evolve good sol‐ utions in local optimal solutions. These solutions would probably require great computa‐ tional efforts to be found by the conventional GA.

## **3.3. Artificial Neural Network**

The data of renewable sources performance characteristics is included in the CES model to determine the best hybrid energy solution to be selected. One of the resources data is the wind turbine power curve of a selected wind turbine, which corresponds to the local wind source along an average year for the region under analysis (Figure 6) and the wind annual average speed applied to the wind turbine. In Table 2 is presented an example of data set range to be used in the CES model to determine the inputs and outputs of the developed ANN. Those data is used to calculate all energy and economic parameters to be included in the CES model to complete the data needed to train the ANN.

**Figure 6.** Wind energy: Wind Turbine Power Curve for an Enercon E33 and Wind source for one year at Lisbon region

Based on a basic data range, depending on the system characteristics (Table 2), to be used in the CES model and from auxiliary hydraulic and energy formulations, the complete input data is then obtained (Table 3) being: (1) Pump power (kW); (2) Pump energy consumption (kWh); (3) Turbine power (kW) - average output; (4) Flow (m3/s) - annual average flow; (5) Gross head (m); (6) Pumping head (m); (7) Head losses (m); (8) Power net head (m); (9) De‐ sign pumping flow rate (l/s); (10) Wind speed (m/s) - annual average; and (11) Wind turbine power (kW) - annual average output.

In the end of the modelling process the input data set is built in a matrix of [11 x 19,602] (Table 3), which by the interaction of the wind velocity data and the water flow yields in the


output matrix of [5 x 19,602] (Table 4), representing the Net Present Value (NPV) of each hy‐ brid solution configuration, as well as the number of wind turbines to be installed.

**Table 2.** Basic data set range used in CES.

Finishing the iterations of the HGA, the solutions stored at the data bank (feasible solutions) are sent to a process of specialized local search. This search algorithm is an iterative process in which, every hour, the pumps are switched-off one by one, verifying if the constraints re‐ main inviolate. If the solution becomes hydraulically unfeasible, the initial solution is re‐ stored. The selected hour is the one that has the highest energy cost. The process is repeated

With the utilization of the specialized local search algorithm it is possible to evolve good sol‐ utions in local optimal solutions. These solutions would probably require great computa‐

The data of renewable sources performance characteristics is included in the CES model to determine the best hybrid energy solution to be selected. One of the resources data is the wind turbine power curve of a selected wind turbine, which corresponds to the local wind source along an average year for the region under analysis (Figure 6) and the wind annual average speed applied to the wind turbine. In Table 2 is presented an example of data set range to be used in the CES model to determine the inputs and outputs of the developed ANN. Those data is used to calculate all energy and economic parameters to be included in

**Figure 6.** Wind energy: Wind Turbine Power Curve for an Enercon E33 and Wind source for one year at Lisbon region

Based on a basic data range, depending on the system characteristics (Table 2), to be used in the CES model and from auxiliary hydraulic and energy formulations, the complete input data is then obtained (Table 3) being: (1) Pump power (kW); (2) Pump energy consumption (kWh); (3) Turbine power (kW) - average output; (4) Flow (m3/s) - annual average flow; (5) Gross head (m); (6) Pumping head (m); (7) Head losses (m); (8) Power net head (m); (9) De‐ sign pumping flow rate (l/s); (10) Wind speed (m/s) - annual average; and (11) Wind turbine

In the end of the modelling process the input data set is built in a matrix of [11 x 19,602] (Table 3), which by the interaction of the wind velocity data and the water flow yields in the

until there are no alterations that result in feasible solutions.

the CES model to complete the data needed to train the ANN.

tional efforts to be found by the conventional GA.

**3.3. Artificial Neural Network**

86 Water Supply System Analysis - Selected Topics

power (kW) - annual average output.

The ANN data set created to be used in water distribution systems is then ready to deter‐ mine the NPV of each hybrid system evaluated for each type of configuration (e.g. grid, grid + hydro, grid + wind, grid + hydro + wind).

search, uses the HPS to hydraulically balance the water distribution system, in a village of Portugal, determining the hydraulic behaviour of the all system including the most suitable

Energy Efficiency in Water Supply Systems: GA for Pump Schedule Optimization and ANN for Hybrid Energy Prediction

Wind Turbine Installed

http://dx.doi.org/10.5772/50458

89

…

…

NPV€ Grid NPV€ Grid+Hydro NPV€ Grid+Wind NPV€ Grid+Hydro+Wind


> …


> …


…

> …

pump and turbine operation for each flow condition.

…

…

…

…


**Table 3.** Input data set for the system characteristics used in ANN.

Matlab® is used for the ANN development. The creation of an ANN should comprise the following steps: (i) patterns definition; (ii) network implementation; (iii) identification of the learning parameters; (iv) training, testing and validation processes. A new neural network model of hybrid energy must be compared with an energy configuration model and eco‐ nomical simulator (CES) using the following procedures: CES is used to obtain data applied in the training process and in reliable neural network tests, together with an hydraulic and power simulator model (HPS) for a large range of flow rates, gross heads, pumping and power heads and wind velocities. That data, available on Ramos and Ramos (2009b) re‐ search, uses the HPS to hydraulically balance the water distribution system, in a village of Portugal, determining the hydraulic behaviour of the all system including the most suitable pump and turbine operation for each flow condition.

The ANN data set created to be used in water distribution systems is then ready to deter‐ mine the NPV of each hybrid system evaluated for each type of configuration (e.g. grid, grid

> Pumping head m (6)

Matlab® is used for the ANN development. The creation of an ANN should comprise the following steps: (i) patterns definition; (ii) network implementation; (iii) identification of the learning parameters; (iv) training, testing and validation processes. A new neural network model of hybrid energy must be compared with an energy configuration model and eco‐ nomical simulator (CES) using the following procedures: CES is used to obtain data applied in the training process and in reliable neural network tests, together with an hydraulic and power simulator model (HPS) for a large range of flow rates, gross heads, pumping and power heads and wind velocities. That data, available on Ramos and Ramos (2009b) re‐

…. …. …. …. …. …. …. …. …. …. …. 0.322 2.895 0.587 0.01 16 24 8 7 16 3 15 0.398 3.584 1.016 0.01 21 29 8 13 16 3 15 0.475 4.274 1.446 0.01 27 35 8 18 16 3 15 0.552 4.964 1.876 0.01 32 41 8 24 16 3 15 0.628 5.653 2.306 0.01 38 46 8 29 16 3 15 0.705 6.343 2.735 0.01 43 52 8 35 16 3 15 0.781 7.032 3.165 0.01 49 57 9 40 16 3 15 0.858 7.722 3.595 0.01 54 63 9 46 16 3 15 0.935 8.412 4.025 0.01 60 69 9 51 16 3 15 1.011 9.101 4.454 0.01 66 74 9 57 16 3 15 1.088 9.791 4.884 0.01 71 80 9 62 16 3 15 1.165 10.481 5.314 0.01 77 86 9 68 16 3 15 1.241 11.170 5.744 0.01 82 91 9 73 16 3 15 1.318 11.860 6.173 0.01 88 97 9 79 16 3 15 1.394 12.549 6.603 0.01 93 102 9 84 16 3 15 …. …. …. …. …. …. …. …. …. …. ….

Head loss m (7)

Power head m (8)

Design flow rate L/s (9)

Wind speed m/s (10)

Wind turbine mean output power kW (11)

+ hydro, grid + wind, grid + hydro + wind).

Turbine mean output power kW (3)

**Table 3.** Input data set for the system characteristics used in ANN.

Annual average flow m3/s

(4) Z m (5)

Pump power kW/h (1)

Pump primary load kW/d (2)

88 Water Supply System Analysis - Selected Topics



ties of the tank Cascalheira (elevation: 375 m). This last one is supplied by EPAL (Portu‐ guese Lisbon Water Company) and provides water, by gravity, to the locations of Aljustrel

Energy Efficiency in Water Supply Systems: GA for Pump Schedule Optimization and ANN for Hybrid Energy Prediction

According to former description, the water storage of the tank Cascalheira is done by EPAL. The cost attributed to Veolia by this supply is related only to the effluent volume from this tank and it is not dependent of any alteration in the operation of the pump-station between tanks of Cascalheira and Fazarga. The reduction of this cost would only be possible with the implementation of water loss control by leakage. The level of the tank Cascalheira is always maintained close to the maximum limit in a way that it increases the reliability of the sys‐ tem. Thus, in the optimization model, it was chosen to consider only the variation of the lev‐

m, 0.3 m and 2.3 m, respectively. The pump-station comprises two pumps of Grundfos

The average time variation of the consumption in the region of Fátima during the day was obtained from the sensors located at the exit of the tank Fazarga. The period analyzed was from March to September, 2007. The water consumption in this year is more noticeable for comprising spring and summer. Figure 8 presents the average time variation calculated.

The hours with the pump working are considered as regular and discrete intervals by the optimization algorithm. Thus, for this case study, a day in which the pumps remained switched-on, in intervals similar to the format considered in the optimization model, were chosen. The hydraulic model of the system was built, in which the tanks Cascalheira and Fa‐

The variation in the level of the tank of Fazarga during the day calculated by the hydraul‐ ic simulator was similar to the real values. The maximum number of pump start-ups (Na max) used by Veolia was three (pump 1) and the level of the tank at the end of the opera‐ tional time is very close to the initial one (Figure 9). The variation of the energy rate is

**Hour 1:00 2:00 3:00 4:00 5:00 6:00 7:00 8:00 9:00 10:00 11:00 12:00 Tariff 0,0465 0,0465 0,0465 0,0465 0,0465 0,0465 0,0465 0,0465 0,0465 0,0761 0,1299 0,1299 Hour 13:00 14:00 15:00 16:00 17:00 18:00 19:00 20:00 21:00 22:00 23:00 24:00 Tariff 0,1299 0,0761 0,0761 0,0761 0,0761 0,0761 0,0761 0,0761 0,1299 0,1299 0,0761 0,0465**

NK65-250 type which work for an average flow of 42 1/s with an efficiency of 65%.

and operates with the initial, minimum and maximum levels of 2.0

of water, whereas Fazarga has a

http://dx.doi.org/10.5772/50458

91

el of the tank Fazarga at downstream of the pump-station.

The tank of Cascalheira has the storage capacity of 4000 m³

zarga were considered as reservoir and storage tank, respectively.

and Fontainhas.

total volume of 347 m³

presented in Table 5.

**Table 5.** Hour vs Energy Tariff (€/kWh) for Fátima system

**Table 4.** Input data set for the best economic configuration used in ANN.

In the ANN code running, the process of training and simulation for each system character‐ istic is analysed. In the training mode is introduced the configuration parameters. Those pa‐ rameters are standard limits (max and min), number of neurons on the hidden layer, limit number of epochs, final error desired, validation rate and activation function used in the hidden layer. With the best ANN configuration for each possible hybrid system and new da‐ ta set for inputs, a validation process is made and the results are verified in terms of correla‐ tion and relative error among the values of CES base model and the ANN.
