Solving 0-1 knapsack problems based on amoeboid organism algorithm
An Improved FPTAS for 0-1 KnapsackΒ Β· FPTAS for 0-1 Knapsack OPT = optimal total profit ( ) For...
Transcript of An Improved FPTAS for 0-1 KnapsackΒ Β· FPTAS for 0-1 Knapsack OPT = optimal total profit ( ) For...
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!