Optimization of sludge thermal treatment at wastewater treatment plants