ADijkstra-LikeScenario - - PDF document

a dijkstra like scenario
SMART_READER_LITE
LIVE PREVIEW

ADijkstra-LikeScenario - - PDF document

ADijkstra-LikeScenario Yourcompanyownsadeliverytruckthatwillhavetomakemany tripsinadaytovariouswarehouses,alwaysstartingatwarehouseA


slide-1
SLIDE 1

1

HeuristicGraphSearch: AnotherReasonAIisCool

NickDeibel QuizSection– 5/31/02

ADijkstra-LikeScenario

Yourcompanyownsadeliverytruckthatwillhavetomakemany tripsinadaytovariouswarehouses,alwaysstartingatwarehouseA andendingatwarehouseB.However,itwillneverrepeatvisitthe samewarehousetwiceinoneday.Becauseofdemand,youcannot wastetimerefuelingthetruckuntilitreachesB.Thetruckcan travelatmostKmilesonasingletankofgas.Youaregivena graphwherethenodesrepresentthewarehousesandthedirected edgesrepresentthehighwaysconnectingthetwowarehouses.Each edgeisweightedaccordingtothelengthofthathighway. AsyouwantyourdriverstoavoidtakingpathsoflongerthanK miles,designanalgorithmthattellsyouifthereexistsanysimple pathfromAtoB(nonodes/warehousesrepeated)whoselengthis greaterthanKmiles.

Whoops,That’sREALLYHard

  • LongestPathisanNP-Completeproblem.
  • Noknownpolynomial-timealgorithmsolvesit.

– Apoly-timealgorithmdoesexistforDAGS.

  • Thisisadifficultproblemforevensmallgraphs.

HugeGraphs

  • Considersomereallyhuge graphs…

– AllcitiesandtownsintheWorldAtlas – AllstarsintheGalaxy – Allways10blockscanbestacked Huh???

ImplicitlyGeneratedGraphs

  • Ahugegraphmaybeimplicitlyspecified byrulesfor

generatingiton-the-fly

  • Blocksworld:

– vertex=relativepositionsofallblocks – edge=robotarmstacksoneblock

stack(blue,red) stack(green,red) stack(green,blue) stack(blue,table) stack(green,blue)

BlocksWorld

  • Source=initialstateoftheblocks
  • Goal=desiredstateoftheblocks
  • Pathsourcetogoal=sequenceofactions

(program)forrobotarm!

  • nblocks nn vertices
  • 10blocks 10billionvertices!
slide-2
SLIDE 2

2

Problem:BranchingFactor

  • Cannotsearchsuchhugegraphsexhaustively.

Supposeweknowthegoalisonlyd stepsaway.

  • Dijkstra’s algorithmisbasicallybreadth-first

search(modifiedtohandlearcweights)

  • Breadth-firstsearch(orforweightedgraphs,

Dijkstra’s algorithm)– Ifout-degreeofeachnode is10,potentiallyvisits10d vertices

– 10stepplan=10billionverticesvisited!

AnEasierCase

  • SupposeyouliveinManhattan;whatdoyoudo?

52nd St 51st St 50th St

10th Ave 9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave 3rd Ave 2nd Ave

S G

Best-FirstSearch

  • TheManhattandistance ( x+ y)isanestimate
  • fthedistancetothegoal

– aheuristicvalue

  • Best-FirstSearch

– Ordernodesinprioritytominimizeestimateddistance tothegoalh(n)

  • Compare:BFS/Dijkstra

– Ordernodesinprioritytominimizedistancefromthe start

BestFirstinAction

  • SupposeyouliveinManhattan;whatdoyoudo?

52nd St 51st St 50th St

10th Ave 9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave 3rd Ave 2nd Ave

S G

Problem1:LedAstray

  • Eventuallywillexpandvertextogetbackonthe

righttrack

52nd St 51st St 50th St

10th Ave 9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave 3rd Ave 2nd Ave

S G

Problem2:Optimality

  • WithBest-FirstSearch,areyouguaranteed a

shortestpathisfoundwhen

– goalisfirstseen? – whengoalisremovedfrompriorityqueue(aswith Dijkstra?)

slide-3
SLIDE 3

3

Sub-OptimalSolution

  • No!Goalisbydefinitionatdistance0:willbe

removedfrompriorityqueueimmediately,evenif ashorterpathexists!

