Optimal delay scheduling in networks with arbitrary constraints