0% found this document useful (0 votes)
5 views

Cs4811 Ch03 Search b Informed

Uploaded by

hhgggubhgghuu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Cs4811 Ch03 Search b Informed

Uploaded by

hhgggubhgghuu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Chapter 3 Solving Problems by Searching

3.5 –3.6 Informed (heuristic) search strategies

CS4811 - Artificial Intelligence

Nilufer Onder
Department of Computer Science
Michigan Technological University
Outline

Best-first search
Greedy search
A∗ search

Heuristics

(Iterative deepening A∗ search)


Best-first search

I Remember that the frontier contains the unexpanded nodes


I Idea: use an evaluation function for each node
(the evaluation function is an estimate of “desirability”)
I Expand the most desirable unexpanded node
I Implementation:
Frontier is a queue sorted in decreasing order of desirability
I Special cases:
I Greedy search
I A∗ search
Romania with step costs in km
Greedy search

I Evaluation function
h(n) = estimate of cost from n to the closest goal
h is the heuristic function
I E.g., hSLD (n) = straight-line distance from n to Bucharest
I Greedy search expands the node that appears to be closest to
the goal
Greedy search example

Arad
After expanding Arad

Arad

Sibiu Timisoara Zerind


253 329 374
After expanding Sibiu

Arad

Sibiu Timisoara Zerind


329 374

Arad Fagaras Oradea Rimnicu V.

366 176 380 193


After expanding Fagaras

Arad

Sibiu Timisoara Zerind


329 374

Arad Fagaras Oradea Rimnicu V.

366 380 193

Sibiu Bucharest

253 0
Properties of greedy search

I Complete: No — can get stuck in loops, e.g.,


Iasi → Neamt → Iasi → Neamt →
Complete in finite space with repeated-state checking
I Time: O(b m ), but a good heuristic can give dramatic
improvement
I Space: O(b m ) (keeps every node in memory)
I Optimal: No
A∗ search

I Idea: avoid expanding paths that are already expensive


I Evaluation function f (n) = g (n) + h(n)
I g (n) = cost so far to reach n
I h(n) = estimated cost to goal from n
I f (n) = estimated total cost of path through n to goal
I A∗ search uses an admissible heuristic
I if h is an admissible heuristic then
h(n) ≤ h∗ (n) where h∗ (n) is the true cost from n.
I Also require h(n) ≥ 0, so h(G ) = 0 for any goal G .
I An admissible heuristic is allowed to underestimate, but can
never overestimate cost.
I E.g., hSLD (n) never overestimates the actual road distance.
A∗ search example

Arad
366=0+366
After expanding Arad

Arad

Sibiu Timisoara Zerind


393=140+253 447=118+329 449=75+374
After expanding Sibiu

Arad

Sibiu Timisoara Zerind


447=118+329 449=75+374

Arad Fagaras Oradea Rimnicu V.

646=280+366 415=239+176 671=291+380 413=220+193


After expanding Rimnicu Vilcea

Arad

Sibiu Timisoara Zerind


447=118+329 449=75+374

Arad Fagaras Oradea Rimnicu V.

646=280+366 415=239+176 671=291+380

Craiova Pitesti Sibiu

526=366+160 417=317+100 553=300+253


After expanding Fagaras

Arad

Sibiu Timisoara Zerind


447=118+329 449=75+374

Arad Fagaras Oradea Rimnicu V.

646=280+366 671=291+380

Sibiu Bucharest Craiova Pitesti Sibiu

591=338+253 450=450+0 526=366+160 417=317+100 553=300+253


After expanding Pitesti

Arad

Sibiu Timisoara Zerind


447=118+329 449=75+374

Arad Fagaras Oradea Rimnicu V.

646=280+366 671=291+380

Sibiu Bucharest Craiova Pitesti Sibiu

591=338+253 450=450+0 526=366+160 553=300+253

Bucharest Craiova Rimnicu V.


418=418+0 615=455+160 607=414+193
Optimality of A∗

Theorem: A∗ search is optimal.

Suppose some suboptimal goal G2 has been generated and is in the


queue. Let n be an unexpanded node on a shortest path to an
optimal goal G1 .
Proof for the optimality of A∗
start

G1
G2

f (G2 ) = g (G2 ) since h(G2 ) = 0


> g (G1 ) since G2 is suboptimal
≥ f (n) since h is admissible

Since f (G2 ) > f (n), A∗ will never select G2 for expansion


Properties of A∗

I Complete: Yes, unless there are infinitely many nodes with


f ≤ f (G )
I Time: Exponential in
(relative error in h × length of solution)
I Space: Keeps all nodes in memory
I Optimal: Yes—cannot expand fi+1 until fi is finished
I A∗ expands all nodes with f (n) < C ∗
I A∗ expands some nodes with f (n) = C ∗
I A∗ expands no nodes with f (n) > C ∗
Admissible heuristics
E.g., for the 8-puzzle:
h1 (n) = number of “misplaced tiles”
h2 (n) = total “Manhattan distance”
(i.e., no. of squares from desired location of each tile)

h1 (S) = ??
h2 (S) = ??
Admissible heuristics
E.g., for the 8-puzzle:
h1 (n) = number of “misplaced tiles”
h2 (n) = total “Manhattan distance”
(i.e., no. of squares from desired location of each tile)

h1 (S) = 8
h2 (S) = 3+1+2+2+3+2+2+3 = 18
Dominance

A “better” heuristic is one that minimizes the effective branching


factor, b ∗ .
If h2 (n) ≥ h1 (n) for all n (both admissible)
then h2 dominates h1 and is better for search
Typical search costs:
d = 12 IDS = 3,644,035 nodes b ∗ = 2.78
A∗ (h1 ) = 539 nodes b ∗ = 1.42
A∗ (h2 ) = 113 nodes b ∗ = 1.24
d = 24 IDS ≈ 54,000,000,000 nodes
A∗ (h1 ) = 39,135 nodes b ∗ = 1.48
A∗ (h2 ) = 1,641 nodes b ∗ = 1.26
Relaxed problems

I Admissible heuristics can be derived from the exact solution


cost of a relaxed version of the problem
I If the rules of the 8-puzzle are relaxed so that a tile can move
“anywhere”, then h1 (n) gives the shortest solution
I If the rules are relaxed so that a tile can move to “any
adjacent square”, then h2 (n) gives the shortest solution
I Key point: the optimal solution cost of a relaxed problem is
no greater than the optimal solution cost of the real problem
Iterative Deepening A* (IDA*)

I Idea: perform iterations of DFS. The cutoff is defined based


on the f -cost rather than the depth of a node.
I Each iteration expands all nodes inside the contour for the
current f -cost, peeping over the contour to find out where the
contour lies.
Summary

I Heuristic search algorithms


I Finding good heuristics for a specific problem is an area of
research
I Think about the time to compute the heuristic
Sources for the slides

I AIMA textbook (3rd edition)


I AIMA slides (http://aima.cs.berkeley.edu/)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy