跳转至

Approximation

  • Find near-optimal solutions in polynomial time

Approximation Ratio

1 If an algorithm achieves an approximation ratio of ρ(n), we call it aρ(n)-approximation algorithm. 2

Approximate Bin Packing Given N items of sizes S1,S2,,SN , such that 0<Si1 for all 1iN . Pack these items in the fewest number of bins, each of which has unit capacity. Example : N = 7; Si = 0.2, 0.5, 0.4, 0.7, 0.1, 0.3, 0.8

3

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 */
}
4 * Therefore the NextFit algorithm is a 2-approximation algorithm for the bin packing problem.[approximation ratio = 2]
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 */
}
* Time complexity of FirstFit is O(nlogn) * But the approximation ratio of FirstFit is 2. 5

6

On-line Algorithms Place an item before processing the next one, and can NOT change decision.

Off-line Algorithms View the entire item list before producing an answer. 7

The Knapsack Problem — fractional version

A knapsack with a capacity M is to be packed. Given N items. Each item i has a weight wi and a profit pi . If xi is the percentage of the item i being packed, then the packed profit will be pixi . * An optimal packing is a feasible one with maximum profit. That is, we are supposed to find the values of xi such that i=1npixi obtains its maximum under the constrains: $\sum\limits_{i=1}^{n}w_ix_i \le M $ and x[0,1] for 1in

8

The Knapsack Problem — 0-1 version

  • NPC and NP-hard 9

  • popt is the optimal solution for the frac version

  • For the 0-1 problem, difference lies in the last object(may not be put into the package),and this last item has cost pmax
  • Therefore poptpgreedy+pmax

Solve in Dynamic Programming

10

  • Another Solution(just search)

11

The K-center Problem

12

Refer to Slides.


最后更新: 2024年5月17日 15:36:16
创建日期: 2024年5月17日 15:36:16
Is this page helpful?