Documente Academic
Documente Profesional
Documente Cultură
Motivations
Objectives
Oracle path
Maximize the heuristic measure: the higher the number, the more promising it is. We can also minimize the heuristic measure: the lower the number, the closer it is to a goal. Negate the above, we have -3, -4, and -2
Breadth first
Depth first
1. open=[A5]; closed=[ ] Ordered by heuristic values 2. Visit A5; open=[B4,C4,D6]; closed=[A5] 3. Visit B4; open=[C4,E5,F5,D6]; closed=[B4,A5] 4. visit C4; open=[H3,G4,E5,F5,D6]; closed=[C4,B4,A5] 5. visit H3; open=[O2,P3,G4,E5,F5,D6]; closed=[H3,C4,B4,A5]
Breadth-first
FIFO
Depth-first Best-first
LIFO _IBO
Best-First Search
Like the depth-first and breadth-first search, best-first search uses
two-lists.
open: to keep track of the frontier of the search. closed: to record states already visited.
At each iteration through the loop, consider the most promising state
on the open list next.
Main program
Function best_first_search open := [Start] closed := [ ] while open [ ] remove leftmost state from open, call it X if X is a goal then return SUCCESS else visit(X) put X on closed sort open by heuristic merit (best leftmost) return FAIL End function
Process children of X
Subroutine visit(X) generate children of X for each child of X child has never been seen before case % 3 cases the child is not on open or closed: assign the child a heuristic value add the child to open
child is waiting
the child is already on open: if the child was reached by a shorter path then give the state on open the shorter path
the child is already on closed: child been visited if the child was reached by a shorter path then remove the child from closed add the child to open End Subroutine
8-puzzle heuristics
Algorithm A
States that are closer to the start node are preferred because you can get there sooner.
4 =1+3
h1(n) h1(n)
Trace
1. open=[a4] closed=[ ] 2. open=[c4,b6,d6] closed=[a4] 3. open=[e5,f5,g6,b6,d6] closed=[a4, c4] 4. open=[f5,h6,g6,b6,d6,i7] closed=[a4,c4,e5]
5. open=[j5,h6,b6,d6,k7,i7] closed=[a4,c4,e5,f5]
6. open=[i5,h6,b6,d6,k7,i7] closed=[a4,c4,e5,f5,j5] 7. open=[m5,h6,b6,d6,k7,i7] closed=[a4,c4,e5,f5,j5,i5] success, m = goal
State f and h both have 3 tiles out of place but f is preferred because you can get to f sooner.
Space complexities: Oracle path traverses 6 nodes. Best-first with h1(n) touches 14 nodes. Breadth-first looks at 46 nodes.
A* algorithm
Conclusion