Batching Problems with Constraints