Professional Documents
Culture Documents
117-8
Best-first search
% tiles_a(A,M,V0,V) <- goal position can be reached from % one of the positions on A with last % move M (best-first strategy) tiles_a([v(V,LastMove)|Rest],LastMove,Visited,Visited):goal(LastMove). tiles_a([v(V,LastMove)|Rest],Goal,Visited0,Visited):show_move(LastMove,V), setof0(v(Value,NextMove), ( move(LastMove,NextMove), eval(NextMove,Value) ), Children), % Children sorted on Value merge(Children,Rest,NewAgenda), % best-first tiles_a(NewAgenda,Goal,[LastMove|Visited0],Visited).
Solving a puzzle
outOfPlace
bLeftOfw
0 1 2 4 5 6 8 9 10 12 13 15 9 9 8 7 7 6 4 4 3 2 1 0
0 1 3 4 6 8 9 11 12 14
12 10 9 7 7 4 4 3 2 0
0 1 3 4 6 7 8 9 10 12 13 15
18 15 13 11 8 7 7 6 6 2 2 0
Comparing heuristics
A algorithm
A heuristic is (globally) optimistic or admissible if the estimated cost of reaching a goal is always less than the actual cost.
h(n) h*(n)
estimate of cost to reach goal from n actual (unknown) cost to reach goal from n
A heuristic is monotonic (locally optimistic) if the estimated cost of reaching any node is always less than the actual cost.
h(n1) h(n2) h*(n1)h*(n2)
[start-3]
start 1 p r 0 q s goal 1 2 3
start
3
1 0 p q
start
s goal start 1 p
[p-2,r-3]
p r 2
0 q
3 1 r 2 0 q p
start
s goal start 1 0 p
s goal
[q-2,r-3]
q
q
3 1 r 2 0 q p
start
[r-3,s-4]
s goal
1
1 0 p q
goal start 3 1 r 2 0 s 1 q p
start
[s-3,s-4]
s goal
goal
1 0 p q
start
[goal-3,s-4]
s goal
Non-monotonic heuristic
Here, the number of children to be added to the beam is made dependent on the depth D of the node
in order to keep depth as a global variable, search is layer-by-layer
Beam search
Hill-climbing