日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

Approximation

發(fā)布時(shí)間:2024/3/26 编程问答 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Approximation 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

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

總結(jié)

以上是生活随笔為你收集整理的Approximation的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。