算法设计与分析算法设计与分析 (12).ppt
《算法设计与分析算法设计与分析 (12).ppt》由会员分享,可在线阅读,更多相关《算法设计与分析算法设计与分析 (12).ppt(43页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、1Chapter 11ApproximationAlgorithmsSlides by Kevin Wayne.Copyright 2005 Pearson-Addison Wesley.All rights reserved.2Approximation AlgorithmsQ.Suppose I need to solve an NP-hard problem.What should I do?A.Theory says youre unlikely to find a poly-time algorithm.Must sacrifice one of three desired feat
2、ures.nSolve problem to optimality.nSolve problem in poly-time.nSolve arbitrary instances of the problem.-approximation algorithm.nGuaranteed to run in poly-time.nGuaranteed to solve arbitrary instance of the problemnGuaranteed to find solution within ratio of true optimum.Challenge.Need to prove a s
3、olutions value is close to optimum,without even knowing what optimum value is!11.1 Load Balancing4Load BalancingInput.m identical machines;n jobs,job j has processing time tj.nJob j must run contiguously on one machine.nA machine can process at most one job at a time.Def.Let J(i)be the subset of job
4、s assigned to machine i.Theload of machine i is Li=j J(i)tj.Def.The makespan is the maximum load on any machine L=maxi Li.Load balancing.Assign each job to a machine to minimize makespan.5List-scheduling algorithm.nConsider n jobs in some fixed order.nAssign job j to machine whose load is smallest s
5、o far.Implementation.O(n log m).Load Balancing:List Scheduling6Load Balancing:List Scheduling AnalysisTheorem.Graham,1966 Greedy algorithm is a 2-approximation.nFirst worst-case analysis of an approximation algorithm.nNeed to compare resulting solution with optimal makespan L*.Lemma 1.The optimal ma
6、kespan L*maxj tj.Pf.Some machine must process the most time-consuming job.Lemma 2.The optimal makespan Pf.nThe total processing time is j tj.nOne of m machines must do at least a 1/m fraction of total work.7Load Balancing:List Scheduling AnalysisTheorem.Greedy algorithm is a 2-approximation.Pf.Consi
7、der load Li of bottleneck machine i.nLet j be last job scheduled on machine i.nWhen job j assigned to machine i,i had smallest load.Its load before assignment is Li-tj Li-tj Lk for all 1 k m.j0L=LiLi-tj machine iblue jobs scheduled before j8Load Balancing:List Scheduling AnalysisTheorem.Greedy algor
8、ithm is a 2-approximation.Pf.Consider load Li of bottleneck machine i.nLet j be last job scheduled on machine i.nWhen job j assigned to machine i,i had smallest load.Its load before assignment is Li-tj Li-tj Lk for all 1 k m.nSum inequalities over all k and divide by m:nNowLemma 1Lemma 29Load Balanc
9、ing:List Scheduling AnalysisQ.Is our analysis tight?A.Essentially yes.Ex:m machines,m(m-1)jobs length 1 jobs,one job of length mmachine 2 idlemachine 3 idlemachine 4 idlemachine 5 idlemachine 6 idlemachine 7 idlemachine 8 idlemachine 9 idlemachine 10 idlelist scheduling makespan=19m=1010Load Balanci
10、ng:List Scheduling AnalysisQ.Is our analysis tight?A.Essentially yes.Ex:m machines,m(m-1)jobs length 1 jobs,one job of length mm=10optimal makespan=1011Load Balancing:LPT RuleLongest processing time(LPT).Sort n jobs in descending order of processing time,and then run list scheduling algorithm.12Load
11、 Balancing:LPT RuleObservation.If at most m jobs,then list-scheduling is optimal.Pf.Each job put on its own machine.Lemma 3.If there are more than m jobs,L*2 tm+1.Pf.nConsider first m+1 jobs t1,tm+1.nSince the tis are in descending order,each takes at least tm+1 time.nThere are m+1 jobs and m machin
12、es,so by pigeonhole principle,at least one machine gets two jobs.Theorem.LPT rule is a 3/2 approximation algorithm.Pf.Same basic approach as for list scheduling.Lemma 3(by observation,can assume number of jobs m)13Load Balancing:LPT RuleQ.Is our 3/2 analysis tight?A.No.Theorem.Graham,1969 LPT rule i
13、s a 4/3-approximation.Pf.More sophisticated analysis of same algorithm.Q.Is Grahams 4/3 analysis tight?A.Essentially yes.Ex:m machines,n=2m+1 jobs,2 jobs of length m+1,m+2,2m-1 and one job of length m.11.2 Center Selection15centerr(C)Center Selection ProblemInput.Set of n sites s1,sn.Center selectio
14、n problem.Select k centers C so that maximum distance from a site to nearest center is minimized.sitek=416Center Selection ProblemInput.Set of n sites s1,sn.Center selection problem.Select k centers C so that maximum distance from a site to nearest center is minimized.Notation.ndist(x,y)=distance be
15、tween x and y.ndist(si,C)=min c C dist(si,c)=distance from si to closest center.nr(C)=maxi dist(si,C)=smallest covering radius.Goal.Find set of centers C that minimizes r(C),subject to|C|=k.Distance function properties.ndist(x,x)=0(identity)ndist(x,y)=dist(y,x)(symmetry)ndist(x,y)dist(x,z)+dist(z,y)
16、(triangle inequality)17Greedy Algorithm:A False StartGreedy algorithm.Put the first center at the best possible location for a single center,and then keep adding centers so as to reduce the covering radius each time by as much as possible.Remark:arbitrarily bad!greedy center 1k=2 centerssitecenter18
17、Center Selection:Greedy AlgorithmGreedy algorithm.Repeatedly choose the next center to be the site farthest from any existing center.Observation.Upon termination all centers in C are pairwise at least r(C)apart.Pf.By construction of algorithm.19Center Selection:Analysis of Greedy AlgorithmTheorem.Le
18、t C*be an optimal set of centers.Then r(C)2r(C*).Pf.(by contradiction)Assume r(C*)r(C).nFor each site ci in C,consider ball of radius r(C)around it.nExactly one ci*in each ball;let ci be the site paired with ci*.nConsider any site s and its closest center ci*in C*.ndist(s,C)dist(s,ci)dist(s,ci*)+dis
19、t(ci*,ci)2r(C*).nThus r(C)2r(C*).C*sites r(C)cici*s r(C*)since ci*is closest center r(C)r(C)-inequality20Center SelectionTheorem.Greedy algorithm is a 2-approximation for center selection problem.Question.Is there hope of a 3/2-approximation?4/3?Theorem.Unless P=NP,there no-approximation for center-
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 算法设计与分析算法设计与分析 12 算法 设计 分析 12
限制150内