Simulation algorithm