Divide objects in groups so that total sum of sizes in a group are balanced across groups

19 Views Asked by At

I have a set of $N$ ordered objects with respective known sizes. I need to group them into $M$ groups subject to the following constraints:

  1. Each group must have at least $1$ object.
  2. Ordering of items should not be altered, that means if the $K^\text{th}$ item goes to group $X$, then the subsequent $K+1, K+2,\ldots$ will go to group $X$ or later only.
  3. The sum of sizes of items in each group should have least possible deviation with respect to other groups.