算法高级教程3.10.2OnlineBipartiteMatching优质PPT.pptx
《算法高级教程3.10.2OnlineBipartiteMatching优质PPT.pptx》由会员分享,可在线阅读,更多相关《算法高级教程3.10.2OnlineBipartiteMatching优质PPT.pptx(75页珍藏版)》请在冰豆网上搜索。
,OnlineBipartiteMatching,Amatchmakerandnboysaregatheredinaroom.ngirlsappear,oneatatime.Eachgirlhasalistofboyswhoareacceptabletoher,whichsherevealstothematchmakerassheappears.Thematchmakerimmediatelymatchesthenewgirltooneoftheboysonherlist,ifanyofthemareavailable.Thegoalistomaximizethenumberofmatches.,2,ImportanceofMatching,ResourceAllocationSchedulingMemoryManagementRoutingRobotMotionPlanningExploringanunknownterrainFindingadestinationComputationalFinance,Subroutineinmanyotheralgorithms.,GivenasinputabipartitegraphG=(U,V,E)inwhicheachvertexuU(girls)arrivesinonlinefashion,deviseanalgorithmthatmatchesu(girl)toone(boy)ofitspreviouslyunmatchedneighboursinV.Thematchinghastobeimmediateandisirrevocable,oncemade.Theobjectiveistomaximizethesizeoftheresultingmatching.AssumethattheinputgraphGhasaperfectmatchingi.e.amatchingofsizen.Wedenoteaperfectmatchingbyafunctionm:
@#@UV.Hence,ac-competitivealgorithmmustreturnamatchingofsizeatleastcn.,4,DeterministicAlgorithm,whenuarrivesassignittoasomeunmatchedneighbour.Lemma3.10.1.Theabovealgorithmhasacompetitiveratioof1/2.Proof.Ifavertexu1isnotpresentintheresultingmatchingM,thenitdoesnothaveanunmatchedneighbour,ifnot,wewouldhavematchedu1tothatneighbour.Hence,theresultingmatchingmustbemaximal.Foreveryedgeu,m(u),eithervertexuorm(u)ispresentinM.So,atleastn/2verticesarematchedandhencethealgorithmhasacompetitiveratioof1/2.,5,Onlinebipartitematching,V(boys),U(girls),Onlinebipartitematching,V(boys),U(girls),Onlinebipartitematching,V(boys),U(girls),Onlinebipartitematching,V(boys),U(girls),Onlinebipartitematching,V(boys),U(girls),Onlinebipartitematching,V(boys),U(girls),Onlinebipartitematching,V(boys),U(girls),Wecanprovethatanydeterministicalgorithmcannotdobetterthantheobviousalgorithm.Anadversarycanlimitthesizeofmatchington/2inthefollowingway:
@#@Letthefirstn/2verticesthatarrivehaveedgestoalltheverticesinV.Clearly,theadversarycandeterminetheverticesinVthatwillbematched.Letthenextn/2verticesthatarrivecontainedgesonlytothoseverticesinVwhicharealreadymatched.Theinputgraphhasaperfectmatchingbutthesecondhalfoftheverticesarenotmatched;@#@henceouranalysisistightforthedeterministiccase.,13,Onlinebipartitematching,n/2,:
@#@n/2:
@#@,V(boys),U(girls),Onlinebipartitematching,n/2,:
@#@n/2:
@#@,V(boys),U(girls),Onlinebipartitematching,:
@#@,:
@#@,n/2,V(boys),U(girls),RandomizedAlgorithm,Foreachpossibleinput,calculatetheexpectationoftheanswerandtaketheworstexpectedvalueamongalltheinputs.Inourcase,aninputinstancewouldbespecifiedbyagraphGalongwithanarrivalorder.Sotheinputspacewouldcontainallpossible(G,)pairs.Themostnaturalwaytointroducerandomnesswouldbetomatchutooneoftheunmatchedneighbourspickedrandomly.Thisalgorithmperformsbetterthanthedeterministicalgorithm;@#@howevertheimprovementisnotsubstantial.,17,Lemma3.10.2.Arandomizedalgorithmthatpicksanunmatchedneighbouruniformlyandrandomlyhasacompetitiveratioofatmost1/2+O(logn)/n.Proof.Toseewhythisisthecase,considerthefollowinginput.Letu1,.,unUandv1,.,vnV.Thereisanedgebetweenuiandviforalli.EveryvertexinthefirsthalfofU=u1,.,un/2isconnectedtoeveryvertexinthesecondhalfofV=vn/2,.,vnasshownbelow:
@#@,18,Onlinebipartitematching,:
@#@,:
@#@,n/2,n/2,VU,u1,un/2un/2+1,:
@#@,:
@#@,v(boys)(girls),1,vn/2vn/2+1,vnun,Tightinstanceforthenaverandomizedalgorithm,Theverticesarriveintheorderoftheirindices.Intuitively,thealgorithmfailstoperformwellonthisinputsinceitmatchestoomanyusfromthefirsthalftothevsofthesecondhalf.Thefirstn/2verticesfromUaredefinitelyinthematchingsinceallofthemgetatleastoneunmatchedneighbourwhentheyarrive.EachuifromthesecondhalfofUcanbematchedtovi,ifviisnotalreadymatched.Whatistheprobabilitythatthishappens?
@#@,20,LetusfindtheexpectednumberofverticesthatarematchedinthefirsthalfofV.Whenu1arrives,itcanpickeitherv1orvn/2,.,vn.Sotheprobabilityofv1gettingmatchedis1/(n/2+1).Similarly,whenu2arrives,theprobabilitythatv2getsmatchedis:
@#@,21,Similarly,probabilityofv3gettingmatchedislessthan1/(n/21)andingeneralavertexviinthefirsthalfofVhaslessthan1/(n/2i+2)probabilityofbeinginthematching.LetEvbetheexpectednumberofverticesfromv1,.,vn/2inthematching.,Hence,lessthanO(logn)unmatchedneighboursareexpectedtobeavailabletothesecondhalfofU,whichprovesourclaim.22,Rankingalgorithm,Aslightlydifferentrandomizedalgorithm,namedRankingKarp,performsmuchbetter.Thealgorithmisasfollows:
@#@Ranking()Initialization:
@#@Pickarandompermutation(ranking)oftheverticesinVForeachuUthatarrives:
@#@