Demand allocation with latency cost functions