Gravar-mail: Energy-saving wastewater treatment systems : formulation of cost functions