I have an combinational optimization problem and I do not know its name in literature.
My problem is the following:
I have n sets containing exclusive elements, so each element is present only in a set.
An element is characterized by 2 constraints values, and one profit.
I have to choose an element from each set in order to maximize the sum of the profits, while keeping the sum of each constraint below a a specified limit.
Is this an already studied problem? WHich is its name?
Can I assimilate it to an already studied problem?
Thanks to #Berthur & #mrBen replies, I discovered that this is a multiple-constrained knapsack problem where you have to create an indicator variable to force that only one element will be chosen by each set
The problem you're describing is know as the multiple-choice knapsack problem. In your case, as you have 2 constraints, it's actually a 2-dimentional multiple-choice knapsack problem.
With the keywords multi-dimentional multiple-choice knapsack problem (sometime abbreviated as MMKP) you should be able to find the corresponding literature.
Related
I want to do a variation on the 0-1 knapsack problem. Just like the original problem each item would have a weight and value, and you are minimizing weight and maximizing value. However each item would be part of a set e.g. Book1(value, weight, set).
I need an algorithm that can sort these, given an upper limit on each individual set. So for instance Set A would be (Book1, Book2, Book3) and I could only have
3 items from set A in the entire knapsack.
There would be no limits on individual items, so I could take as many Book1's as I wished, but I couldn't take more than Set A would allow me to take. The entire knapsack would have multiple sets each with multiple items.
I've tried individually solving each set before solving the problem as a whole using the solutions from each set, but it gives me obviously suboptimal solutions.
How should I design my code so that it produces the best result?
I'm working with a problem that is similar to the box stacking problem that can be solved with a dynamic programming algorithm. I read posts here on SO about it but I have a difficult time understanding the DP approach, and would like some explanation as to how it works. Here's the problem at hand:
Given X objects, each with its own weight 'w' and strength 's', how
many can you stack on top of each other? An object can carry its own
weight and the sum of all weights on top of it as long as it does not
exceed its strength.
I understand that it has an optimal substructure, but its the overlapping subproblem part that confuses me. I'm trying to create a recursion tree to see where it would calculate the same thing several times, but I can't figure out if the function would take one or two parameters for example.
The first step to solving this problem is proving that you can find an optimal stack with boxes ordered from highest to lowest strength.
Then you just have to sort the boxes by strength and figure out which ones are included in the optimal stack.
The recursive subproblem has two parameters: find the best stack you can put on top of a stack with X remaining strength, using boxes at positions >= Y in the list.
If good DP solution exists, it takes 2 params:
number of visited objects or number of unvisited objects
total weight of unvisited objects you can currently afford (weight of visited objects does not matter)
To make it work you have to find ordering, where placing object on top of next objects is useless. That is, for any solution with violation of this ordering there is another solution that follows this ordering and is better or equal.
You have to proof that selected ordering exists and define it clearly. I don't think simple sorting by strength, suggested by Matt Timmermans, is enough, since weight has some meaning. But it's the proofing part...
I have been trying to find a variation on the knapsack problem that fits my problem, but either I don't understand the definitions on wikipedia well enough (likely) or I am looking in the wrong places.
My problem requires the maximization of value across multiple sets of data. Given 3 sets of data, I want to be able to pick exactly 2 members from each set while maximizing the profit.
Does anyone know of a variation of the knapsack problem that I can look into to do this?
Thank you
I have a research on Knapsack Problems. Now I stopped on special type of a Multiple Knapsack Problem, where weight of each item is equal with profit of this item.
I can't find any paper saying anything about the complexity of this problem. Is it NP-complete or not?
Any help will be appreciated.
I found a problem that can be reduced to mine - The Multiple Subset Sum Problem. The Multiple Subset Sum Problem (MSSP) is the selection of items from a given ground set and their packing into a given number of identical bins such that the sum of the item weights in every bin does not exceed the bin capacity and the total sum of the weights of the items packed is as large as possible. It can be easily reduced to my problem. It proves that my problem is NP-hard.
This problem is NP-hard via a reduction from the set partition problem. In that problem, you're given a set of integers and are asked whether it's possible to split that set into two sets with the same sum. You can reduce it to your problem as follows: if the set has sum 2k, create two knapsacks of capacity k each and create one item for each number in the set to split. Then, any way of perfectly filling the knapsacks corresponds to a partition of the original set and vice-versa. (If the sum of the numbers isn't even, just map the problem instance to an unsolvable instance of your knapsack problem).
Hope this helps!
I have this problem in my textbook:
Given a group of n items, each with a distinct value V(i), what is the best way to divide the items into 3 groups so the group with the highest value is minimIzed? Give the value of this largest group.
I know how to do the 2 pile variant of this problem: it just requires running the knapsack algorithm backwards on the problem. However, I am pretty puzzled as how to solve this problem. Could anyone give me any pointers?
Answer: Pretty much the same thing as the 0-1 knapsack, although 2D
Tough homework problem. This is essentially the optimization version of the 3-partition problem.
http://en.wikipedia.org/wiki/3-partition_problem
It is closely related to bin packing, partition, and subset-sum (and, as you noted, knapsack). However, it happens to be strongly NP-Complete, which makes it a harder than its cousins. Anyway, I suggest you start by looking at dynamic programming solutions to the related problems (I'd start with partition, but find a non-wikipedia explanation of the DP solution).
Update: I apologize. I have mislead you. The 3-partition problem splits the input into sets of 3, not 3 sets. The rest of what I said still applies, but with the renewed hope that your variant isn't strongly np-complete.
Let f[i][j][k] denotes whether it is possible to have value j in the first set and value k in the second set, with the first i items.
So we have f[i][j][k] = f[i-1][j-v[i]][k] or f[i-1][j][k-v[i]].
and initially we have f[0][0][0] = True.
for every f[i][j][k] = True, update your answer depends on how you defines fairly.
I don't know about "The Best" mathematically speaking, but one obvious approach would be to build a population of groups initially with one item in each group. Then, for as long as you have more groups than the desired number of final groups, extract the two groups with the lowest values and combine them into a new group that you add back into the collection. This is similar to how Huffman compression trees are built.
Example:
1 3 7 9 10
becomes
4(1+3) 7 9 10
becomes
9 10 11(1+3+7)