Approximation
Approximation ratio
【Definition】 An algorithm has an approximation ratio of ρ\rhoρ(n) if, for any input of size n, the cost C of the solution produced by the algorithm is within a factor of ρ\rhoρ (n) of the cost C* of an optimal solution: max(CC?,C?C)≤ρ(n)\frac{C}{C^*},\frac{C^*}{C}) \leq \rho(n)C?C?,CC??)≤ρ(n)
If an algorithm achieves an approximation ratio of ρ\rhoρ(n), we call it a ρ\rhoρ(n)-approximation algorithm.
【Definition】 An approximation scheme for an optimization problem is an approximation algorithm that takes as input not only an instance of the problem, but also a value ?\epsilon? > 0 such that for any fixed ?\epsilon?, the scheme is a (1+ ?\epsilon?)-approximation algorithm.
We say that an approximation scheme is a polynomial-time approximation scheme (PTAS) if for any fixed ?\epsilon? > 0, the scheme runs in time polynomial in the size n of its input instance.
eg. O((1/?)2n3)O((1/ \epsilon)^2 n^3)O((1/?)2n3) --> FPTAS (fully …) , O(n?/2)O(n^{\epsilon/2})O(n?/2), …
Approximate Bin Packing
Online Algorithms
next fit
void NextFit ( ) { read item1;while ( read item2 ) {if ( item2 can be packed in the same bin as item1 )place item2 in the bin;elsecreate a new bin for item2;item1 = item2;} /* end-while */ }Let M be the optimal number of bins required to pack a list I of items. Then next fit never uses more than 2M – 1 bins. There exist sequences such that next fit uses 2M – 1 bins.
first fit
void FirstFit ( ) { while ( read item ) {scan for the first bin that is large enough for item;if ( found )place item in that bin;elsecreate a new bin for item;} /* end-while */ }Let M be the optimal number of bins required to pack a list I of items. Then first fit never uses more than 17M / 10 bins. There exist sequences such that first fit uses 17(M – 1) / 10 bins.
best fit
Off-line Algorithm
first fit decreasing
Let M be the optimal number of bins required to pack a list I of items. Then first fit decreasing never uses more than 11M / 9 + 6/9 bins. There exist sequences such that first fit decreasing uses 11M / 9 + 6/9 bins.
best fit decreasing
Exercises
總結
以上是生活随笔為你收集整理的Approximation的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Dr.Web(大蜘蛛)中天专用一瓢凉水特
- 下一篇: python networkx.algo