Approximation¶
- Find near-optimal solutions in polynomial time
Approximation Ratio¶
If an algorithm achieves an approximation ratio of
Approximate Bin Packing
Given N items of sizes
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 */
}

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 */
}

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.
The Knapsack Problem — fractional version¶
A knapsack with a capacity
The Knapsack Problem — 0-1 version¶
-
NPC and NP-hard
-
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
- Therefore
Solve in Dynamic Programming¶
- Another Solution(just search)
The K-center Problem¶
Refer to Slides.
创建日期: 2024年5月17日 15:36:16