Optimal Delay Scheduling in Networks with Arbitrary Constraints