52nd St 51st St

9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave

S G

(5blocks)

h=2 h=1 h=4 h=5

Synergy?

  • Dijkstra/BreadthFirstguaranteedtofindoptimal

solution

  • BestFirstoftenvisitsfarfewer vertices,butmay

notprovideoptimalsolution – Canwegetthebestofboth?

Heuristics

  • Aruleofthumb,simplification,oreducatedguess.
  • Reducesthesearchforsolutionsinlargesolution

spaces

  • Unlikealgorithms,heuristicsdonotguarantee
  • ptimal,orevenfeasible,solutions.

A*(“Astar”)

  • Orderverticesinpriorityqueuetominimize

(distancefromstart)+(estimateddistancetogoal) f(n)=g(n) +h(n) f(n)=priorityofanode g(n) =truedistancefromstart h(n) =heuristicdistancetogoal

Optimality

  • Supposetheestimateddistance(h)is

always lessthanorequalto thetrue distancetothe goal – heuristicisalowerboundontruedistance

  • Then:whenthegoalisremoved fromthepriority

queue,weareguaranteed tohavefoundashortest path!

Problem2Revisited

52nd St 51st St

9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave

S G

(5blocks)

50th St 5 5 52nd &9th f(n) h(n) g(n) vertex

slide-4
SLIDE 4

4

Problem2Revisited

52nd St 51st St

9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave

S G

(5blocks)

50th St 5 4 1 51st &9th 7 2 5 52nd &4th f(n) h(n) g(n) vertex

Problem2Revisited

52nd St 51st St

9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave

S G

(5blocks)

50th St 7 5 2 50th &9th 5 3 2 51st &8th 7 2 5 52nd &4th f(n) h(n) g(n) vertex

Problem2Revisited

52nd St 51st St

9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave

S G

(5blocks)

50th St 7 4 3 50th &8th 7 5 2 50th &9th 5 2 3 51st &7th 7 2 5 52nd &4th f(n) h(n) g(n) vertex

Problem2Revisited

52nd St 51st St

9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave

S G

(5blocks)

50th St 7 3 4 50th &7th 7 4 3 50th &8th 7 5 2 50th &9th 5 1 4 51st &6th 7 2 5 52nd &4th f(n) h(n) g(n) vertex

Problem2Revisited

52nd St 51st St

9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave

S G

(5blocks)

50th St 7 3 4 50th &7th 7 4 3 50th &8th 7 5 2 50th &9th 5 5 51st &5th 7 2 5 52nd &4th f(n) h(n) g(n) vertex

Problem2Revisited

52nd St 51st St

9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave

S G

(5blocks)

50th St 7 3 4 50th &7th 7 4 3 50th &8th 7 5 2 50th &9th 7 2 5 52nd &4th f(n) h(n) g(n) vertex

DONE!

slide-5
SLIDE 5

5

WhatWouldDijkstraHave Done?

52nd St 51st St

9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave

S G

(5blocks)

50th St 49th St 48th St 47th St

ProofofA*Optimality

  • A*terminateswhenGispoppedfromtheheap.
  • SupposeGispoppedbutthepathfoundisn’toptimal:

priority(G)>optimalpathlengthc

  • LetPbeanoptimalpathfromStoG,andletNbethelast

vertexonthatpaththathasbeenvisitedbutnotyetpopped.

TheremustbesuchanN,otherwisetheoptimalpathwouldhavebeen found. priority(N)=g(N)+h(N) c

  • SoNshouldhavepoppedbeforeGcanpop.Contradiction.

S N G

non-optimalpathtoG portionofoptimal pathfoundsofar undiscoveredportion

  • fshortestpath

WhatAboutThoseBlocks?

  • “Distancetogoal”isnotalwaysphysicaldistance
  • Blocksworld:

– distance=numberofstackstoperform – heuristiclowerbound=numberofblocksoutofplace #outofplace=1,truedistancetogoal=3

OtherReal-WorldApplications

  • Routingfinding– computernetworks,airline

routeplanning

  • VLSIlayout– celllayoutandchannelrouting
  • Productionplanning– “justintime”optimization
  • Proteinsequencealignment
  • Manyother“NP-Hard”problems

– Aclassofproblemsforwhichnoexactpolynomial timealgorithmsexist– soheuristicsearchisthebest wecanhopefor