Design and control of optimal water distribution systems