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( C C ∗ , C ∗ C ) ≤ ρ ( n ) \frac{C}{C^*},\frac{C^*}{C}) \leq \rho(n) CC,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 / ϵ ) 2 n 3 ) 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;
        else
	create 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;
        else
	create 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_第1张图片

你可能感兴趣的:(Advanced,Data,Structure)