![]() ![]() I don't know whether it has also been used before for profits. $~~~\Box$ĮDIT: Looking briefly over the literature, the same idea (but for weights instead of profits) has been used for unbounded Knapsack with small weights. There are $O(n P)$ subproblems, and for each the right-hand side of the recurrence can be evaluated in time $O(P)$, so the dynamic-programming algorithm takes time $O(n P^2)$. Given weights and values of n items, put these items in a knapsack of capacity W to get the maximum total value in the knapsack. Output: the minimum sufficient weight $W^* = \min\big\ Input: weights $w=(w_1,\ldots,w_n)$, positive integer profits $p=(p_1,\ldots, p_n)$, and desired profit $P$ We first observe that the problem reduces in polynomial time to the "flipped" variant, where the profits are given a threshold, rather than the weights: For unbounded Knapsack with integer profits $(p_1,\ldots,p_n)$, there is an algorithm running in time polynomial in $n$ and $\max_i p_i$. The problem (unbounded Knapsack with small profits) has a polynomial-time algorithm. In contrast, for the unbounded problem, even with small profits, the maximum achievable profit is not in general polynomial in $n$, so the same approach does not yield a polynomial-time algorithm. Well known problems that are not usually classified in the knapsack area, including generalized assignment and bin packing, are also covered. (That reduction creates profits that are the same as the weights, and both are exponential.) But for instances where each item profit is $O(n)$, the maximum achievable profit $P$ is $O(n^2)$, and there is a standard dynamic-programming algorithm that runs in time polynomial in $n$ and $P$, so the run-time in the case of small profits is polynomial in $n$. Includes not only the classical knapsack problems such as binary, bounded, unbounded or binary multiple, but also less familiar problems such as subset-sum and change-making. This version is NP-hard by reduction from Subset Sum. With this restriction, is the unbounded Knapsack problem NP-hard, or is there a poly-time algorithm for it?įor comparison, consider the standard Knapsack problem, where each item can be taken at most once, so each $x_i$ is either 0 or 1. ![]() The UKP is very easy to solve (despite being weakly NP-Hard). So you can solve each knapsack separately (losing some shared effort). In general, this problem is NP-hard, but I am wondering about the restriction to instances with small profits - where every item profit $p_i$ is $O(n)$. As the number of items is unbounded, what you put in one knapsack does not affect the others. Here (in the unbounded variant) each item $i$ can be taken any number of times, so each $x_i$ can take any value in $\mathbb N_0$. The goal is to maximize the total profit $\sum_i x_ip_i$ subject to the total weight $\sum_i w_i x_i$ being at most $W$. You cannot break an item, either pick the complete item, or don’t pick it (0-1 property).Consider the unbounded Knapsack problem where we are given $n$ items of integral weights $w_i$, integral profits $p_i$, and a max weight $W$. ![]() Also given an integer W which represents knapsack capacity, find out the items such that sum of the weights of those items of given subset is smaller than or equal to W. In other words, given two integer arrays val and wt which represent values and weights associated with n items respectively. Given weights and values of n items, put these items in a knapsack of capacity W to get the maximum total value in the knapsack. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |