This paper proposes an innovative procedure for identifying, in the event of accidental or intentional contamination of a water distribution system, the optimal scheduling of activation of a pre-selected set of flow control devices which will serve to minimise the volume of contaminated water consumed by users after the detection of the contaminant in the system. The constraints are represented by the number of available response teams and the maximum speed at which these teams can travel along the roadway. The optimal scheduling of device activation is sought by means of an optimisation process based on a genetic algorithm (GA) which interacts with a mixed integer linear programming (MILP) solver in order to ensure the feasibility of the scheduling identified. The optimisation procedure is coupled to a hydraulic and quality simulator, which enables a calculation of the volumes of contaminated water consumed by users, and a dynamic cache memory, which, by storing information on the system's behaviour as the optimisation process progresses, serves to limit the computational times. The application of the procedure to a highly complex real water distribution system shows that the optimisation process is robust and efficacious and produces a smaller volume of contaminated water consumed by the users than when the activation of all the devices was completed in the shortest amount of time.