knapsack implements a solution for the 0/1 Knapsack Problem as described here. Given a total budget as input, with data containing each potential item's cost and value, knapsack returns the maximum possible total value that can be purchased using the budget. If generate() is specified, a new variable is created containing 1 if the item is in the optimal set and 0 if it is not.