1
$\begingroup$

I am given a set of items S = {a1,a2,a3,...,an}. Each item has a corresponding M dimensional bit vector indicating the properties of that item. For example, if item x has corresponding vector: {0, 1, 0}, then item x does not have property 1, does have property 2, and does not have property 3.

I am also given a M dimensional "goal" vector indicating the number of items I need that match each property. For example, if my goal vector is: {1, 3, 2}, then I need 1 item with property 1, 3 items with property 2, and 2 items with property 3.

My question is, how can I select a subset of items from the set S such that the constraints listed in the goal vector are met exactly and so that the number of items selected from S is minimized? What is the name of this problem, and what is an efficient algorithm for solving it? Also, what algorithm would I use for the opposite scenario where I would like to maximize (instead of minimize) the number of items used?

Could this be a variation on the knapsack problem or the bin packing problem?

$\endgroup$

1 Answer 1

1
$\begingroup$

This problem is NP-hard, so you can't expect a general algorithm that is efficient and always correct. In particular, in the special case where the goal vector has only 1's and 0's in it, it becomes an instance of the exact cover problem.

Your problem can be viewed as an instance of the multidimensional subset sum problem.

If you have to solve it in practice, I would suggest formulating it as an instance of integer linear programming and using an off-the-shelf ILP solver.

$\endgroup$
1
  • $\begingroup$ Thank you for the response. I thought it might have been a variation of the multidimensional subset sum problem but I wasn't certain. I'll look up some ILP solvers. $\endgroup$
    – aisle3
    Commented Dec 1, 2020 at 2:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.