Let item have weight and profit . Define as the largest profit obtainable from the first items with capacity at most the nonnegative integer . Set . The last item is either absent or present once, giving the dynamic programming recursion
The two alternatives exhaust the feasible binary decisions. In the second alternative, deleting item leaves exactly the smaller subproblem with capacity , which proves the recurrence.
Fill rows , and within each row capacities . Store which alternative attains each maximum. Backtrack from : when exclusion was chosen, set and move to ; when inclusion was chosen, set and move to . Ties may be resolved either way. Thus the stored values yield an actual optimal selection, not just its objective value.
For items and capacity , the algorithm uses arithmetic operations and space with the full backtracking table. It is a pseudo-polynomial algorithm, since is a numerical capacity rather than its bit length. A value-only version can use one row, but must update capacities in decreasing order to avoid reusing the same item.
Applying the recurrence in source item order gives the complete table
At inclusion wins, since . Thus and the residual capacity is two. Items three and two are too heavy for it, and item one exactly fits. Consequently
Its weight is . The recurrence proves that no binary selection with capacity seven has greater profit.
For each branch and bound node, relax the unfixed binary variables to . The fractional knapsack problem is solved by decreasing profit-to-weight ratios, here
Its value is an upper bound for the node's integer optimum. At the root, greedy filling gives and upper bound , so branch on .
In the child , the relaxed optimum is with value . Branch on . Taking leaves capacity two, giving the integral solution of value , our incumbent. Taking gives the integral relaxed optimum of value , so that node is closed.
In the child , item four cannot be selected in any integer feasible solution, since their combined weight is nine. Fixing is therefore valid binary feasibility propagation. Its LP optimum is with value . Branch on . The child leaves no residual capacity and has integral solution of value . The child has integral solution of value . Both are below the incumbent.
The complete short search is
All integer feasible solutions lie in these branches, and every terminal node is integral with value at most forty. Therefore the LP bounds and incumbent certify independently of the dynamic program.

Articles by others on the same topic (0)

There are currently no matching articles.