napsack(x, target, best=10)
The solutions produced may not include all subsets that can generate solutions with a certain error. It is guaranteed to produce an exact solution if one is possible, but may not find all of a number of exact solutions.
Salkin, H. M. (1975). Integer Programming. Addison-Wesley, Reading, Mass.
# given areas of the states, find subsets of them # with approximately 1/2 the total area of the country state.area <- state.x77[,"Area"] state.half <- napsack(state.area, sum(state.area)/2) crossprod(state.half, state.area) # areas of the subsets