Optimizing event-driven simulations