Due to pervasive deployment of electricity-propelled water-pumps, water distribution systems (WDSs) are energy-intensive technologies which are largely operated and controlled by engineers based on their judgments and discretions. Hence energy efficiency in the water sector is a serious concern. To this end, this study is dedicated to the optimal operation of the WDS which is articulated as minimization of the pumps energy consumption while maintaining flow, pressure, and tank water levels at a minimum level, also known as pump scheduling problem (PSP). This problem is proved to be NP-hard (i.e. a difficult problem computationally). We therefore develop a hybrid methodology incorporating machine-learning techniques as well as optimization methods to address real-life and large-sized WDSs. Other main contributions of this research are (i) in addition to fixed-speed pumps, the variable-speed pumps are optimally controlled, (ii) and operational rules such as water allocation rules can also be explicitly considered in the methodology. This methodology is tested using a large dataset in which the results are found to be highly promising. This methodology has been coded as a user-friendly software composed of MS-Excel (as a user interface), MS-Access (a database), MATLAB (for machine-learning), GAMS (with CPLEX solver for solving optimization problem) and EPANET (to solve hydraulic models).