Optimizing a pumping system in the wastewater treatment process by improving its operational schedules is presented. The energy consumption and outflow rate of the pumping system are modeled by a data-driven approach. A mixed-integer nonlinear programming (MINLP) model containing data-driven components and pump operational constraints is developed to minimize the energy consumption of the pumping system while maintaining the required pumping workload. A greedy electromagnetism-like (GEM) algorithm is designed to solve the MINLP model for optimized operational schedules and pump speeds. Three computational cases are studied to demonstrate the effectiveness of the proposed data-driven modeling and GEM algorithm. The computational results show that significant energy saving can be obtained.