Title: Heuristic Search
1Heuristic Search
2Outline
- Heuristic function
- Greedy Best-first search
- Admissible heuristic and A
- Properties of A Algorithm
- IDA
3Heuristic Search
- Heuristic A rule of thumb generally based on
expert experience, common sense to guide
problem-solving process - In search, use a heuristic function that
estimates how far we are from a goal. - How do we use heuristics?
4Romania with step costs in km
5Greedy best-first search example
6Greedy best-first search example
7Greedy best-first search example
8Greedy best-first search example
9Robot Navigation
10Robot Navigation
f(N) h(N), with h(N) Manhattan distance to
the goal
11Properties of greedy best-first search
- Complete? No can get stuck in loops Yes, if we
can avoid repeated states - Time? O(bm), but a good heuristic can give
dramatic improvement - Space? O(bm) -- keeps all nodes in memory
- Optimal? No
12A Search
- A search combines Uniform-cost and Greedy
Best-first Search - Evaluation function f(N) g(N)
h(N) where - g(N) is the cost of the best path found so far to
N - h(N) is an admissible heuristic
- f(N) is the estimated cost of cheapest solution
- through N
- 0 lt ? ? c(N,N) (no negative cost steps).
- Order the nodes in the fringe in increasing
values of f(N)
13A search example
14A search example
15A search example
16A search example
17A search example
18A search example
19Admissible heuristic
- Let h(N) be the cost of the optimal path from N
to a goal node - Heuristic h(N) is admissible if 0
? h(N) ? h(N) - An admissible heuristic is always optimistic
208-Puzzle
N
goal
- h1(N) number of misplaced tiles 6 is
admissible
- h2(N) sum of distances of each tile to goal
13 is admissible
- What heuristics are overestimates?
21Completeness Optimality of A
- Claim
- If there is a path from the initial to a goal
node, A using TREE-SEARCH terminates by finding
the best path, hence is - complete
- optimal
22Optimality of A (proof)
- Suppose some suboptimal goal G2 has been
generated and is in the fringe. Let n be an
unexpanded node in the fringe such that n is on a
shortest path to an optimal goal G. - We can show f(n) lt f(G2), so A would not have
selected G2.
23Optimality of A (proof)
- Contd
- f(G2) g(G2) since h(G2) 0
- g(G2) gt g(G) since G2 is suboptimal
- f(G) g(G) since h(G) 0
- f(G2) gt f(G) from above
24Optimality of A (proof)
- Contd
- f(G2) gt f(G) from above
- h(n) h(n) since h is admissible
- g(n) h(n) g(n) h(n)
- f(n) f(G)
- Hence f(G2) gt f(n), and A will never select
G2 for expansion
25Exampel Graph Search returns a suboptimal
solution
h6
2
1
B
A
5
S
G
h7
h1
h0
4
26Exampel Graph Search returns a suboptimal
solution
h6
2
1
B
A
5
S
G
h7
h1
h0
4
27Exampel Graph Search returns a suboptimal
solution
h6
2
1
B
A
5
S
G
h7
h1
h0
4
28Exampel Graph Search returns a suboptimal
solution
h6
2
1
B
A
5
S
G
h7
h1
h0
4
29Exampel Graph Search returns a suboptimal
solution
h6
2
1
B
A
5
S
G
h7
h1
h0
4
30Consistent Heuristic
- The admissible heuristic h is consistent (or
satisfies the monotone restriction) if for every
node N and every successor N of Nh(N) ?
c(N,N) h(N)(triangular inequality) - A consisteny heuristic is admissible.
31Exampel Graph Search returns a suboptimal
solution
h6
2
1
B
A
5
S
G
h7
h1
h0
4
- h is admissible but not consistent e.g.
- h(S)7 ? c(S,A) h(A) 5 ?
- No.
328-Puzzle
N
goal
33Claims
- If h is consistent, then the function f alongany
path is non-decreasing f(N) g(N) h(N)
f(N) g(N) c(N,N) h(N) h(N) ? c(N,N)
h(N) f(N) ? f(N) - If h is consistent, then whenever A expands a
node it has already found an optimal path to the
state associated with this node
34Optimality of A
- A expands nodes in order of increasing f value
- Gradually adds "f-contours" of nodes
- Contour i has all nodes with ffi, where fi lt fi1
35Avoiding Repeated States in A
- If the heuristic h is consistent, then
- Let CLOSED be the list of states associated with
expanded nodes - When a new node N is generated
- If its state is in CLOSED, then discard N
- If it has the same state as another node in the
fringe, then discard the node with the largest f
36Heuristic Accuracy
- h(N) 0 for all nodes is admissible and
consistent. Hence, breadth-first and uniform-cost
are particular A !!! - Let h1 and h2 be two admissible and consistent
heuristics such that for all nodes N h1(N) ?
h2(N). - Then, every node expanded by A using h2 is
also expanded by A using h1. - h2 is more informed than h1
- h2 dominates h1
- Which heuristic for 8-puzzle is better?
37Complexity of A
- Time exponential
- Space can keep all nodes in memory
- If we want save space, use IDA
38Iterative Deepening A (IDA)
- Use f(N) g(N) h(N) with admissible and
consistent h - Each iteration is depth-first with cutoff on the
value of f of expanded nodes
398-Puzzle
f(N) g(N) h(N) with h(N) number of
misplaced tiles
Cutoff4
408-Puzzle
f(N) g(N) h(N) with h(N) number of
misplaced tiles
Cutoff4
418-Puzzle
f(N) g(N) h(N) with h(N) number of
misplaced tiles
Cutoff4
428-Puzzle
f(N) g(N) h(N) with h(N) number of
misplaced tiles
Cutoff4
438-Puzzle
f(N) g(N) h(N) with h(N) number of
misplaced tiles
Cutoff4
448-Puzzle
f(N) g(N) h(N) with h(N) number of
misplaced tiles
Cutoff5
458-Puzzle
f(N) g(N) h(N) with h(N) number of
misplaced tiles
Cutoff5
468-Puzzle
f(N) g(N) h(N) with h(N) number of
misplaced tiles
Cutoff5
478-Puzzle
f(N) g(N) h(N) with h(N) number of
misplaced tiles
Cutoff5
488-Puzzle
f(N) g(N) h(N) with h(N) number of
misplaced tiles
Cutoff5
498-Puzzle
f(N) g(N) h(N) with h(N) number of
misplaced tiles
Cutoff5
508-Puzzle
f(N) g(N) h(N) with h(N) number of
misplaced tiles
Cutoff5
51About Heuristics
- Heuristics are intended to orient the search
along promising paths - The time spent computing heuristics must be
recovered by a better search - After all, a heuristic function could consist of
solving the problem then it would perfectly
guide the search - Deciding which node to expand is sometimes called
meta-reasoning - Heuristics may not always look like numbers and
may involve large amount of knowledge
52When to Use Search Techniques?
- The search space is small, and
- There are no other available techniques, or
- It is not worth the effort to develop a more
efficient technique - The search space is large, and
- There is no other available techniques, and
- There exist good heuristics
53Summary
- Heuristic function
- Greedy Best-first search
- Admissible heuristic and A
- A is complete and optimal
- Consistent heuristic and repeated states
- Heuristic accuracy
- IDA