Ar#ficialIntelligence
Dr.QaiserAbbasDepartmentofComputerScience&IT,
UniversityofSargodha,Sargodha,40100,[email protected]
Saturday,23April16 1
3.5INFORMED(HEURISTIC)SEARCHSTRATEGIES
• Informedsearchstrategy—onethatusesproblem-specificknowledgebeyondthedefiniOonoftheproblemitself—canfindsoluOonsmoreefficientlythancananuninformedstrategy.
• Mostbest-firstalgorithmsincludeaheuris#cfunc#on,denotedh(n),whereh(n)=esOmatedcostofthecheapestpathfromthestateatnodentoagoalstate.
• h(n)takesanodeasinputanditdependsonlyonthestateatthatnode.Forexample,inRomania,onemightesOmatethecostofthecheapestpathfromAradtoBucharestviathestraight-linedistancefuncOonfromAradtoBucharest.
• HeurisOcfuncOonsarethemostcommonforminwhichaddiOonalknowledgeoftheproblemisimpartedtothesearchalgorithm.
• ThissecOoncoverstwowaystouseheurisOcinformaOontoguidesearch.
Saturday,23April16 2
3.5.1Greedybest-firstsearch• Greedybest-firstsearchtriestoexpandthenodethatisclosesttothegoal.• Letusseehowthisworksforroute-findingproblemsinRomania.• weusethestraight-linedistanceheurisOc,whichwewillcallh.Ifthegoalis
Bucharest,weneedtoknowthestraight-linedistancestoBucharest,whichareshowninFigure3.2and3.22.
Saturday,23April16 3
3.5.1Greedybest-firstsearch• Figure3.23showstheprogressofagreedybest-firstsearchusinghSLDtofinda
pathfromAradtoBucharest.ThefirstnodetobeexpandedfromAradwillbeSibiubecauseitisclosertoBucharestthaneitherZerindorTimisoara.ThenextnodetobeexpandedwillbeFagarasbecauseitisclosest.FagarasinturngeneratesBucharest,whichisthegoal.
• ItisnotopOmal,however:thepathviaSibiuandFagarastoBucharestis32kilometerslongerthanthepaththroughRimnicuVilceaandPitesO.Thisshowswhythealgorithmiscalled“greedy”—ateachstepittriestogetasclosetothegoalasitcan.
Saturday,23April16 4
3.5.1Greedybest-firstsearch
Saturday,23April16 5
3.5.1Greedybest-firstsearch• Greedybest-firsttreesearchisalsoincompleteeveninafinitestatespace,much
likedepth-firstsearch.• ConsidertheproblemofgebngfromIasitoFagaras.TheheurisOcsuggeststhat
NeamtbeexpandedfirstbecauseitisclosesttoFagaras,butitisadeadend.• ThesoluOonistogofirsttoVaslui—astepthatisactuallyfartherfromthegoal
accordingtotheheurisOc—andthentoconOnuetoUrziceni,Bucharest,andFagaras.
• ThealgorithmwillneverfindthissoluOon,however,becauseexpandingNeamtputsIasibackintothefronOer,IasiisclosertoFagarasthanVasluiis,andsoIasiwillbeexpandedagain,leadingtoaninfiniteloop.(Thegraphsearchversioniscompleteinfinitespaces,butnotininfiniteones.)
• Theworst-caseOmeandspacecomplexityforthetreeversionisO(bm),wheremisthemaximumdepthofthesearchspace.
• WithagoodheurisOcfuncOon,however,thecomplexitycanbereducedsubstanOally.TheamountofthereducOondependsontheparOcularproblemandonthequalityoftheheurisOc.
Saturday,23April16 6
3.5.2A*search:Minimizingthetotales#matedsolu#oncost3.5.2A*search:Minimizingthetotal
• Themostwidelyknownformofbest-firstsearchiscalledA∗search(pronounced“A-starsearch”).
• Itevaluatesnodesbycombiningg(n)andh(n)asf(n)=g(n)+h(n),where• Themostwidelyknownformofbest-firstsearchiscalledA∗search(pronounced“A-starsearch”).• Itevaluatesnodesbycombiningg(n)andh(n)asf(n)=g(n)+h(n),where
g(n)givesthepathcostfromthestartnodetonoden,andh(n)istheesOmatedcostofthecheapestpathfromntothegoal,so,wehavef(n)=
esOmatedcostifthecheapestsoluOonthroughn.• Condi#onsforop#mality:Admissibilityandconsistency– ThefirstcondiOonwerequireforopOmalityisthath(n)beanadmissibleheuris#c
• ThealgorithmisidenOcaltoUNIFORM-COST-SEARCHexceptthatA∗usesg+hinsteadofg.• Condi#onsforop#mality:Admissibilityandconsistency– ThefirstcondiOonwerequireforopOmalityisthath(n)beanadmissibleheuris#c(acceptable).
Saturday,23April16 7
3.5.2A*search:Minimizingthetotales#matedsolu#oncostes#matedsolu#oncost
straight-linedistancestraight-linedistancehSLDhSLDthatweusedingebngto
Bucharest.Straight-linedistanceisadmissiblebecausetheshortestpathbetweenanytwopointsisastraightline,sothestraightlinecannotbeanoveresOmate.InFigure3.24givenonnextslide,weshowtheprogressofanA∗treesearchforBucharest.ThevaluesofgarecomputedfromthestepcostsinFigure3.2,andthevaluesofhSLD
aregiveninFigure3.22.Havealookovertitfirst!
– Asecond,slightlystrongercondiOoncalledconsistency(orsomeOmesmonotonicity)isrequiredonlyforapplicaOons
Saturday,23April16 9Figure3.24
3.5.2A*search:Minimizingthetotales#matedsolu#oncost
– AheurisOch(n)isconsistentif,foreverynodenandeverysuccessornʹofngeneratedbyanyacOona,theesOmatedcostofreachingthegoalfromnisnogreaterthanthestepcostofgebngtonʹplustheesOmatedcostofreachingthegoalfromnʹ:h(n)≤c(n,a,nʹ)+h(nʹ).
– Thisisaformofthegeneraltriangleinequality,whichsOpulatesthateachsideofatrianglecannotbelongerthanthesumoftheothertwosides.Consider,forexample,hSLD.WeknowthatthegeneraltriangleinequalityissaOsfiedwheneachsideismeasuredbythestraight-linedistanceandthatthestraight-linedistancebetweennandnʹisnogreaterthanc(n,a,nʹ).Hence,hSLDisaconsistentheurisOc.
Saturday,23April16 10
3.5.2A*search:Minimizingthetotales#matedsolu#oncost
• Op#malityofA*– A∗hasthefollowingproperOes:(1)thetree-searchversionofA∗isop1malifh(n)isadmissible,(2)whilethegraph-searchversionisop1malifh(n)isconsistent.
– Weshowthesecondofthesetwoclaimssinceitismoreuseful.TheargumentessenOallymirrorstheargumentfortheopOmalityofuniform-costsearch.
– Thefirststepistoestablishthefollowing:ifh(n)isconsistent,thenthevaluesoff(n)alonganypatharenondecreasing.
– TheprooffollowsdirectlyfromthedefiniOonofconsistency.Supposenʹisasuccessorofn;theng(nʹ)=g(n)+c(n,a,nʹ)forsomeacOona,andwehavef(nʹ)=g(nʹ)+h(nʹ)=g(n)+c(n,a,nʹ)+h(nʹ)≥g(n)+h(n)=f(n).
Saturday,23April16 11
3.5.2A*search:Minimizingthetotales#matedsolu#oncost
– SecondStep:A∗selectsanodenforexpansion,theop1malpathtothatnodehasbeenfound.Werethisnotthecase,therewouldhavetobeanotherfronOernodenʹontheopOmalpathfromthestartnodeton,becausefisnondecreasingalonganypath,nʹwouldhavelowerf-costthannandwouldhavebeenselectedfirst.
– FromthetwoprecedingobservaOons,itfollowsthatthesequenceofnodesexpandedbyA∗usingGRAPH-SEARCHisinnondecreasingorderoff(n).Hence,thefirstgoalnodeselectedforexpansionmustbeanopOmalsoluOonbecausefisthetruecostforgoalnodes(whichhaveh=0)andalllatergoalnodeswillbeatleastasexpensive.
Saturday,23April16 12
3.5.2A*search:Minimizingthetotales#matedsolu#oncost
– Hence,completenessrequiresthattherewouldbeonlyfinitelymanynodeswithcostlessthanorequaltoC∗,acondiOonthatistrueifallstepcostsexceedsomefiniteεandifbisfinite.
– A∗expandsnonodeswithf(n)>C∗—forexample,TimisoaraisnotexpandedinFigure3.24eventhoughitisachildoftheroot.WesaythatthesubtreebelowTimisoaraispruned;
– BecausehSLDisadmissible,thealgorithmcansafelyignorethissubtreewhilesOllguaranteeingopOmality.Theconceptofpruning—eliminaOngpossibiliOesfromconsideraOonwithouthavingtoexaminethem—isimportantformanyareasofAI.
Saturday,23April16 13
3.5.2A*search:Minimizingthetotales#matedsolu#oncost
– AmongopOmalalgorithmsofthistype—algorithmsthatextendsearchpathsfromtherootandusethesameheurisOcinformaOon—A∗isop#mallyefficientforsuchgivenconsistentheurisOc.
– Unfortunately,itdoesnotmeanthatA∗istheanswertoalloursearchingneeds.
• ComplexityofA*dependsontheheurisOc.– Intheworstcaseofanunboundedsearchspace,thenumberofnodesexpandedisexponenOalinthelengthofthesoluOond:O(bd),wherebisthebranchingfactor.Thisassumesthatagoalstateexistsatall,andisreachablefromthestartstate;ifitisnot,andthestatespaceisinfinite,thealgorithmwillnotterminate.
Saturday,23April16 14
3.5.2A*search:Minimizingthetotales#matedsolu#oncost
– TheexponenOalcomplexityofA∗withrespecttodepthofgoalosenmakesitimpracOcalinfindinganopOmalsoluOon.
– ComputaOonOmeisnotthemaindrawbackofA∗.AsA*keepsallgeneratednodesinmemory(asdoallGRAPH-SEARCHalgorithms),andusuallyrunsoutofspacelongbeforeitrunsoutofOme.Forthisreason,A∗isnotpracOcalformanylarge-scaleproblems.
Saturday,23April16 15
3.5.3Memory-boundedheuris#csearch
• (ReaditYourself)
Saturday,23April16 16
3.5.4LearningtosearchbeUer• (Readityourself)
Saturday,23April16 17
3.6HEURISTICFUNCTIONS
• Readityourself.
Saturday,23April16 18
AssignmentNo.4
• ExercisesNo’s:3.9,3.13,3.17,3.19,3.22,3.29
Saturday,23April16 19