Multi-stage optimal design of energy systems for urban districts