Proof of Correctness of Value Density First Greedy Strategy for Fractional Knapsack Problem

      The fractional knapsack problem is a variant of the 0/1 knapsack problem, where items can be broken down into small pieces, which leads to the use of a greedy algorithm to solve this problem.  So how do you prove that an optimal solution can be obtained for the greedy strategy of proft density frst for fractional knapsack problem ?

      The idea is to compare the solution of the greedy method with any optimal solution to prove - using the method of proof by contradiction, if the two solutions are different, find an unequal solution, and then draw a conclusion that contradicts the assumption, so as to prove the original. The title is established.

      Proof : In the words of "Introduction to Algorithms", the commodity in the fractional knapsack problem is like "gold sand". Assume preprocessing: for these different qualities of gold sand, if some different gold sands have the same value density (vm = vl, m != l), consider these kinds of gold sand as the same kind of gold sand (or mixed together to become a commodity), which greatly simplifies the proof.

      (1) Let the capacity of the backpack be c, the value density priority greedy strategy algorithm is pdf, there are a total of n categories of commodities after preprocessing, and the total weight of each commodity is Wrk (1<=k<=n), S(i) ={Wi1,...,Win} (0<=Wik<=Wrk) is a global optimal solution; ∑Wik=c.

       Let S={W1,W2,...,Wn} be the solution obtained by pdf, and not the optimal solution, where v1>v2>...>vn(*), ∑Wk=c. According to the preprocessing, it can be known , (*) will not take the equal sign . If all commodities are loaded into the knapsack, obviously this solution is the optimal solution; if not all commodities are loaded into the knapsack, then let j be the minimum subscript that makes Wk!=1, it can be known from the algorithm that for 1<=k<j, Wk=Wrk; for j<k<=n, Wk=0; for j, there is 0<=Wk<Wrk. Let m be the minimum subscript that makes Wik != Wk, from the above assumption, it can be inferred that Wim < Wm , which can be proved from three possible cases, namely m<j, m=j or m>j, respectively:

       If m<j, then Wm=Wrm, because Wim != Wm, and 0<=Wik<=Wrk, thus Wim<Wm.

       If m=j, (1) the proband is Wm in this case! =0. Assuming Wm=0, then there is Wk=Wrk=Wik(1<=k<m), otherwise, it is contradictory that m is the minimum subscript that makes Wik != Wk; thus Wim>Wm=0, However, at this time ∑Wik>∑Wk=c, which contradicts the feasible solution of S(i). Therefore, when Wm>0; (2) For 1<=k<m, there is Wk=Wik=Wrk, if Wim>Wm , then ∑Wik>∑Wk=c , which contradicts the feasible solution of S(i). If Wim=Wm , it contradicts Wim != Wm, so Wim<Wm .

       If m>j, then Wim>Wm=0, so ∑Wik>∑Wk=c, which contradicts the feasible solution of S(i). In summary, Wim < Wm.

       (ii) Now, suppose that Wim is increased to Wm, then the same amount must be subtracted from {Wim+1,...Win}, so that the total capacity used is still c, which will lead to a new solution Z = { z1,...,zn}, where zk=Wk (1<=k<=m). 

        By assumption, weight change = zm - Wim - ∑(Wik-zk)(m<k<=n) = 0.

       Z total value = ∑zkvk(1<=k<=n) = ∑Wikvk(1<=k<=n) + value change

                                                    = ∑Wikvk(1<=k<=n) + (zm - Wim)vm - ∑(Wik-zk)vk(m<k<=n)

                                            > ∑Wikvk(1<=k<=n) + (zm - Wim)vm - vm∑(Wik-zk)(m<k<=n) (*)

                                                    = ∑Wikvk(1<=k<=n) + vm(zm - Wim - ∑(Wik-zk)(m<k<=n))

                                                    = ∑Wikvk(1<=k<=n)

        Thus, ∑zkvk(1<=k<=n)>∑Wikvk(1<=k<=n) is obtained , which contradicts that S(i) is a global optimal solution.

        To sum up, the bold font assumption does not hold, and it is concluded that the solution obtained by the value-density-first greedy strategy for the fractional knapsack problem is the optimal solution.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325182715&siteId=291194637