Quadratic profits depend on multi items rather than every two items of Quadratic Multi Knapsack Problem - knapsack-problem

There are multiple knapsacks that need to be filled exactly. Each knapsack has a different capacity. Items are unique. The weight of all items is 1.The value of item will be different when this item put in different knapsacks. At the same time, having multiple items in the same knapsack creates quadratic value. The quadratic value varies, depending on the type and quantity of items in the knapsack.
Is there any kind of efficient solving techniques that can get optimal result?

Related

If you are given a binary knapsack problem with all items the same density (value/volume) how would you solve it?

As the title is asking, not sure whether to use greedy method based on volume or if it is NP complete.
The binary knapsack problem where all items have the same density is essentially equivalent to the subset sum problem. In that problem, you’re given a set S of natural numbers and a target number k, and asked to determine whether it has a subset whose sum is exactly k. You can easily reduce subset sum to your problem by mapping each number in S to an item whose weight and value are the same. Since the subset sum problem is NP-complete, so is your problem.

Why is 0/1 Knapsack not part of Greedy Algorithm but Fractional Knapsack is? [duplicate]

This question already has answers here:
Cases where the greedy algorithm fails the 0-1 knapsack p‌r‌o‌b‌l‌e‌m
(2 answers)
Closed 2 years ago.
I don't get it. I really don't. Greedy Algorithm for me, only cares about :
Dividing a problem into stages[sub problems]
Maximizing/Minimizing or Optimizing output in each stage irrespective of later stages or anything else.
Even the 0/1 Knapsack Problem is solved using the same theory.
Stages become various items to fill
Optimizing output in each stage becomes picking the item providing most profit first and then picking the next item providing most profit and so on.
It's the same approach that we are following on both Knapsack problems. The only difference is :
In Fractional Knapsack : we maximize profit by picking the item providing most PROFIT/WEIGHT. Why? Because items can be divided
In 0/1 Knapsack : we maximize profit by simply picking the item providing most profit. Since items cannot be divided, we don't think about calculating profit/weight as it makes no difference.
They both should fall under Greedy Algorithm.
I'm just not able to understand where does concept of Dynamic Programming arrive.
Greedy algorithms are not about dividing the problem and solving it in parts.
It is in fact DP or backtracking. In Greedy we choose the best possible option that we have at the moment and pick that and compute for the rest. Best example for this is Dijkstra.
In 0/1 we don't know which item will give us the maximum weight, so we have to try all the items. In order to avoid computing the same input space again and again, we store the intermediate result and that's why it falls under DP.
In partial knapsack, we basically take the item which will give us the best weight at the moment, pick that and compute for the remaining of the weight.

Knapsack problem with values per item and limited items

I'm trying to solve a variant of knapsack problem that i haven't seen before.
in this variant we have a vector v consist of values per gram for each item and we also have a limited weight of each item and our goal is to find the maximum value that can be gain if we have a pack of size M.
I tried greedy approached but haven't found any solution. i think the most difficult part is to do it in O(n) because we shouldn't sort anything.
anyone has any idea?
If the value per gram has reasonably narrow bounds, you can counting-sort or radix-sort or bucket-sort it in linear time by the value per gram, and then just fill up the bucket in order of most valuable substances. What do I mean by reasonable limits? Specifically, I mean that there are asymptotically fewer meaningful "values per gram" than there are kinds of substances.

Can we solve this kind of 0-1 Multiple Knapsack problem in DP?

The problem is: given a set of n items and a set of m knapsacks, c[i] is the capacity of knapsack i, w[j] is the weight of item j, p[i][j] is the profit of put item j to the knapsack i, that means an item may have different profit if placing in different knapsack.
We have to find the optimal solution to make the total profit of the selected items is a maximum and all the selected items have to be placed in the same knapsack. For example, if there are two knapsacks A and B, the final solution cannot be placing some items in A and placing some items in B. All the selected items must be either placed in A or placed in B. So this question is somewhat different from the traditional 0-1 Multiple knapsack problem.
One solution is breaking this multiple knapsack problem into multiple small 0-1 knapsack problem. For each knapsack, we can use dynamic programming to solve the 0-1 knapsack problem and find the maximum profit for this knapsack. Use the same algorithm to traverse all the knapsacks and select the maximum profit,we can get the solution we want.
I want to know, is there any better method with better time complexity to solve this problem? Or any dynamic programming method to avoid traversing all the knapsacks? If there is no better way, how to prove?

Isn't this a correct but very efficient and simple way of solving the 0-1 knapsack?

As I understand it, in a 0-1 knapsack problem, only 0 or 1 objects of the same variant are allowed. Wouldn't it be better to just divide every weight by it's value to get the respectiv ratios and then just take every ratio beginning from the largest and put it in the knapsack until the maximum allowed weight is reached? Wouldn't its time complexity be better than the dynamic programming solution and obviously better than bruteforcing?
The point of the 0-1 Knapsack problem is to find if the maximum value occurs if an item is put into the knapsack or not included in the knapsack. This prevents the problem where including an item results in an unfillable space in the knapsack. A greedy approach that always includes an object could result in an unfillable space in the knapsack.

Resources