I have a problem that I am trying to find an algorithm for. I'd appreciate any suggestions.
I have n rows of length m. The rows have binary (0,1) values that have some expected sum. The 1's can be placed anywhere in its row as long as the sum is as expected. The goal is to minimize the vertical sum for each column in length m.
For example, if we have a 4
rows and 10
columns, where the expected sums are:
Row 1: 6
Row 2: 7
Row 3: 4
Row 4: 5
A potential solution could be:
1 1 1 1 1 1 0 0 0 0
1 1 1 0 0 0 1 1 1 1
1 0 0 1 1 1 0 0 0 0
0 1 0 0 0 0 1 1 1 1
Getting vertical sums of:
3 3 2 2 2 2 2 2 2 2
Opposed to the larger sums if we would just place all the ones in the beginning:
1 1 1 1 1 1 0 0 0 0
1 1 1 1 1 1 1 0 0 0
1 1 1 1 0 0 0 0 0 0
1 1 1 1 1 0 0 0 0 0
With sums of:
4 4 4 4 3 2 1 0 0 0
So, I'm trying to spread out the load. My number of rows will get into the millions/billions, so I'm hoping for a linear algebra approach rather than iterative. Thanks!