Upload
ach-ref
View
4
Download
0
Embed Size (px)
DESCRIPTION
dynamic programming (rod cut)
Citation preview
Rod cutting
Rod cuttingDecide where to cut steel rods:Given a rod of length n inches and a table of prices pi, i=1,2,,n, find the maximum revenue rn obtainable by cutting up the rod and selling the piecesRod lengths are integersFor i=1,2,,n we know the price pi of a rod of length i inchesExamplelength I: 1 2 3 4 5 6 7 8 9 10------------------------------------------------price pi: 1 5 8 9 10 17 17 20 24 30
For a rod of length 4: 2+2 is optimal (p2+p2=10)In general, can cut a rod of length n 2n-1 waysIf optimal sol. cuts rod in k pieces then optimal decomposition: n=i1+i2++ikRevenue: rn=pi1+pi2++pikIn general: rn=max{pn,r1+rn-1,r2+rn-2,,rn-1+r1}Initial cut of the rod: two pieces of size i and n-IRevenue ri and rn-i from those two piecesNeed to consider all possible values of iMay get better revenue if we sell the rod uncut
A different view of the problemDecomposition inA first, left-hand piece of length iA right-hand reminder of length n-iOnly the reminder is further dividedThenrn=max{pi+rn-i, 1