




























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of heuristic search algorithms, including best-first search, greedy search, and a* search. The concepts of evaluation functions, f-values, and priority queues, as well as extensions to a* and the construction of heuristics. The document also includes examples and comparisons of the different search algorithms.
Typology: Study notes
1 / 36
This page cannot be seen from the preview
Don't miss anything!





























Chris Brooks
Department of Computer Science
University of San Francisco
“Best-first” search Greedy Search A* Search Extensions to A* Constructing Heuristics
Department of Computer Science — University of San Francisco – p.1/
Nodes were expanded based on their total path cost A priority queue was used to implement this. Path cost is an example of an
evaluation function
We’ll use the notation
f^
(n
)^ to refer to an evaluation
function. An evaluation function tells us how promising a node is. Indicates the quality of the solution that node leads to.
Department of Computer Science — University of San Francisco – p.3/
f
value, we search the “best” nodes “first” If^ f
was perfect, we would expand a straight path from the initial state to the goal state.
Arad, Sibiu, Rimnicu Vilcea, Pitesti, Bucharest Of course, if we had a perfect
f^ , we wouldn’t need to
solve the problem in the first place. Instead, we’ll try to develop heuristic functions
h(
n)
that
help us estimate
f^
(n
Department of Computer Science — University of San Francisco – p.4/
f
Greedy search
uses an estimate of distance to the goal
for
f^. Rationale: Always pick the node that looks like it will getyou closest to the solution. Let’s start with a simple estimate of
f^
for the Romania
domain.
h(
city
) =
Straight-line distance between that city and
Bucharest.
Department of Computer Science — University of San Francisco – p.6/
common sense
knowledge. Department of Computer Science — University of San Francisco – p.7/
Expands a linear number of nodes Is not complete or optimal Its ability to cut toward a goal is appealing - can wesalvage this?
Department of Computer Science — University of San Francisco – p.9/
f^
(n
) =
g(
n) +
h(
n)
g(
n)
= current path cost h(
n)
= heuristic estimate of distance to goal.
Favors nodes that have a cheap solution to date andalso look like they’ll get close to the goal. If^ h
(n
)^ satisfies certain conditions, A* is both complete (always finds a solution) and optimal (always finds thebest solution).
Department of Computer Science — University of San Francisco – p.10/
MehadiaNeamtOradeaPitestiRimnicu VilceaSibiuTimisoara UrziceniVasluiZerind
AradBucharestCraiovaDobretaEforieFagarasGiurgiuHirsovaIasiLugoj
3660 16024216117677151226244
24123438010019325332980199374
(dequeue P: g = 317) T = 118 + 329 = 447, Z = 374 + 75= 449,
B = 518 + 0 = 518
, C = 366 + 160 = 526, B = 550
RV
= 414 + 193 = 607
,^ C = 455 + 160 = 615
, A = 280 + 336 =
616, O = 291 + 380 = 671 (dequeue T: g = 118) Z = 374 + 75 = 449,
L = 229 + 244
= 473
, B = 518 + 0 = 518, C = 366 + 160 = 526, B = 550
A = 236 + 336 = 572
, S =
338 + 253 = 591, RV = 414 + 193 = 607, C = 455 + 160 =615, A = 280 + 336 = 616, O = 291 + 380 = 671 (dequeue Z: g = 75) L = 229 + 244 = 473,
A = 150 + 336
= 486
, B = 518 + 0 = 518,
O = 146 + 380 = 526
, C = 366
Department of Computer Science — University of San Francisco – p.12/
MehadiaNeamtOradeaPitestiRimnicu VilceaSibiuTimisoara UrziceniVasluiZerind
AradBucharestCraiovaDobretaEforieFagarasGiurgiuHirsovaIasiLugoj
366016024216117677151226244
24123438010019325332980199374
(dequeue L: g = 229) A = 150 + 336 = 486, B = 518 + 0 =518, O = 146 + 380 = 526, C = 366 + 160 = 526,
M = 299
, B = 550 + 0 = 550, S = 300 + 253 = 553, A =
236 + 336 = 572, S = 338 + 253 = 591, RV = 414 + 193 =607, C = 455 + 160 = 615, A = 280 + 336 = 616,
T = 340
, O = 291 + 380 = 671
(dequeue A: g = 150) B = 518 + 0 = 518, O = 146 + 380 =526, C = 366 + 160 = 526, M = 299 + 241 = 540,
S = 290
, B = 550 + 0 = 550, S = 300 + 253 = 553, A =
236 + 336 = 572, S = 338 + 253 = 591,
T = 268 + 329 =
597
,^ Z = 225 + 374 = 599
, RV = 414 + 193 = 607, C =
455 + 160 = 615, A = 280 + 336 = 616, T = 340 + 329 =669, O = 291 + 380 = 671 (dequeue B: g = 518) solution. A -> S -> RV -> P -> B
Department of Computer Science — University of San Francisco – p.13/
We could always keep the version of the state withthe lowest
g
More simply, we can also ensure that we alwaystraverse the best path to a node first. a^ monotonic
heuristic guarantees this.
A heuristic is monotonic if, for every node
n
and each of
its successors
(n
h(
n)
is less than or equal to
stepCost
(n, n
′) +
h(
′n)
In geometry, this is called the triangle inequality.
Department of Computer Science — University of San Francisco – p.15/
h^
is monotonic, then
f^
is nondecreasing as
we expand the search tree. Alternative proof of optimality. Notice also that UCS is A* with
h(
n) = 0
A* is also
optimally efficient
No other complete and optimal algorithm isguaranteed to expand fewer nodes.
Department of Computer Science — University of San Francisco – p.16/
Node:
Queue
:
A^
[(C
f^
= 22,
g^
=^ 7,
h^
=^ 15),
(B
f^
= 28,
g^
=^ 8,
h^
=^ 20)]
Department of Computer Science — University of San Francisco – p.18/
Node:
Queue
:
C^
[(D
f^
=^ 23,
g^
=^ 15,
h^
= 8),
(B
f^
=^ 28,
g^
=^ 8,
h^
=^ 20)]
Department of Computer Science — University of San Francisco – p.19/