ExampleThe8puzzle ExampleThe8puzzlecontdIstatesintegerlocationsoftilesignoreintermediatepositionsIactionsmoveblankleftrightupdownignoreunjammingetcIgoaltestgoalstategivenIpathcost ID: 451588
Download Pdf The PPT/PDF document "Example:TravelinginRomaniaIOnholidayinRo..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Example:TravelinginRomaniaIOnholidayinRomania;currentlyinAradIFlightleavestomorrowfromBucharestIFormulategoal:beinBucharestIFormulateproblem:states:variouscitiesactions:drivebetweencitiesIFindsolution:sequenceofcities,e.g.,Arad,Sibiu,Fagaras,Bucharest(anysolutionoroptimalsolution?) Example:The8-puzzle Example:The8-puzzle(cont'd)Istates:integerlocationsoftiles(ignoreintermediatepositions)Iactions:moveblankleft,right,up,down(ignoreunjammingetc.)Igoaltest:=goalstate(given)Ipathcost:1permoveINotethattheoptimalsolutionofn-PuzzlefamilyisNP-hard Treesearchalgorithms(cont'd)functionTree-Search(problem,strategy)returnsasolution,orfailureinitializethefrontierusingtheinitialstateofproblemloopdoifthefrontierisemptythenreturnfailurechoosealeafnodeandremoveitfromthefrontierifthenodecontainsagoalstatethenreturnthecorrespondingsolutionexpandthechosennodeandaddtheresultingnodestothefrontierend EvaluatingsearchstrategiesIAstrategyisdenedbypickingtheorderofnodeexpansionIStrategiesareevaluatedalongthefollowingdimensions:Icompleteness|doesitalwaysndasolutionifoneexists?Itimecomplexity|numberofnodesgenerated/expandedIspacecomplexity|maximumnumberofnodesinmemoryIoptimality|doesitalwaysndaleast-costsolution?ITimeandspacecomplexityaremeasuredintermsofIb|maximumbranchingfactorofthesearchtreeId|depthoftheleast-costsolutionIm|maximumdepthofthestatespace(maybe1) UninformedsearchstrategiesUninformedstrategiesuseonlytheinformationavailableintheproblemdenitionIBreadth-rstsearchIUniform-costsearchIDepth-rstsearchIDepth-limitedsearchIIterativedeepeningsearchIBidirectionalsearch Breadth-rstsearchIExpandtheshallowestunexpandednodeIImplementation:frontierisaFIFOqueue,i.e.,newsuccessorsgoatend Progressofbreadth-rstsearchBreadth-rstsearchonasimplebinarytree.Ateachstage,thenodetobeexpandednextisindicatedbyamarker.Thenodesthatarealreadyexploredaregray.Thenodeswithdashedlinesarenotgeneratedyet. Progressofbreadth-rstsearchBreadth-rstsearchonasimplebinarytree.Ateachstage,thenodetobeexpandednextisindicatedbyamarker.Thenodesthatarealreadyexploredaregray.Thenodeswithdashedlinesarenotgeneratedyet. Progressofbreadth-rstsearchBreadth-rstsearchonasimplebinarytree.Ateachstage,thenodetobeexpandednextisindicatedbyamarker.Thenodesthatarealreadyexploredaregray.Thenodeswithdashedlinesarenotgeneratedyet. Progressofbreadth-rstsearchBreadth-rstsearchonasimplebinarytree.Ateachstage,thenodetobeexpandednextisindicatedbyamarker.Thenodesthatarealreadyexploredaregray.Thenodeswithdashedlinesarenotgeneratedyet. Propertiesofbreadth-rstsearchIComplete:Yes(ifbisnite)ITime:b+b2+b3+:::+bd+b(bd1)=O(bd+1),i.e.,numberofnodesgeneratedisexponentialindISpace:O(bd+1)(keepseverynodeinmemory)IOptimal:Yes(ifcost=1perstep)Spaceisthebigproblem;caneasilygeneratenodesat100MB/secso24hrs=8604GB. Uniform-costsearchIExpandtheleast-costunexpandednodeIImplementation:frontierisaqueueorderedbypathcostIEquivalenttobreadth-rstifstepcostsareallequal Propertiesofuniform-costsearchIComplete:Yes,ifstepcostITime:#ofnodeswithgcostofoptimalsolution,O(b1+bC=c)whereCisthecostoftheoptimalsolutionISpace:#ofnodeswithgcostofoptimalsolution,O(b1+bC=c)IOptimal:Yes|nodesexpandedinincreasingorderofg(n) Depth-rstsearchIExpanddeepestunexpandednodeIImplementation:frontierisaLIFOqueue,i.e.,putsuccessorsatfront Progressofdepth-rstsearch Progressofdepth-rstsearch Progressofdepth-rstsearch Progressofdepth-rstsearch Progressofdepth-rstsearch Progressofdepth-rstsearch Progressofdepth-rstsearch Progressofdepth-rstsearch Progressofdepth-rstsearch Progressofdepth-rstsearch Progressofdepth-rstsearch Progressofdepth-rstsearch Propertiesofdepth-rstsearchIComplete:No:failsininnite-depthspaces,spaceswithloopsModifytoavoidrepeatedstatesalongpath)completeinnitespacesITime:O(bm):terribleifmismuchlargerthandbutifsolutionsaredense,maybemuchfasterthanbreadth-rstISpace:O(bm),i.e.,linearspace!IOptimal:No Depth-limitedsearchfunctionDepth-Limited-Search(problem,limit)returnsasolution,orfailure/cutoreturnRecursive-DLS(Make-Node(problem.Initial-State),problem,limit)functionRecursive-DLS(node,problem,limit)returnsasolution,orfailure/cutoifproblem.Goal-Test(node.State)thenreturnSolution(node)elseiflimit=0thenreturncutoelsecuto-occurred? falseforeachactioninproblem.Actions(node.State)dochild Child-Node(problem,node,action)result Recursive-DLS(child,problem,limit-1)ifresult=cutothencuto-occurred? trueelseifresult6=failurethenreturnresultifcuto-occurred?thenreturncutoelsereturnfailure IterativedeepeningsearchfunctionIterative-Deepening-Search(problem)returnsasolution,orfailurefordepth 0to1doresult Depth-Limited-Search(problem,depth)ifresult6=cutothenreturnresult Summaryofalgorithms Criterion Breadth-Uniform-Depth-Depth-Iter. FirstCostFirstLimitedDeep. Complete? YesYesNoYesYes Time O(bd+1)O(b1+bC=c)O(bm)O(bl)O(bd) Space O(bd+1)O(b1+bC=c)O(bm)O(bl)O(bd) Optimal? YesYesNoNoYes SummaryIProblemformulationusuallyrequiresabstractingawayreal-worlddetailstodeneastatespacethatcanfeasiblybeexplored.IThereareavarietyofuninformedsearchstrategiesavailable.IIterativedeepeningsearchusesonlylinearspaceandnotmuchmoretimethanotheruninformedalgorithms.