Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search....
Transcript of Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search....
![Page 1: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/1.jpg)
CE417: Introduction to Artificial Intelligence
Sharif University of Technology
Spring 2018
“Artificial Intelligence: A Modern Approach”, Chapter 3
Most slides have been adopted from Klein and Abdeel, CS188, UC Berkeley.
Informed Search
A* Algorithm
Soleymani
![Page 2: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/2.jpg)
Outline
Heuristics
Greedy (best-first) search
A* search
Finding heuristics
2
![Page 3: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/3.jpg)
Uninformed Search
![Page 4: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/4.jpg)
Uniform Cost Search
Strategy: expand lowest path cost
The good: UCS is complete and optimal!
The bad: Explores options in every “direction” No information about goal location Start Goal
…
c 3
c 2
c 1
![Page 5: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/5.jpg)
UCS Example
5
![Page 6: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/6.jpg)
Informed Search
![Page 7: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/7.jpg)
Search Heuristics
A heuristic is:
A function that estimates how close a state is to a goal
Designed for a particular search problem
Examples: Manhattan distance, Euclidean distance for pathing
10
5
11.2
![Page 8: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/8.jpg)
Heuristic Function
Incorporating problem-specific knowledge in search
Information more than problem definition
In order to come to an optimal solution as rapidly as possible
ℎ 𝑛 : estimated cost of cheapest path from 𝑛 to a goal
Depends only on 𝑛 (not path from root to 𝑛)
If 𝑛 is a goal state then ℎ(𝑛)=0
ℎ(𝑛) ≥ 0
Examples of heuristic functions include using a rule-of-thumb,
an educated guess, or an intuitive judgment
8
![Page 9: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/9.jpg)
Example: Heuristic Function
h(x)
![Page 10: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/10.jpg)
Greedy Search
![Page 11: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/11.jpg)
Greedy search
Priority queue based on ℎ(𝑛)
e.g., ℎ𝑆𝐿𝐷 𝑛 = straight-line distance from n to Bucharest
Greedy search expands the node that appears to be
closest to goal
Greedy
11
![Page 12: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/12.jpg)
Example: Heuristic Function
h(x)
![Page 13: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/13.jpg)
Romania with step costs in km
13
![Page 14: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/14.jpg)
Greedy best-first search example
14
![Page 15: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/15.jpg)
Greedy best-first search example
15
![Page 16: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/16.jpg)
Greedy best-first search example
16
![Page 17: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/17.jpg)
Greedy best-first search example
17
![Page 18: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/18.jpg)
Greedy Search
Expand the node that seems closest…
What can go wrong?
![Page 19: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/19.jpg)
Greedy Search
Strategy: expand a node that you think is closest to agoal state Heuristic: estimate of distance to nearest goal for each state
A common case: Best-first takes you straight to the (wrong) goal
Worst-case: like a badly-guided DFS
…b
…b
![Page 20: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/20.jpg)
Properties of greedy best-first search
Complete? No
Similar to DFS, only graph search version is complete in finite spaces
Infinite loops, e.g., (Iasi to Fagaras) Iasi Neamt Iasi Neamt
Time
𝑂(𝑏𝑚), but a good heuristic can give dramatic improvement
Space
𝑂(𝑏𝑚): keeps all nodes in memory
Optimal? No
20
![Page 21: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/21.jpg)
Greedy Search
21
![Page 22: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/22.jpg)
A* Search
![Page 23: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/23.jpg)
A* search
Idea: minimizing the total estimated solution cost
Evaluation function for priority 𝑓 𝑛 = 𝑔 𝑛 + ℎ(𝑛)
𝑔 𝑛 = cost so far to reach 𝑛
ℎ 𝑛 = estimated cost of the cheapest path from 𝑛 to goal
So, 𝑓 𝑛 = estimated total cost of path through 𝑛 to goal
24
start n… goal…
Actual cost 𝑔 𝑛 Estimated cost ℎ 𝑛
𝑓 𝑛 = 𝑔 𝑛 + ℎ(𝑛)
![Page 24: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/24.jpg)
Combining UCS and Greedy
Uniform-cost orders by path cost, or backward cost g(n)
Greedy orders by goal proximity, or forward cost h(n)
A* Search orders by the sum: f(n) = g(n) + h(n)
S a d
b
G
h=5
h=6
h=2
1
8
1
1
2
h=6h=0
c
h=7
3
e h=11
Example: Teg Grenager
S
a
b
c
ed
dG
G
g = 0 h=6
g = 1 h=5
g = 2 h=6
g = 3 h=7
g = 4 h=2
g = 6 h=0
g = 9 h=1
g = 10 h=2
g = 12 h=0
![Page 25: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/25.jpg)
When should A* terminate?
Should we stop when we enqueue a goal?
No: only stop when we dequeue a goal
S
B
A
G
2
3
2
2
h = 1
h = 2
h = 0h = 3
![Page 26: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/26.jpg)
Is A* Optimal?
What went wrong?
Actual bad goal cost < estimated good goal cost
We need estimates to be less than actual costs!
A
GS
1 3
h = 6
h = 0
5
h = 7
![Page 27: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/27.jpg)
Admissible Heuristics
![Page 28: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/28.jpg)
Idea: Admissibility
Inadmissible (pessimistic) heuristics break optimality by trapping good plans on the frontier
Admissible (optimistic) heuristics slow down bad plans but never outweigh true costs
![Page 29: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/29.jpg)
Admissible Heuristics
A heuristic h is admissible (optimistic) if:
where is the true cost to a nearest goal
Examples:
Coming up with admissible heuristics is most of what’sinvolved in using A* in practice.
15
![Page 30: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/30.jpg)
Optimality of A* Tree Search
![Page 31: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/31.jpg)
Optimality of A* Tree Search
Assume:
A is an optimal goal node
B is a suboptimal goal node
h is admissible
Claim:
A will exit the frontier before B
…
![Page 32: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/32.jpg)
Optimality of A* Tree Search: Blocking
Proof:
Imagine B is on the frontier
Some ancestor n of A is on thefrontier, too (maybe A!)
Claim: n will be expanded before B
1. f(n) is less or equal to f(A)
Definition of f-cost
Admissibility of h
…
h = 0 at a goal
𝑓 𝑛 ≤ 𝑔 𝑛 + ℎ∗(𝑛)
𝑔 𝐴 = 𝑔 𝑛 + ℎ∗(𝑛)
![Page 33: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/33.jpg)
Optimality of A* Tree Search: Blocking
Proof:
Imagine B is on the frontier
Some ancestor n of A is on thefrontier, too (maybe A!)
Claim: n will be expanded before B
1. f(n) is less or equal to f(A)
2. f(A) is less than f(B)
B is suboptimal
h = 0 at a goal
…
![Page 34: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/34.jpg)
Optimality of A* Tree Search: Blocking
Proof:
Imagine B is on the frontier
Some ancestor n of A is on thefrontier, too (maybe A!)
Claim: n will be expanded before B
1. f(n) is less or equal to f(A)
2. f(A) is less than f(B)
3. n expands before B
All ancestors of A expand before B
A expands before B
A* search is optimal
…
![Page 35: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/35.jpg)
A* search
36
Combines advantages of uniform-cost and greedy
searches
A* can be complete and optimal when ℎ(𝑛) has some
properties
![Page 36: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/36.jpg)
A* search: example
37
![Page 37: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/37.jpg)
A* search: example
38
![Page 38: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/38.jpg)
A* search: example
39
![Page 39: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/39.jpg)
A* search: example
40
![Page 40: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/40.jpg)
A* search: example
41
![Page 41: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/41.jpg)
A* search: example
42
![Page 42: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/42.jpg)
Properties of A*
…b
…b
Uniform-Cost A*
![Page 43: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/43.jpg)
A* Example
44
![Page 44: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/44.jpg)
Example
45
UCS Greedy A*
![Page 45: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/45.jpg)
UCS vs A* Contours
Uniform-cost (A* using ℎ(𝑛)=0) expandsequally in all “directions”
A* expands mainly toward the goal, butdoes hedge its bets to ensure optimality More accurate heuristics stretched toward the goal
(more narrowly focused around the optimal path)
Start Goal
Start Goal
States are points in 2-D Euclidean space.
g(n)=distance from start
h(n)=estimate of distance from goal
![Page 46: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/46.jpg)
Comparison
GreedyUniform Cost A*
![Page 47: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/47.jpg)
Graph Search
![Page 48: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/48.jpg)
Failure to detect repeated states can cause exponentially more work.
Search TreeState Graph
Tree Search: Extra Work!
![Page 49: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/49.jpg)
Graph Search In BFS, for example, we shouldn’t bother expanding the circled nodes (why?)
S
a
b
d p
a
c
e
p
h
f
r
q
q c G
a
qe
p
h
f
r
q
q c G
a
![Page 50: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/50.jpg)
Recall: Graph Search
Idea: never expand a state twice
How to implement:
Tree search + set of expanded states (“closed set”)
Expand the search tree node-by-node, but…
Before expanding a node, check to make sure its state has never been expanded before
If not new, skip it, if new add to closed set
Important: store the closed set as a set, not a list
Can graph search wreck completeness? Why/why not?
How about optimality?
![Page 51: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/51.jpg)
Optimality of A* Graph Search
![Page 52: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/52.jpg)
A* Graph Search Gone Wrong?
S
A
B
C
G
1
1
1
23
h=2
h=1
h=4
h=1
h=0
S (0+2)
A (1+4) B (1+1)
C (2+1)
G (5+0)
C (3+1)
G (6+0)
State space graph Search tree
![Page 53: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/53.jpg)
Conditions for optimality of A*
Admissibility: ℎ(𝑛) be a lower bound on the cost to reach goal
Condition for optimality of TREE-SEARCH version of A*
Consistency (monotonicity): ℎ 𝑛 ≤ 𝑐 𝑛, 𝑎, 𝑛′ + ℎ 𝑛′
Condition for optimality of GRAPH-SEARCH version of A*
54
![Page 54: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/54.jpg)
Consistent heuristics
55
Triangle inequality
𝑛
𝑛′
𝐺
ℎ(𝑛′)
ℎ(𝑛)
𝑐(𝑛, 𝑎, 𝑛′)
𝑐 𝑛, 𝑎, 𝑛′ : cost of generating 𝑛′ by applying action to 𝑛
for every node 𝑛 and every successor
𝑛′ generated by any action 𝑎
ℎ 𝑛 ≤ 𝑐 𝑛, 𝑎, 𝑛′ + ℎ 𝑛′
![Page 55: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/55.jpg)
Consistency of Heuristics
Main idea: estimated heuristic costs ≤ actual costs
Admissibility: heuristic cost ≤ actual cost to goal
h(A) ≤ actual cost from A to G
Consistency: heuristic “arc” cost ≤ actual cost for each arc
h(A) – h(C) ≤ cost(A to C)
Consequences of consistency:
The f value along a path never decreases
h(A) ≤ cost(A to C) + h(C)
A* graph search is optimal
3
A
C
G
h=4 h=11
h=2
![Page 56: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/56.jpg)
Optimality
Tree search: A* is optimal if heuristic is admissible
UCS is a special case (h = 0)
Graph search: A* optimal if heuristic is consistent
UCS optimal (h = 0 is consistent)
Consistency implies admissibility
In general, most natural admissible heuristics tend to beconsistent, especially if from relaxed problems
![Page 57: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/57.jpg)
Consistency implies admissibility
58
Consistency ⇒ Admissblity
All consistent heuristic functions are admissible
Nonetheless, most admissible heuristics are also consistent
ℎ 𝑛1 ≤ 𝑐 𝑛1, 𝑎1, 𝑛2 + ℎ(𝑛2)
≤ 𝑐 𝑛1, 𝑎1, 𝑛2 + 𝑐 𝑛2, 𝑎2, 𝑛3 + ℎ(𝑛3)
…
≤ 𝑖=1𝑘 𝑐 𝑛𝑖 , 𝑎𝑖 , 𝑛𝑖+1 + ℎ(G)
𝑛1 𝑛2 𝑛3 𝑛𝑘 𝐺…
𝑐(𝑛1, 𝑎1, 𝑛2) 𝑐(𝑛𝑘 , 𝑎𝑘 , 𝐺)𝑐(𝑛2, 𝑎2, 𝑛3)
0 ⇒ ℎ 𝑛1 ≤ cost of (every) path from 𝑛1 to goal
≤ cost of optimal path from 𝑛1 to goal
![Page 58: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/58.jpg)
Admissible but not consistent: Example
59
𝑓 (for admissible heuristic) may decrease along a path
Is there any way to make ℎ consistent?
𝑛
𝑛′
𝑐(𝑛, 𝑎, 𝑛’) = 1ℎ(𝑛) = 9ℎ(𝑛’) = 6⟹ ℎ 𝑛 ≰ ℎ 𝑛’ + 𝑐(𝑛, 𝑎, 𝑛’)
1
𝑔 𝑛 = 5ℎ 𝑛 = 9𝑓(𝑛) = 14
𝑔 𝑛′ = 6ℎ 𝑛′ = 6𝑓(𝑛′) = 12G
10
10
ℎ 𝑛′ = max(ℎ 𝑛′ , ℎ 𝑛 − 𝑐(𝑛, 𝑎, 𝑛′))
![Page 59: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/59.jpg)
Optimality of A* Graph Search Sketch: consider what A* does with a consistent heuristic:
Fact 1: In graph search, A* expands nodes in increasing total f value (f-contours)
Fact 2: For every state s, nodes that reach s optimally are expanded before nodesthat reach s suboptimally
Result: A* graph search is optimal…
f 3
f 2
f 1
![Page 60: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/60.jpg)
Optimality of A* (consistent heuristics)
Theorem: If ℎ(𝑛) is consistent, A* using GRAPH-SEARCH is
optimal
Lemma1: if ℎ(𝑛) is consistent then 𝑓(𝑛) values are non-
decreasing along any path
Proof: Let 𝑛′ be a successor of 𝑛
I. 𝑓(𝑛′) = 𝑔(𝑛′) + ℎ(𝑛′)
II. 𝑔(𝑛′) = 𝑔(𝑛) + 𝑐(𝑛, 𝑎, 𝑛′)
III. 𝐼, 𝐼𝐼 ⇒ 𝑓 𝑛′ = 𝑔 𝑛 + 𝑐 𝑛, 𝑎, 𝑛′ + ℎ 𝑛′
IV. ℎ 𝑛 is consistent ⇒ ℎ 𝑛 ≤ 𝑐 𝑛, 𝑎, 𝑛′ + ℎ 𝑛′
V. 𝐼𝐼𝐼, 𝐼𝑉 ⇒ 𝑓(𝑛′) ≥ 𝑔(𝑛) + ℎ(𝑛) = 𝑓(𝑛)
61
![Page 61: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/61.jpg)
Optimality of A* (consistent heuristics)
Lemma 2: If A* selects a node 𝑛 for expansion, the optimal
path to that node has been found.
Proof by contradiction: Another frontier node 𝑛′ must exist on the optimal
path from initial node to 𝑛 (using graph separation property). Moreover, based
on Lemma 1, 𝑓 𝑛′ ≤ 𝑓 𝑛 and thus 𝑛′ would have been selected first.
Lemma 1 & 2⇒ The sequence of nodes expanded by A* (using GRAPH-
SEARCH) is in non-decreasing order of 𝑓(𝑛)
Since ℎ = 0 for goal nodes, the first selected goal node for expansion is an
optimal solution (𝑓 is the true cost for goal nodes)
62
![Page 62: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/62.jpg)
Admissible vs. consistent
(tree vs. graph search)
63
Consistent heuristic: When selecting a node for expansion, the
path with the lowest cost to that node has been found
When an admissible heuristic is not consistent, a node will
need repeated expansion, every time a new best (so-far) cost
is achieved for it.
![Page 63: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/63.jpg)
Contours in the state space
A* (using GRAPH-SEARCH) expands nodes in order of
increasing 𝑓 value
Gradually adds "f-contours" of nodes
Contour 𝑖 has all nodes with 𝑓 = 𝑓𝑖 where𝑓𝑖 < 𝑓𝑖+1
A* expands all nodes with f(n) < C*
A* expands some nodes with f(n) = C* (nodes on the goal contour)
A* expands no nodes with f(n) > C* ⟹ pruning
64
![Page 64: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/64.jpg)
Properties of A*
Complete?
Yes if nodes with 𝑓 ≤ 𝑓 𝐺 = 𝐶∗ are finite
Step cost≥ 𝜀 > 0 and 𝑏 is finite
Time?
Exponential
But, with a smaller branching factor
𝑏ℎ∗−ℎ or when equal step costs 𝑏𝑑×ℎ∗−ℎ
ℎ∗
Polynomial when |ℎ(𝑥) − ℎ∗(𝑥)| = 𝑂(𝑙𝑜𝑔 ℎ∗(𝑥))
However,A* is optimally efficient for any given consistent heuristic
No optimal algorithm of this type is guaranteed to expand fewer nodes than A* (except
to node with 𝑓 = 𝐶∗)
Space?
Keeps all leaf and/or explored nodes in memory
Optimal?
Yes (expanding node in non-decreasing order of 𝑓)
65
![Page 65: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/65.jpg)
Robot navigation example
66
Initial state? Red cell
States? Cells on rectangular grid (except to obstacle)
Actions? Move to one of 8 neighbors (if it is not obstacle)
Goal test? Green cell
Path cost? Action cost is the Euclidean length of movement
![Page 66: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/66.jpg)
A* vs. UCS: Robot navigation example
67
Heuristic: Euclidean distance to goal
Expanded nodes: filled circles in red & green
Color indicating 𝑔 value (red: lower, green: higher)
Frontier: empty nodes with blue boundary
Nodes falling inside the obstacle are discarded
Adopted from: http://en.wikipedia.org/wiki/Talk%3AA*_search_algorithm
![Page 67: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/67.jpg)
Robot navigation: Admissible heuristic
68
Is Manhattan 𝑑𝑀 𝑥, 𝑦 = 𝑥1 − 𝑦1 + 𝑥2 − 𝑦2 distance
an admissible heuristic for previous example?
![Page 68: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/68.jpg)
A*: inadmissible heuristic
69
ℎ = ℎ_𝑆𝐿𝐷ℎ = 5 ∗ ℎ_𝑆𝐿𝐷
Adopted from: http://en.wikipedia.org/wiki/Talk%3AA*_search_algorithm
![Page 69: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/69.jpg)
A*: Summary
![Page 70: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/70.jpg)
A*: Summary
A* uses both backward costs and (estimates of) forward
costs
A* is optimal with admissible / consistent heuristics
Heuristic design is key: often use relaxed problems
![Page 71: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/71.jpg)
Creating Heuristics
![Page 72: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/72.jpg)
Creating Admissible Heuristics Most of the work in solving hard search problems optimally is in
coming up with admissible heuristics
Often, admissible heuristics are solutions to relaxed problems, where
new actions are available
Inadmissible heuristics are often useful too
15366
![Page 73: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/73.jpg)
Example: 8 Puzzle
What are the states?
How many states?
What are the actions?
How many successors from the start state?
What should the costs be?
Start State Goal StateActions
![Page 74: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/74.jpg)
8 Puzzle: Heuristic h1
Heuristic: Number of tiles misplaced
Why is it admissible?
h1(start) = 8
Average nodes expanded when the optimal path has…
…4 steps …8 steps …12 steps
UCS 112 6,300 3.6 x 106
A*(h1) 13 39 227
Start State Goal State
Statistics from Andrew Moore
![Page 75: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/75.jpg)
Admissible heuristics: 8-puzzle
ℎ1(𝑛) = number of misplaced tiles
ℎ2(𝑛) = sum of Manhattan distance of tiles from their target position
i.e., no. of squares from desired location of each tile
ℎ1(𝑆) =
ℎ2(𝑆) =
8
3+1+2+2+2+3+3+2 = 18
76
![Page 76: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/76.jpg)
8 Puzzle: Heuristic h2
What if we had an easier 8-puzzle whereany tile could slide any direction at anytime, ignoring other tiles?
Total Manhattan distance
Why is it admissible?
h2(start) = 3 + 1 + 2 + … = 18
Average nodes expanded when the optimal path has…
…4 steps
…8 steps
…12 steps
A*(h1) 13 39 227
A*(h2) 12 25 73
Start State Goal State
![Page 77: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/77.jpg)
8 Puzzle: heuristic
How about using the actual cost as a heuristic?
Would it be admissible?
Would we save on nodes expanded?
What’s wrong with it?
With A*: a trade-off between quality of estimate and work per node
As heuristics get closer to the true cost, you will expand fewer nodes but usually
do more work per node to compute the heuristic itself
![Page 78: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/78.jpg)
Effect of heuristic on accuracy
𝑁: number of generated nodes by A*
𝑑: solution depth
Effective branching factor 𝑏∗ : branching factor of a
uniform tree of depth 𝑑 containing 𝑁 + 1 nodes.
𝑁 + 1 = 1 + 𝑏∗ + (𝑏∗)2+⋯+ (𝑏∗)𝑑
Well-defined heuristic: 𝑏∗ is close to one
79
![Page 79: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/79.jpg)
Comparison on 8-puzzle
𝑑 IDS A*(𝒉𝟏) A*(𝒉𝟐)
6 680 20 18
12 3644035 227 73
24 -- 39135 1641
𝑑 IDS A*(𝒉𝟏) A*(𝒉𝟐)
6 2.87 1.34 1.30
12 2.78 1.42 1.24
24 -- 1.48 1.26
Search Cost (𝑁)
Effective branching factor (𝑏∗)
80
![Page 80: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/80.jpg)
Heuristic quality
If ∀𝑛, ℎ2(𝑛) ≥ ℎ1(𝑛) (both admissible)
then ℎ2 dominates ℎ1 and it is better for search
Surely expanded nodes: 𝑓 𝑛 < 𝐶∗ ⇒ ℎ 𝑛 < 𝐶∗ − 𝑔 𝑛
If ℎ2(𝑛) ≥ ℎ1(𝑛) then every node expanded for ℎ2 will also be surely
expanded with ℎ1 (ℎ1 may also causes some more node expansion)
81
![Page 81: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/81.jpg)
More accurate heuristic
82
Max of admissible heuristics is admissible (while it is a
more accurate estimate)
How about using the actual cost as a heuristic?
ℎ(𝑛) = ℎ∗(𝑛) for all 𝑛
Will go straight to the goal ?!
Trade of between accuracy and computation time
ℎ 𝑛 = max(ℎ1 𝑛 , ℎ2 𝑛 )
![Page 82: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/82.jpg)
Trivial Heuristics, Dominance
Dominance: ha ≥ hc if
Heuristics form a semi-lattice:
Max of admissible heuristics is admissible
Trivial heuristics
Bottom of lattice is the zero heuristic (what does this give us?)
Top of lattice is the exact heuristic
![Page 83: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/83.jpg)
Generating heuristics
Relaxed problems
Inventing admissible heuristics automatically
Sub-problems (pattern databases)
Learning heuristics from experience
84
![Page 84: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/84.jpg)
Relaxed problem
85
Relaxed problem: Problem with fewer restrictions on the
actions
Optimal solution to the relaxed problem may be computed
easily (without search)
The cost of an optimal solution to a relaxed problem is an
admissible heuristic for the original problem
The optimal solution is the shortest path in the super-graph of the state-
space.
![Page 85: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/85.jpg)
Relaxed problem: 8-puzzle
8-Puzzle: move a tile from square A to B if A is adjacent (left,
right, above, below) to B and B is blank
Relaxed problems
1) can move from A to B if A is adjacent to B (ignore whether or not position is
blank)
2) can move from A to B if B is blank (ignore adjacency)
3) can move from A to B (ignore both conditions)
Admissible heuristics for original problem (ℎ1(𝑛) and ℎ2(𝑛))
are optimal path costs for relaxed problems
First case: a tile can move to any adjacent square ⇒ ℎ2(𝑛)
Third case: a tile can move anywhere ⇒ ℎ1(𝑛)
86
![Page 86: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/86.jpg)
Sub-problem heuristic
The cost to solve a sub-problem
Store exact solution costs for every possible sub-problem
Admissible?
The cost of the optimal solution to this problem is a lower
bound on the cost of the complete problem
87
![Page 87: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/87.jpg)
Pattern databases heuristics
Storing the exact solution cost for every possible sub-
problem instance
Combination (taking maximum) of heuristics resulted by
different sub-problems
15-Puzzle: 103
times reduction in no. of generated nodes vs. ℎ2
88
![Page 88: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/88.jpg)
Disjoint pattern databases
Adding these pattern-database heuristics yields an admissibleheuristic?!
Dividing up the problem such that each move affects only onesub-problem (disjoint sub-problems) and then addingheuristics 15-puzzle: 10
4times reduction in no. of generated nodes vs. ℎ2
24-Puzzle: 106
times reduction in no. of generated nodes vs. ℎ2
Can Rubik’s cube be divided up to disjoint sub-problems?
89
![Page 89: Informed Search A* Algorithmce.sharif.edu/courses/96-97/2/ce417-1/resources... · Informed Search. Search Heuristics A heuristic is: A function that estimates how close a state is](https://reader034.fdocuments.us/reader034/viewer/2022043005/5f89f5fd7a76073aa41c9aa2/html5/thumbnails/89.jpg)
Learning heuristics from experience
Machine Learning Techniques
Learn ℎ(𝑛) from samples of optimally solved problems
(predicting solution cost for other states)
Features of state (instead of raw state description)
8-puzzle
number of misplaced tiles
number of adjacent pairs of tiles that are not adjacent in the goal state
Linear Combination of features
90