State space representations and search strategies Spring 2007, Juris Vīksna

Preview:

Citation preview

State space representations and search strategies

Spring 2007, Juris Vīksna

Sample problems - 8-puzzle

[Adapted from C.Arany, R.Barak, M.Dang]

Sample problems - 8-puzzle

[Adapted from C.Arany, R.Barak, M.Dang]

Sample problems - 8 queens

[Adapted from C.Arany, R.Barak, M.Dang]

Sample problems - 8 queens

[Adapted from C.Arany, R.Barak, M.Dang]

Sample problems - 8 queens

[Adapted from C.Arany, R.Barak, M.Dang]

Sample problems - Cryptarithmetic

[Adapted from C.Arany, R.Barak, M.Dang]

Sample problems - Cryptarithmetic

[Adapted from C.Arany, R.Barak, M.Dang]

Sample problems - River crossing puzzles

[Adapted from C.Arany, R.Barak, M.Dang]

Sample problems - River crossing puzzles

[Adapted from C.Arany, R.Barak, M.Dang]

Real world problems

[Adapted from C.Arany, R.Barak, M.Dang]

Real world problems - Route finding

[Adapted from C.Arany, R.Barak, M.Dang]

Real world problems - Travelling salesman

[Adapted from C.Arany, R.Barak, M.Dang]

Real world problems - VLSI layout

[Adapted from C.Arany, R.Barak, M.Dang]

State spaces

<S,P,I,G,W> - state space

S - set of statesP= {(x,y)|x,yS} - set of production rulesIS - initial stateGS - set of goal states W: PR+ - weight function

State spaces

<S,P,I,G,W> - state space

The problem

• find a goal state• find a path from the initial state to a goal state• find a shortest path from the initial state to a goal state• find a path with minimal weight from the initial state to a goal state

River crossing puzzle

[Adapted from R.Shinghal]

River crossing puzzle[Adapted from R.Shinghal]

River crossing puzzle

[Adapted from R.Shinghal]

River crossing puzzle

[Adapted from R.Shinghal]

River crossing puzzle

[Adapted from R.Shinghal]

8-puzzle

[Adapted from R.Shinghal]

8-puzzle

[Adapted from G.Luger, W.Stubblefield]

Search strategies - Data Driven

[Adapted from G.Luger, W.Stubblefield]

Search strategies - Goal Driven

[Adapted from G.Luger, W.Stubblefield]

Search strategies - Bi-directional

[Adapted from G.Luger, W.Stubblefield]

Search strategies - Bi-directional

[Adapted from G.Luger, W.Stubblefield]

Search strategies -

BFS

[Adapted from G.Luger, W.Stubblefield]

Search strategies - BFS

[Adapted from G.Luger, W.Stubblefield]

Search strategies - BFS

BreadthFirstSearch(state space =<S,P,I,G,W>)Open {I}Closed while Open do

x DeQueue(Open)if Goal(x, ) then return xInsert(x,Closed)for y Child(x ,) do

if yClosed and yOpen thenEnQueue(y,Open)

return fail

Open is implemented as queue (FIFO); Closed can be an arbitrary data structure for sets

Search strategies - Uniform Cost Search

UniformCostSearch(state space =<S,P,I,G,W>)Open {<0,I>}Closed while Open do

<wx,x> ExtractMin(Open)if Goal(x, ) then return xInsert(x,Closed)for y Child(x ,) do

if yClosed thenwy wx + W((x,y))Insert(<wy,y>,Open)

return fail

Open is implemented as a priority queue

Search strategies - DFS

[Adapted from G.Luger, W.Stubblefield]

Search strategies -

DFS

[Adapted from G.Luger, W.Stubblefield]

Search strategies - DFS

[Adapted from J.Pearl]

Search strategies - DFS

DepthFirstSearch(state space =<S,P,I,G,W>)Open {I}Closed while Open do

x Pop(Open)if Goal(x, ) then return xInsert(x,Closed)for y Child(x ,) do

if yClosed and yOpen thenPush(y,Open)

return fail

Open is implemented as stack (LIFO); Closed can be an arbitrary data structure for sets

Search strategies - DFS

DepthFirstSearch(state space =<S,P,I,G,W>)Closed return DFSVisit(I,Closed,)

DFSVisit(x,Closed,) if Goal(x, ) then return xInsert(x,Closed)

for y Child(x ,) doif y Closed then

value DFSVisit(y,Closed,) if value fail then return value

return fail

Search strategies - Backtracking

[Adapted from J.Pearl]

Search strategies - Backtracking

BacktrackingSearch(state space =<S,P,I,G,W>)Open {I}Closed while Open do

x Pop(Open)if Goal(x, ) then return xInsert(x,Closed)if there exists y Child(x ,) and yClosed

and yOpen then Push(y,Open)

return fail

Open is implemented as stack (LIFO); Closed can be an arbitrary data structure for sets

Heuristic function

<S,P,I,G,W> - state space

S - set of statesP= {(x,y)|x,yS} - set of production rulesIS - initial stateGS - set of goal states W: PR+ - weight function

d: SR+

d(x) - a shortest distance fromx to the closest goal state

f: SR+ - heuristic estimate of d

(if xG we usually assume f(x)=0)

Search strategies - Hill climbing

HCSearch(state space =<S,P,I,G,W>,f)HCVisit(I,,f)

HCVisit(x,,f) if Goal(x, ) then return xfind y Child(x ,) with the smallest f(y) valueHCVisit(y,,f)

Search strategies - Best first

[Adapted from J.Pearl]

Search strategies - Best first

BestFirstSearch(state space =<S,P,I,G,W>,f)Open {<f(I),I>}Closed while Open do

<wx,x> ExtractMin(Open)if Goal(x, ) then return xInsert(x,Closed)for y Child(x ,) do

if yClosed thenInsert(<f(y),y>,Open)

return fail

Open is implemented as a priority queue

Search strategies

[Adapted from J.Pearl]

Search strategies

[Adapted from R.Shinghal]