A problem in combinatorial optimization. Given a set of items with both weight and value, determine the number of each item to include in a collection so that the total weight is at most a given limit and the value of the collection is maximized.
Questions tagged [knapsack-problems]
267 questions
29
votes
1 answer
Subset Sum problem with many divisibility conditions
How does the computational complexity of the Subset Sum problem depend on the parameter $\alpha(S)$ of the input $(S, t)$,
defined as follows?
Considering $S$ under the divisibility partial order, i.e. $s_1 \prec s_2 \iff s_1 \mid s_2$,…
Chao Xu
- 3,103
- 19
- 34
15
votes
2 answers
Why is the dynamic programming algorithm of the knapsack problem not polynomial?
The dynamic programming algorithm for the knapsack problem has a time complexity of $O(nW)$ where $n$ is the number of items and $W$ is the capacity of the knapsack.
Why is this not a polynomial-time algorithm?
I have read that one needs $\lg W$…
Kaalouss
- 477
- 1
- 4
- 7
11
votes
1 answer
What algorithms exist for solving natural number linear systems?
I'm looking at the following problem:
Given $n$-dimensional vectors of natural numbers $v_1, \ldots, v_m$ and some input vector $u$, is $u$ a linear combination of the $v_i$'s with natural number coefficients?
i.e. are there some $t_1, \ldots, t_m…
Joey Eremondi
- 30,277
- 5
- 67
- 122
11
votes
1 answer
Variant of the knapsack problem
How would you approach the knapsack problem in a dynamic programming situation if you now have to limit the number of item in the knapsack by a constant $p$ ? This is the same problem (max weight of $W$, every item have a value $v$ and weight $w$)…
user11536
- 113
- 1
- 1
- 4
10
votes
2 answers
Knapsack Greedy Approximation: Worst Case
I am currently studying approximation algorithms and I have run into an issue with a study problem.
The approximation algorithm is for the general Knapsack problem, and it proposes a greedy approach, where it sorts by the value/weight ratio, and…
Chris Chambers
- 201
- 2
- 3
9
votes
1 answer
Knapsack with same value
I'm wondering if there's a name/reference for the variant of knapsack problem where all items have the same value (so we only care about maximizing the number of items), but there are multiple weight constraints.
Maximize $\sum_{j=1}^nx_j$
subject…
user57012
- 105
- 6
9
votes
2 answers
Algorithms for two and three dimensional Knapsack
I know that the 2D and 3D Knapsack problems are NPC, but is there any way to solve them in reasonable time if the instances are not very complicated? Would dynamic programming work?
By 2D (3D) Knapsack I mean I have a square (cube) and a I have list…
Anonymous
- 621
- 7
- 5
8
votes
1 answer
Balanced Weight Distribution in Bins/Buckets
Let $W = \{w_1,w_2,...w_n\}$ be a set of integer weights. Let $B = \{b_1,b_2,...b_m\}$ be a set of buckets, with $m \leq n$. Let $T(b_j)$ represent the total weight present in bucket $b_j$, which is the sum of all the weights present in $b_j$.
What…
laughing_man
- 211
- 2
- 4
8
votes
4 answers
Find non-overlapping scheduled jobs with maximum cost
Given a set of n jobs with [start time, end time, cost] find a subset so that no 2 jobs overlap and the cost is maximum.
Now I'm not sure if a greedy algorithm will do the trick. That is, sort by cost and always take the next job that doesn't…
user1531186
- 89
- 1
- 1
- 2
6
votes
0 answers
Relations between the knapsack problem, the bin packing problem, and the set packing problem?
I wonder what relations are between the knapsack problem, the bin packing problem and the set packing problem?
From their mathematical formulations, I don't see the first two belong to the third one i.e. the set packing problem, although I feel the…
Tim
- 5,035
- 5
- 37
- 71
5
votes
0 answers
Specific quadratic 0-1 knapsack problem solvable in linear time?
I am interested in a simple variant of the quadratic knapsack problem.
Let $\{w_1, \ldots, w_n\} \in \{0,1\}$ be $n$ weights and $\{v_1, \ldots, v_n\} \in \mathbb{R}$ be $n$ values. Furthermore, assume $h$ is a fixed integer such that $n \geq h \geq…
LuckyStapler
- 51
- 1
5
votes
2 answers
Version of knap sack problem
The are cuisenaire rods with N differnt lengthes $x_1,x_2,...,x_n$ (each length is a natural number), the number of the Cuisenaire rods is unlimited. Given a natural number B. you should tell if you can pick a bunch of Cuisenaire rods with exactly…
Error 404
- 211
- 2
- 8
5
votes
1 answer
Proof of 0/1 knapsack optimal substructure
I'm trying to understand why exactly the 0/1 knapsack problem actually has the optimal substructure property.
Let $E$ be the set of items to consider and $v$ and $w$ the value and weight functions defined over $E$.
Now, suppose that, among all…
matheuscscp
- 345
- 1
- 4
- 12
5
votes
1 answer
Counting the solutions to a restricted 0-1 knapsack problem
Consider the counting knapsack problem $\mathsf{\#IDKNAP}$ :
Input: $n \in \mathbb{Z_+}$, $s \in \mathbb{Q}_+$, where $s$ is represented by a fraction $\frac{p}{q}$ in its lowest terms.
Output: the number of 0-1 solutions (i.e. those having…
PKG
- 1,489
- 10
- 15
5
votes
0 answers
2 Dimensional Subset Sum: looking for information
I do not know if this problems exists with a different name, if it is, I could not find it.
The problem is this:
Given a set $S$ of $n$ points in $\mathbb{Z}^2$, is there a subset $A\subset S$ such that the points of $A$ sum up to $(0,0)$?
If we…
Harry
- 111
- 6