An Improved FPTAS for 0-1 Knapsack Ce Jin Tsinghua University
An Improved FPTAS for 0-1 Knapsack
Ce Jin
Tsinghua University
ð items
Each item ð has weight 0 < ð€ð †ðand profit ðð > 0
Given:
⢠ð€ ðŒ â ÏðâðŒð€ð †ð⢠ð ðŒ â ÏðâðŒ ðð is maximized
Find a subset of items ðŒ â ð such that:
0-1 Knapsack Problem
Knapsack capacity ð > 0
ð items
Each item ð has weight 0 < ð€ð †ðand profit ðð > 0
Given:
⢠ð€ ðŒ â ÏðâðŒð€ð †ð⢠ð ðŒ â ÏðâðŒ ðð is maximized
Find a subset of items ðŒ â ð such that:
A well-known NP-hard problem
0-1 Knapsack Problem
Knapsack capacity ð > 0
FPTAS for 0-1 Knapsack
OPT = optimal total profit ð(ðŒ)
For ð > 0, find a subset ðŒ â ð such that:
⢠ð€ ðŒ †ð
⢠ð ðŒ â¥OPT
1+
Solvable in poly ð,1
time
Prior Work
⢠ේð(ð3/ð) (textbook algorithm)
⢠ේð(ð + ðâ4) [Ibarra and Kim, 1975]
⢠ේð(ð + ðâ3) [Kellerer and Pferschy, 2004]
⢠ේð(ð + ðâ2.5) [Rhee, 2015]
⢠෩ð¶(ð + ðºâð.ð) [Chan, 2018]
FPTAS for 0-1 Knapsack:
Prior Work
⢠ේð(ð3/ð) (textbook algorithm)
⢠ේð(ð + ðâ4) [Ibarra and Kim, 1975]
⢠ේð(ð + ðâ3) [Kellerer and Pferschy, 2004]
⢠ේð(ð + ðâ2.5) [Rhee, 2015]
⢠෩ð¶(ð + ðºâð.ð) [Chan, 2018]
â¢à·©ð¶(ð + ðºâð.ðð) (this work)
FPTAS for 0-1 Knapsack:
No ð ð + ðâ1 2âð¿ time algorithm,
unless ðŠð¢ð§,+ convolution has truly subquadratic algo
[Cygan, Mucha, WÄgrzycki, and WÅodarczyk, 2017]
Conditional Lower Bound:
A Special Case
FPTAS for Subset Sum (ðð = ð€ð):
⢠ේð min ð + ðºâð, ððâ1
[Kellerer, Mansini, Pferschy, and Speranza, 2003]
A Special Case
FPTAS for Subset Sum (ðð = ð€ð):
⢠ේð min ð + ðºâð, ððâ1
[Kellerer, Mansini, Pferschy, and Speranza, 2003]
Our 0-1 Knapsack algorithm utilizes this result
â¢Our à·©ð¶(ð + ðºâð.ðð) algorithm builds on Chanâs à·©ð¶(ð + ðºâð.ð) algorithm
â¢Two new ideas
1. Extending Chanâs number-theoretic technique from two levels to multiple levels.
â¢Our à·©ð¶(ð + ðºâð.ðð) algorithm builds on Chanâs à·©ð¶(ð + ðºâð.ð) algorithm
â¢Two new ideas
1. Extending Chanâs number-theoretic technique from two levels to multiple levels.
2. A greedy argument â less computationspent on cheap items (small unit profit ðð/ð€ð)
â¢Our à·©ð¶(ð + ðºâð.ðð) algorithm builds on Chanâs à·©ð¶(ð + ðºâð.ð) algorithm
â¢Two new ideas
1. Extending Chanâs number-theoretic technique from two levels to multiple levels.
2. A greedy argument â less computationspent on cheap items (small unit profit ðð/ð€ð)
This talk
â¢Our à·©ð¶(ð + ðºâð.ðð) algorithm builds on Chanâs à·©ð¶(ð + ðºâð.ð) algorithm
â¢Two new ideas
1. Extending Chanâs number-theoretic technique from two levels to multiple levels.
2. A greedy argument â less computationspent on cheap items (small unit profit ðð/ð€ð)
This talkUsing Chanâs Lemmas
as blackboxes
à·©ð¶(ð + ðºâð.ððð) algo
Preliminaries (based
on [Chan, 2018])
Preliminaries
â¢Assume ð †poly ðâ1 .
â¢Too cheap items (ðð < ðmaxð
ðð) are
discarded at the beginning (loss †ð â OPT)
So max ðð
min ðð†poly ðâ1
ð items, capacity = ðweight 0 < ð€ð †ð and profit ðð > 0
Preliminaries
ð †poly ðâ1 items
profit max ðð/min ðð †poly ðâ1
weight 0 < ð€ð †ð
⢠âProfit functionâ (defined over real ð¥ ⥠0)ððŒ ð¥ = max ð ðœ : ðœ â ðŒ, ð€ 𜠆ð¥
Preliminaries
ð †poly ðâ1 items
profit max ðð/min ðð †poly ðâ1
weight 0 < ð€ð †ð
⢠âProfit functionâ (defined over real ð¥ ⥠0)ððŒ ð¥ = max ð ðœ : ðœ â ðŒ, ð€ 𜠆ð¥
â¢Task: compute a 1 + ð -approximation of profit function ððŒ,
à·©ððŒ 𥠆ððŒ 𥠆1 + ð à·©ððŒ ð¥ , âð¥ ⥠0
Preliminaries
ð †poly ðâ1 items
profit max ðð/min ðð †poly ðâ1
weight 0 < ð€ð †ð
⢠âProfit functionâ (defined over real ð¥ ⥠0)ððŒ ð¥ = max ð ðœ : ðœ â ðŒ, ð€ 𜠆ð¥
â¢Task: compute a 1 + ð -approximation of profit function ððŒ,
à·©ððŒ 𥠆ððŒ 𥠆1 + ð à·©ððŒ ð¥ , âð¥ ⥠0
â¢For disjoint sets ðŒ, ðœ of items,
ððŒâªðœ ð¥ = ððŒ âððœ ð¥ â max0â€ðŠâ€ð¥
ððŒ ðŠ + ððœ ð¥ â ðŠ
Preliminaries
ð †poly ðâ1 items
profit max ðð/min ðð †poly ðâ1
weight 0 < ð€ð †ð
⢠âProfit functionâ (defined over real ð¥ ⥠0)ððŒ ð¥ = max ð ðœ : ðœ â ðŒ, ð€ 𜠆ð¥
â¢Task: compute a 1 + ð -approximation of profit function ððŒ,
à·©ððŒ 𥠆ððŒ 𥠆1 + ð à·©ððŒ ð¥ , âð¥ ⥠0
â¢For disjoint sets ðŒ, ðœ of items,
ððŒâªðœ ð¥ = ððŒ âððœ ð¥ â max0â€ðŠâ€ð¥
ððŒ ðŠ + ððœ ð¥ â ðŠ
⢠෩ððŒ â à·©ððœ is a 1 + ð -approximation of ððŒâªðœ
Preliminaries
ð †poly ðâ1 items
profit max ðð/min ðð †poly ðâ1
â¢A nondecreasing step function ð has a (1 + ð)-approx. with only à·šð 1/ð steps (by rounding down to powers of (1 + ð))
Preliminaries
â¢A nondecreasing step function ð has a (1 + ð)-approx. with only à·šð 1/ð steps (by rounding down to powers of (1 + ð))
â¢âMerging Lemmaâ: Computing (a 1 + ð -approx. of) ð1 ââ¯âðð takes à·šð ð/ð2
time.
(logð depth binary tree. ðâ² â ð/ logð)
ð â ð â max0â€ðŠâ€ð¥
ð ðŠ + ð ð¥ â ðŠ
â¢Divide items into ð log 1/ð groups
(group ð: ðð â [2ð , 2ð+1])
Preliminaries
ð †poly ðâ1 items
profit max ðð/min ðð †poly ðâ1
weight 0 < ð€ð †ðMerging ð1 ââ¯âðð: à·šð ð/ð2 time.
â¢Divide items into ð log 1/ð groups
(group ð: ðð â [2ð , 2ð+1])
â¢Compute all ðð and merge them in à·šð(1/ð2) time
Preliminaries
ð †poly ðâ1 items
profit max ðð/min ðð †poly ðâ1
weight 0 < ð€ð †ðMerging ð1 ââ¯âðð: à·šð ð/ð2 time.
â¢Divide items into ð log 1/ð groups
(group ð: ðð â [2ð , 2ð+1])
â¢Compute all ðð and merge them in à·šð(1/ð2) time
â¢Now assume ðð â [1,2]
Preliminaries
ð †poly ðâ1 items
profit max ðð/min ðð †poly ðâ1
weight 0 < ð€ð †ðMerging ð1 ââ¯âðð: à·šð ð/ð2 time.
â¢Simple greedy (sort by unit profit ð1
ð€1â¥
ð2
ð€2⥠â¯)
approximates with additive error ð †max ðð =ð(1)
profit ðð â 1,2weight 0 < ð€ð †ð
Preliminaries
â¢Simple greedy (sort by unit profit ð1
ð€1â¥
ð2
ð€2⥠â¯)
approximates with additive error ð †max ðð =ð(1)
â¢For ð ð€ ⥠Ω(ðâ1), this is 1 + ð(ð)multiplicative approx.
profit ðð â 1,2weight 0 < ð€ð †ð
Preliminaries
â¢Simple greedy (sort by unit profit ð1
ð€1â¥
ð2
ð€2⥠â¯)
approximates with additive error ð †max ðð =ð(1)
â¢For ð ð€ ⥠Ω(ðâ1), this is 1 + ð(ð)multiplicative approx.
â¢Only need to 1 + ð(ð) approximate ðŠð¢ð§ ð©, ðð° for ð© = ð¶ ðºâð !
profit ðð â 1,2weight 0 < ð€ð †ð
Preliminaries
â¢Round ðð down to 1,1 + ð, 1 + 2ð, ⊠, 2 â ð
1 + ð multiplicative error
â¢Only ð = ð(1/ð) different ðð âs!
Preliminaries
ðð â 1,2
â¢Round ðð down to 1,1 + ð, 1 + 2ð, ⊠, 2 â ð
1 + ð multiplicative error
â¢Only ð = ð(1/ð) different ðð âs!
â¢Collect all items with the same profit ð. Then ðð can be computed by simple greedy (sort ð€1 †ð€2 †â¯)
Preliminaries
ðð â 1,2
Recap
ðð â 1,2
Profit functions ð1, ⊠, ðð obtained by simple
greedy (one for every ðð) (ð = ð(1/ð) )
Task: 1 + ð ð approximate
min ðµ, ð1 ââ¯âðð (ðµ = ð(ðâ1))
Lemma: Merging ð1 ââ¯âðð in à·šð ð/ð2 time.
(Immediately gives à·šð(ð + ðâ3) algo)
ð items with ð = ð(ðâ1) distinct profit values ðð â 1,2Task: 1 + ð ð approximate
min ðµ, ð1 ââ¯âðð(ðµ = ð(ðâ1))
à·šð ðâ1 ðµð algo(faster when ð© small)
à·šð(ðâ4/3ð + ðâ2) algo(faster when ð small)
Chanâs results
A Greedy Lemma
⢠the items can be divided into two groups ð», ð¿ with a large enough gap between their unit profits,
maxââð¿
ðâ/ð€â †1 â ðŒ â minââð»
ðâ/ð€â
⢠and group ð» is large enough,
Ïââð»ð€â > ð
ðð â 1,2capacity = ð
If
Then
⢠In an optimal solution, ð¿-items contribute total profit †2/ðŒ
ðð â 1,2capacity = ðmaxââð¿
ðâ/ð€â †1 â ðŒ â minââð»
ðâ/ð€â
Ïââð»ð€â > ð
⢠Suppose the optimal solution isðð»âªð¿ ð = ðð» ð âðð¿ + ðð¿ ðð¿
ð âðð¿ðð¿
ð» ð¿
ðð â 1,2capacity = ðmaxââð¿
ðâ/ð€â †1 â ðŒ â minââð»
ðâ/ð€â
Ïââð»ð€â > ð
â¢Remove all ð¿-items, and insert more ð»-items (denoted by ðŸ) to fill in the ðð¿ space
ð âðð¿ðð¿
ð» ð¿
ð âðð¿ðð¿
ððŸ
ðð â 1,2capacity = ðmaxââð¿
ðâ/ð€â †1 â ðŒ â minââð»
ðâ/ð€â
Ïðâð¯ðð > ðŸ
â¢Remove all ð¿-items, and insert more ð»-items (denoted by ðŸ) to fill in the ðð¿ space
â¢Until ðð¿ âððŸ < maxââð» ð€â
ð» ð¿
ð âðð¿ðð¿
ððŸ
ðð â ð, ðcapacity = ðmaxââð¿
ðâ/ð€â †1 â ðŒ â ðŠð¢ð§ðâð¯
ðð/ðð = 1 â ðŒ â ð
Ïââð»ð€â > ð
â¢Remove all ð¿-items, and insert more ð»-items (denoted by ðŸ) to fill in the ðð¿ space
â¢Until ðð¿ âððŸ < maxââð» ð€â †ð/ð
ð» ð¿
ð âðð¿ ðð¿
ððŸ
ðð â 1,2capacity = ðmaxââð¿
ðâ/ð€â †1 â ðŒ â ðŠð¢ð§ðâð¯
ðð/ðð = 1 â ðŒ â ð
Ïââð»ð€â > ððð¿ âððŸ < 2/ð
ð âðð¿ ðð¿
optimal sol:
ðð»âªð¿ ð = ðð» ð âðð¿ + ðð¿ ðð¿
tot profit ⥠ðð» ð âðð¿ + ðððŸ
ð âðð¿ ðð¿
ððŸ
ðð â 1,2capacity = ðmaxââð¿
ðâ/ð€â †1 â ðŒ â ðŠð¢ð§ðâð¯
ðð/ðð = 1 â ðŒ â ð
Ïââð»ð€â > ððð¿ âððŸ < 2/ð
ð âðð¿ ðð¿
optimal sol:
ðð»âªð¿ ð = ðð» ð âðð¿ + ðð¿ ðð¿
tot profit ⥠ðð» ð âðð¿ + ðððŸ
ððŸð² †ðð³ ðŸð³
ð âðð¿ ðð¿
ððŸ
ðð â 1,2capacity = ðmaxââð¿
ðâ/ð€â †1 â ðŒ â ðŠð¢ð§ðâð¯
ðð/ðð = 1 â ðŒ â ð
Ïââð»ð€â > ððŸð³ âðŸð² < ð/ð
ð âðð¿ ðð¿
optimal sol:
ðð»âªð¿ ð = ðð» ð âðð¿ + ðð¿ ðð¿
tot profit ⥠ðð» ð âðð¿ + ðððŸ
ððŸð² †ðð³ ðŸð³
1 â ðŒ â ð â ðð¿ ⥠ðð¿ ðð¿
ðð¿ ðð¿ ⥠ðððŸ
ðððŸ > ððð¿ â 2â
1 â ðŒ â ððð¿ > ððð¿ â 2
ðŒððð¿ < 2
ðð¿ ðð¿ < 2/ðŒ
ð âðð¿ ðð¿
ððŸ
ðð â 1,2capacity = ðmaxââð¿
ðâ/ð€â †1 â ðŒ â ðŠð¢ð§ðâð¯
ðð/ðð = 1 â ðŒ â ð
Ïââð»ð€â > ððŸð³ âðŸð² < ð/ð
ð âðð¿ ðð¿
optimal sol:
ðð»âªð¿ ð = ðð» ð âðð¿ + ðð¿ ðð¿
tot profit ⥠ðð» ð âðð¿ + ðððŸ
ððŸð² †ðð³ ðŸð³
1 â ðŒ â ð â ðð¿ ⥠ðð¿ ðð¿
ðð¿ ðð¿ ⥠ðððŸ
ðððŸ > ððð¿ â 2â
1 â ðŒ â ððð¿ > ððð¿ â 2â
ðŒððð¿ < 2
ðð¿ ðð¿ < 2/ðŒ
ð âðð¿ ðð¿
ððŸ
ðð â 1,2capacity = ðmaxââð¿
ðâ/ð€â †1 â ðŒ â ðŠð¢ð§ðâð¯
ðð/ðð = 1 â ðŒ â ð
Ïââð»ð€â > ððŸð³ âðŸð² < ð/ð
ð âðð¿ ðð¿
optimal sol:
ðð»âªð¿ ð = ðð» ð âðð¿ + ðð¿ ðð¿
tot profit ⥠ðð» ð âðð¿ + ðððŸ
ððŸð² †ðð³ ðŸð³
ð â ð¶ â ð â ðŸð³ ⥠ðð³ ðŸð³
ðð¿ ðð¿ ⥠ðððŸ
ðððŸ > ððð¿ â 2â
1 â ðŒ â ððð¿ > ððð¿ â 2â
ð¶ððŸð³ < ðâ
ðð³ ðŸð³ < ð/ð¶
Recap
If: maxââð¿
ðâ/ð€â †1 â ðŒ â minââð»
ðâ/ð€â
Ïââð»ð€â > ðThen: In optimal solution of ðð»âªð¿(ð), ð¿-items
contribute total profit †2/ðŒ
Task: 1 + ð ð approximate min ðµ, ððŒ , ðµ = ð(ðâ1)
ð = ð(ðâ1) distinct values
ðð â 1,2
à·šð ðâ1 ðµð algo (Chan)
(faster when ð© small)
à·šð(ðâ4/3ð + ðâ2) algo (Chan)(faster when ð small)
Improved Algorithm
â¢Sort the items by ðð/ð€ð, and divide into three groups
ðð â 1,2
Improved Algorithm
â¢Sort the items by ðð/ð€ð, and divide into three groups
ð»: top
Î ðâ1
items
ðð â 1,2
Improved Algorithm
â¢Sort the items by ðð/ð€ð, and divide into three groups
ð»: top
Î ðâ1
items
ð¿: (1 â ðŒ)multiplicative
gap
ð (ð â ð¶)ð
ðð â 1,2
Improved Algorithm
â¢Sort the items by ðð/ð€ð, and divide into three groups
ð»: top
Î ðâ1
items
ð¿: (1 â ðŒ)multiplicative
gap
ð (1 â ðŒ)ð
ð: items in
between
ðð â 1,2
Improved Algorithm
ð (1 â ðŒ)ðð» = Î(ðâ1)
ð» ð ð¿
If: maxââð¿
ðâ/ð€â †1 â ðŒ â minââð»
ðâ/ð€â
Ïââð»ð€â > ðThen: In optimal solution of ðð»âªð¿(ð), ð¿-items
contribute total profit †2/ðŒ
Task: 1 + ð ð approximate min ð(ðâ1), ððŒ
ðð â 1,2
If: maxââð¿
ðâ/ð€â †1 â ðŒ â minââð»
ðâ/ð€â
Ïââð»ð€â > ðThen: In optimal solution of ðð»âªð¿(ð), ð¿-items
contribute total profit †2/ðŒ
Improved Algorithm
ð (1 â ðŒ)ðð» = Î(ðâ1)
ð» ð ð¿
ðð â 1,2
Task: 1 + ð ð approximate min ð(ðâ1), ððŒ
Improved Algorithm
ð (1 â ðŒ)ðð¯ = ð¯(ðºâð)
ð» ð ð¿
(If ðð° ðŸ < ð¶(ðºâð) then ðŸ < ð(ð¯))
Task: 1 + ð ð approximate ðŠð¢ð§ ð¶(ðºâð), ðð°
If: maxââð¿
ðâ/ð€â †1 â ðŒ â minââð»
ðâ/ð€â
Ïââð»ð€â > ðThen: In optimal solution of ðð»âªð¿(ð), ð¿-items
contribute total profit †2/ðŒðð â ð, ð
Improved Algorithm
ð (1 â ðŒ)ðð» = Î(ðâ1)
ð» ð ð¿
Task: 1 + ð ð approximate min ð(ðâ1), ððŒ
If: maxââð¿
ðâ/ð€â †1 â ðŒ â minââð»
ðâ/ð€â
Ïââð»ð€â > ðThen: In optimal solution of ðð»âªð¿(ð), ð¿-items
contribute total profit †2/ðŒðð â 1,2
ðŠð¢ð§{ðð³ , ð/ð¶}
Improved Algorithm
ð (1 â ðŒ)ðð» = Î(ðâ1)
ð» ð ð³
min{ðð¿ , 2/ðŒ}
à·šð ðâ1 ðµð algo (Chan)
(faster when ð© small)à·šð(ðâ4/3ð + ðâ2) algo (Chan)
(faster when ð small)
Let ð¶ = ðºð/ðà·©ð¶(ðºâð/ð)
à·©ð¶(ðºâð/ð)
ð â ð¯ â ð/ðº ð© â ð/ð¶
ð â ð ðâ1
Improved Algorithm
ð (1 â ðŒ)ð
ð» ð ð³
Let ð¶ = ðºð/ð
à·šð ðâ7/3 -time à·šð(ðâ7/3)-time
Group ð: Round ðð/ð€ð
down to powers of (1 + ð)
Improved Algorithm
ð (1 â ðŒ)ð
ð» ð ð³
Let ð¶ = ðºð/ð
à·šð ðâ7/3 -time à·šð(ðâ7/3)-time
Group ð: Round ðð/ð€ð
down to powers of (1 + ð)
Only log1+1
1âðŒâ ðŒ/ð = ðºâð/ð
distinct values of ðð/ð€ð
Improved Algorithm
ð (1 â ðŒ)ð
ð» ð ð³
Let ð¶ = ðºð/ð
à·šð ðâ7/3 -time à·šð(ðâ7/3)-time
Group ð: Round ðð/ð€ð
down to powers of (1 + ð)
Only log1+1
1âðŒâ ðŒ/ð = ðºâð/ð
distinct values of ðð/ð€ð
Items with the same ðð/ð€ð
(profit â weight ): a Subset
Sum instance
à·šð(ð + ðâ2) time [KMPS03]
Improved Algorithm
ð (1 â ðŒ)ð
ð» ð ð³
Let ð¶ = ðºð/ð
à·šð ðâ7/3 -time à·šð(ðâ7/3)-time
Group ð: Round ðð/ð€ð
down to powers of (1 + ð)
Only log1+1
1âðŒâ ðŒ/ð = ðºâð/ð
distinct values of ðð/ð€ð
Items with the same ðð/ð€ð
(profit â weight ): a Subset
Sum instance
à·šð(ð + ðâ2) time [KMPS03]
Merge ðºâð/ð groups
Improved Algorithm
ð (1 â ðŒ)ð
ð» ð ð³
Let ð¶ = ðºð/ð
à·šð ðâ7/3 -time à·šð(ðâ7/3)-time
Group ð: Round ðð/ð€ð
down to powers of (1 + ð)
Only log1+1
1âðŒâ ðŒ/ð = ðºâð/ð
distinct values of ðð/ð€ð
Items with the same ðð/ð€ð
(profit â weight ): a Subset
Sum instance
à·šð(ð + ðâ2) time [KMPS03]
ð + ðºâð/ð â ðâ2
Merge ðºâð/ð groups
Improved Algorithm
ð (1 â ðŒ)ð
ð» ð ð³
Let ð¶ = ðºð/ð
à·šð ðâ7/3 -time à·šð(ðâ7/3)-time
Group ð: Round ðð/ð€ð
down to powers of (1 + ð)
Only log1+1
1âðŒâ ðŒ/ð = ðºâð/ð
distinct values of ðð/ð€ð
Items with the same ðð/ð€ð
(profit â weight ): a Subset
Sum instance
à·šð(ð + ðâ2) time [KMPS03]
ð + ðºâð/ð â ðâ2
Merge ðºâð/ð groups
Total time:à·©ð¶ ð + ðºâð/ð
Further improvement
à·šð ðâ1 ðµð (Chan)
(faster when ð© small)
à·šð(ðâ4/3ð + ðâ2) (Chan)(faster when ð small)
à·šð(ðâ3/2ð3/4 + ð + ðâ2)(faster when ð small)
à·šð ðâ4/3ðµ1/3ð2/3(ð2 â« ðâ2/ðµ)
(faster when ð© small)
à·šð(ð + ðâ9/4)
Greedy argument (this talk)
extending Chanâs
techniques from two levels
to multiple levels
Open problem
Unbounded Knapsack (each item has infinitely
many copies) which easily reduces to 0-1
Knapsack:
à·šð(ð + ðâ2) [Jansen and Kraft, 2015]
Improve 0-1 Knapsack to à·šð(ð + ðâ2) time?
à·šð min ð + ðºâð, ððâ1
[Kellerer, Mansini, Pferschy, and Speranza, 2003]
Subset Sum:
Thank you!