Exact GPS simulation and optimal fair scheduling with logarithmic complexity