A generic method to optimize instructions for the control of evacuations