To experience the process of designing an algorithm (without anybody telling you how you have to do it), implementing the algorithm (Java, C++, or C), and testing it.
Consider a sparse 2-dimensional 0-1 matrix, where each column is assigned a weight. The task is to select a subset of the columns so that the each row contains exactly one 1 in the selected columns. The cost of the solution is the sum of the costs of the selected columns. A solution of lowest cost is desired.
Example:
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | |
---|---|---|---|---|---|---|---|---|
1 | ||||||||
2 | ||||||||
3 | ||||||||
4 | ||||||||
5 | ||||||||
Cost |
first line: number of rows, number of columns
remaining lines, one for each column:
column cost, number of rows covered, list of rows covered
Here are the first few lines of some sample data with forty rows and 3076 columns. This file has 3077 lines. I think that no column will cover more than fifteen rows in any data file that I have.
40 3076
3006 6 1 4 5 11 34 382620 4 1 4 10 11
9484 1 1
3438 6 2 12 13 21 29 32
2168 5 2 21 37 39 40
2830 4 2 21 37 39
2152 4 2 21 39 40
2830 3 2 21 39
/u/css/classes/5110/Fall2014/setcover/data1.txt /u/css/classes/5110/Fall2014/setcover/data2.txt /u/css/classes/5110/Fall2014/setcover/data3.txt /u/css/classes/5110/Fall2014/setcover/data4.txt