Setup
Suppose I have a very large number of items. Each item has a shape, size and colour. They may be
- triangles, circles or squares
- red, green or blue
- small or large
I can't make any assumptions about the distribution of these attributes among the items. I'm reasonably sure that it's not one million large, red triangles but that's always a possibility.
Problem
I want to pick 36 of my shapes with as "diverse" as possible representation across all attribute classes. To clarify, with 36 items drawn from the very large set I'd ideally like 12 red, 12 green, 12 blue, 12 triangles, 18 small etc.
Now there are 18 possible distinct item types (3 colours * 3 shapes * 2 sizes) so one way of doing this would be to include two of each distinct type (assuming that I have them).
If I don't have sufficient of each distinct type, another (impractical, brute force) approach, would be to iterate over every possible subset of 36 items and keep the best subset.
I'm sure that this is a specific instance of a broader class of problems solvable by a well known algorithm but I can't determine the magic words for Google. I've tagged as knapsack-problem because it feels like perhaps it's this but I wonder if there's a better way to solve this?
Can you help with either a solution or at least appropriate search terms?