This article looks at how to optimise pump operations using rule-based controls using such things as the EPANET2 Toolkit. Until now, this has not been possible. We modified the toolkit so that it is.


Every time we open a tap, water comes out. I had never asked myself why, before starting my civil engineering degree. It was only after I did that I realised that there is a lot of work behind water distribution systems (a water distribution system is the system of pipes, valves, tanks and pumps that deliver us water). Before that, I thought it was kind of magic.

Now, about 15 years later, I think it is still a kind of magic. Not only because the design of these systems is complex, but also because their operation needs to take into account a lot of constraints. In particular, the pump operation.

How do you operate a pump?

The easy answer is to switch it on or off depending on whether the tank is empty or full, respectively. But, the small example in Figure 1 will show you that it is not that easy after all.

The pump in Figure 1 fills a tank that is used to provide water to the users. We can use the tank level to decide when to switch on or off a pump.

Figure 2 shows the tank level and the pump operation if we decide to switch the pump on when the tank level reaches 7.9 m (this is the lower trigger level) and if we decide to switch the pump off when the tank level reaches 9.7 m (this is the upper trigger level).

This figure shows a pumping system. On the far right are some houses, labelled “users”. Above them is a tank, labelled “tank”. To the left and below the tank is an item labelled “pump” and next to it is an item labelled “water source”. It shows that the pump moves water from the water source to the tank, and then the tank serves the users.

Figure 1: simple example of pumping system

The pump controls in Figure 2 are not bad after all:

  • the tank is never empty, so users can have water the whole time
  • the tank is refilled after 24 hours
  • the number of pump switches is not excessive.

    This diagram shows a comparison between pump flow and tank levels. Between 1 pm and 1 am, at around 7 pm, a label says “some of this pumping could have been delayed to the off-peak tariff period!”. That off-peak tariff period is shown above it. The label says this because the pump flow is above 100 Litres per second, and yet the tank level is low at that time.

    Figure 2: example of pump operation with one set of tank trigger levels

However, we could have done better and saved a bit of money if we had pumped more in the off-peak tariff period, where energy is cheaper!

Who cares?

Maybe, at this point, you are already wondering ‘who cares?’ Well, the water utility, and all the people involved in the pump operations do.  Research has also cared for a relatively long time (e.g. Lingireddy and Wood, 1998; van Zyl et al. 2004; López-Ibáñez et al. 2008).

On some level, you should care too. Here’s why: Pumps use energy, which costs money. No matter where you are, you pay for water (and the electricity used to move it) directly or indirectly (e.g. through taxes).

It makes sense to switch the pumps on when the energy is cheaper (i.e. in the off-peak tariff period), but that is not easy. We could define the pump operation based on the time of the day (i.e. using scheduling), so that we are sure that we pump as much as we can when energy is cheaper. Figure 3 shows an example where we decide to switch off the pump at 8 am and to switch it on again at 4 pm. Now we exploit the off-peak tariff period as much as we can!  Perfect! Or, at least, it seems perfect. But what if the demands were bigger than expected and the tank runs empty before the off-peak tariff period starts? You cannot let this happen.

The problem is that we don’t know the water demands ahead of time. It makes predicting when we need to switch on or off a pump difficult.

Figure 3: the pump is switched on or off according to the time of the day

Rule-based controls help deal with uncertainty

One way to take into account the uncertainty in water demands is to control the pumps based on multiple conditions.

For example, if we define a different set of tank trigger levels (when to switch on or off a pump) for peak and off-peak tariff periods, we can reach the pump operations shown in Figure 4. The figure shows that we don’t pump more than necessary in the peak-tariff period, but we can  also make sure that the pump will be switched on before our tank runs empty.

Figure 4: example of pump operation with two sets of tank trigger levels (one for the peak and one for the off-peak tariff period) using rule-based controls

We can implement this type of pump controls in the hydraulic simulator EPANET2 (Rossman, 2000).

A rule-based control in EPANET2 looks like this:

AND TANK t6 LEVEL < 8.5000

You can see that the status of the pump depends both on the time of the day and on the tank level.

What happens is that usually the tank trigger levels in the peak tariff period are lower than the tank trigger levels in the off-peak tariff period. This way, the tank will not be completely refilled during the expensive period of the day; and it will be maintained as full as possible in the off-peak tariff period.

Optimising rule-based controls

The hydraulic simulator EPANET2 can be easily linked to optimisation algorithms using the EPANET2 toolkit. By doing this, the optimisation algorithm can find the best solution (or solutions) for you. For example, optimisation can find the optimal set of tank trigger levels to minimise costs and/or minimise energy consumption etc, Using trial and error would take a lot more time.

EPANET2 toolkit modification allows automation

Until  now, the toolkit did not allow the automatic modification of rule-based controls during optimisation. Now, we have adjusted the EPANET2 toolkit (see Marchi et al. (2016) and the ETTAR toolkit), so that we can optimise rule-based controls automatically.

This means that we can have an optimisation algorithm that optimises the tank trigger levels taking into account peak and off-peak tariff periods.

Automatic optimisation saves you time and money

But what if you want to operate a pump based on the level of multiple tanks? Real systems usually have more than one pump and one tank! Now we can optimise multiple conditions at the same time.

In Marchi et al. (2016) we also tried to let the algorithm optimise the entire set of rules. That is, the algorithm is deciding every word and value in a rule (for example RULE 1 above).

What we showed was that the algorithm was able to find less expensive solutions for the 24 hours tested!

There are many other possibilities

Maybe having the algorithm decide everything seems a bit too futuristic (even for me!). There is still a long way to go. There are a lot of considerations to take into account before the algorithm can really decide everything. But, this opens up a lot of interesting possibilities.

My hope is that the ETTAR toolkit can be used to find more cost-effective and reliable pump controls.

I hope you enjoyed this blog! If you are interested in this topic too, please leave a comment here or contact me.



Lingireddy, S. and Wood, D. (1998). “Improved Operation of Water Distribution Systems Using Variable-Speed Pumps.” J. Energy Eng., 10.1061/(ASCE)0733-9402(1998)124:3(90), 90-103.

López-Ibáñez, M., Prasad, T., and Paechter, B. (2008). “Ant Colony Optimization for Optimal Control of Pumps in Water Distribution Networks.” J. Water Resour. Plann. Manage., 10.1061/(ASCE)0733-9496(2008)134:4(337), 337-346.

Marchi, A.Simpson, A., and Lambert, M. (2016). “Optimization of Pump Operation Using Rule-Based Controls in EPANET2: New ETTAR Toolkit and Correction of Energy Computation.” J. Water Resour. Plann. Manage. , 10.1061/(ASCE)WR.1943-5452.0000637 , 04016012.

Rossman L.A., “EPANET2 user’s manual”, National Risk Management Research Laboratory, United States Environmental Protection Agency, Cincinnati, OH, 2000.

van Zyl, J. E. , Savic, D. A. , and Walters, G. A. (2004). “Operational optimization of water distribution systems using a hybrid genetic algorithm.” J. Water Resour. Plann. Manage. 130 (), 160–170.