Optimization of drinking water treatment and distribution