Bin Packing regarding Optimization and Decision Versions

和自甴很熟 提交于 2019-12-11 09:38:14

问题


I'm studying for an exam and we were given a set of practice problems. Here's one I'm struggling with and I hope somebody can help shed some light on the right approach to this problem:

Here's my initial go at the problem:

Decision Version: To find the optimal solution using the decision version, I would try using various K's until I got a yes answer. Let's say the optimized solution is 7, I would try :

k=1, no
k=2, no
k=3, no
k=4, no
k=5, no
k=6, no
k=7, yes. 

So now that we know that the optimal solution is 7 bins, we solve the decision version by sorting the items by sizes from largest to smallest, and filling up the bins filling largest to smallest, and looping back over the bins until they are no more elements in the set.

If we have an optimal solution and we want to solve the decision version, I would take the number of bins returned by the optimal solution, and run it on the decision version to see if it returns yes.

I've never really seen a problem like this before so I'm not sure how the proper format is supposed to be.

Any help would be greatly appreciated!


回答1:


There is a much better approach to solving the optimization problem based on the decision problem, note that your solution is exponential (pseudo-polynomial, but still exponential) in the size of the input, since if you have an algorithm that runs in T(n) on the decision problem, the suggested solution runs in O(k*T(n)), but since k is actually exponential in the size of the input (you need only log(k) bits to represent it), you have an exponential run time.

However, you can apply binary search on the problem, and require only O(log(k)) invokations of the algorithm of the decision problem in order to solve the optimization problem.

Now, if P=NP, and such algorithm (for solving the decision problem) exists in polynomial time O(p(n)), solving the optimization problem will be done in O(p(n) * log(k)) - which is polynomial in the size of the input.

The binary search will go something like that:

k <- 1
while decision_bin_packing(G,k) == false:
    k <- k * 2
perform binary search for the smallest value t in [k/2,k] such that decision_bin_packing(G,t)==true

The last binary search is pretty standard, and can be easily implemented with only O(logk) invokations of decision_bin_packing.



来源:https://stackoverflow.com/questions/27353917/bin-packing-regarding-optimization-and-decision-versions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!