Professional Documents
Culture Documents
Heuristic Search 20032023 035504pm 24102023 053215pm
Heuristic Search 20032023 035504pm 24102023 053215pm
INTELLIGENCE
Informed Searches
Informed (Heuristic) Search
Informed searches use domain knowledge to guide selection of the best path to continue
searching
• Heuristics are used, which are informed guesses
• Heuristic means "serving to aid discovery“
Best-first search (for small search spaces)
◦ Greedy best-first search
◦ A* search
Local search algorithms (for large search spaces)
◦ Hill-climbing search
◦ Simulated annealing search
◦ Local beam search
◦ Genetic algorithms
Heuristics
▪ Heuristics are formalized as rules for choosing those branches in a state space that are most likely
to lead to an acceptable problem solution.
▪ Much more efficient than un-informed searches.
▪ Heuristics are employed in two basic situations:
▪ A problem may not have an exact solution because of inherent ambiguities in the problem
statement or available data
▪ A problem may have an exact solution, but the computational cost of finding it may be
prohibitive
Heuristic Function
Designed for particular search problem
Define a heuristic function, h(n)
◦ it estimates
◦ the "goodness" of node n
◦ how close node n is to a goal
◦ the estimated cost of minimal cost (cheapest) path from node n to a goal
state
Heuristic Function
•h(n) ≥ 0 for all nodes n
•h(n)=0 means n is a goal node
•h(n) close to 0 means we think n is close to a goal state
•h(n) very big means we think n is far from a goal state
•All domain knowledge used in the search is encoded in the heuristic function, h
EX AMPLE: PAN C AK E PRO BLEM
Gates, W. and Papadimitriou, C., "Bounds for Sorting by Prefix Reversal.", Discrete Mathematics. 27, 47-57,
1979.
EX AMPLE: HEURISTIC FUN C TIO N
3
h(x
4
)
3
4
3 0
4
4 3
4
4 2
3
Heuristic: the number of the largest pancake that is still out of place
BEST FIRST SEARCH
Example: Path Finding
Greedy Best First Search
• Use as an evaluation function, f(n) = h(n), sorting nodes in the
Frontier by increasing values of f
• Heuristic Function
• h(n)= estimated cost of the cheapest path from node n to a goal
node
• Selects the node to expand that is believed to be closest (i.e.,
smallest f value) to a goal node
• e.g., hSLD(n) = straight-line distance from n to Bucharest
GREEDY SEARCH EXAMPLE
GREEDY SEARCH EXAMPLE
GREEDY SEARCH EXAMPLE
PROPERTIES OF GREEDY ALGORITHMS
Greedy Best First Search
f(n) = h(n)
S
# of nodes tested: 0, expanded: 0 h=8
expnd. node Frontier
{S:8} 1 5 8
A B C
h=8 h=4 h=3
3 7 9 4 5
D E G
h=∞ h=∞ h=0
Greedy Best First Search
f(n) = h(n)
S
# of nodes tested: 1, expanded: 1 h=8
expnd. node Frontier
{S:8} 1 5 8
S not goal {C:3,B:4,A:8} A B C
h=8 h=4 h=3
3 7 9 4 5
D E G
h=∞ h=∞ h=0
Greedy Best First Search
f(n) = h(n)
S
# of nodes tested: 2, expanded: 2 h=8
expnd. node Frontier
{S:8} 1 5 8
S {C:3,B:4,A:8} A B C
C not goal {G:0,B:4,A:8} h=8 h=4 h=3
3 7 9 4 5
D E G
h=∞ h=∞ h=0
Greedy Best First Search
f(n) = h(n)
S
# of nodes tested: 3, expanded: 2 h=8
expnd. node Frontier
{S:8} 1 5 8
S {C:3,B:4,A:8} A B C
C {G:0,B:4, A:8} h=8 h=4 h=3
G goal {B:4, A:8} not 3 7 9 4 5
expanded
D E G
h=∞ h=∞ h=0
Greedy Best First Search
f(n) = h(n)
S
# of nodes tested: 3, expanded: 2 h=8
expnd. node Frontier
{S:8} 1 5 8
S {C:3,B:4,A:8} A B C
C {G:0,B:4, A:8} h=8 h=4 h=3
G {B:4, A:8} 3 7 9 4 5
D E G
h=∞ h=∞ h=0
Fast but not optimal
path: S,C,G
cost: 13
Greedy Best First Search
Not complete
Not optimal/admissible S
h=5
2 2
A B
Greedy search finds the left goal h=3 h=4
(solution cost of 7) 1 2
Optimal solution is the path to the C D
h=3 h=1
right goal (solution cost of 5)
1 1
E G
h=2 goal
3
G
goal
Greedy Best First Search
Greedy best-first search resembles depth-first search in the way it
prefers to follow a single path all the way to the goal but will back up
when it hits a dead end.
3 7 9 4 5
D E G
h=∞ h=∞ h=0
A* Search
49
Reading Reference