Heuristic Search: Greedy, A* & IDA* for Optimal Solutions - Prof. Dana S. Nau, Study notes of Computer Science

Informed search algorithms, specifically greedy search, a* search, and ida*. These algorithms use heuristic functions to estimate the cost of paths and find optimal solutions. The document also covers the properties of these algorithms, their completeness, and space requirements.

Typology: Study notes

Pre 2010

Uploaded on 02/13/2009

koofers-user-qlj
koofers-user-qlj 🇺🇸

10 documents

1 / 55

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Last update: September 9, 2008
Informed search algorithms
CMSC 421: Chapter 4, Sections 1–2
CMSC 421: Chapter 4, Sections 1–2 1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37

Partial preview of the text

Download Heuristic Search: Greedy, A* & IDA* for Optimal Solutions - Prof. Dana S. Nau and more Study notes Computer Science in PDF only on Docsity!

Last update: September 9, 2008

Informed search algorithms

CMSC 421: Chapter 4, Sections 1–

Motivation

♦ In Chapter 3 we were talked about trial-and-error search

♦ In the worst case, most searches take exponential time (unless P=NP)

♦ Can sometimes do much better on the average, using heuristic techniques

heuristic: A rule of thumb, simplification, or educated guess that reduces or limits the search for solutions in domains that are difficult and poorly understood.

Depending on what heuristic you use, you won’t necessarily find an optimal solution, or even a solution at all.

Heuristic search

function Tree-Search( problem) returns a solution, or failure fringe ← a list containing Make-Node(Initial-State[problem]) loop do if fringe is empty then return failure node ← Remove-Front(fringe) if Goal-Test[problem] applied to State(node) succeeds return node fringe ← InsertAll(Expand(node, problem), fringe)

Heuristic choice in search algorithms: what node to expand next Use an evaluation function for each node – estimate of “desirability” ⇒ Expand most desirable unexpanded node

This depends on InsertAll Want to keep fringe sorted in decreasing order of desirability

Heuristic search on graphs

function Graph-Search( problem, fringe) returns a solution, or failure closed ← an empty set fringe ← Insert(Make-Node(Initial-State[problem]), fringe) loop do if fringe is empty then return failure node ← Remove-Front(fringe) if Goal-Test(problem, State[node]) then return node if State[node] is not in closed then add State[node] to closed fringe ← InsertAll(Expand(node, problem), fringe) end

Same as for Tree-Search: Use InsertAll to keep fringe sorted in decreasing order of desirability

Greedy search

Evaluation function h(n) (heuristic) = estimate of cost from n to the closest goal

E.g., hSLD(n) = straight-line distance from n to Bucharest

Greedy search keeps fringe ordered in increasing value of h, hence always expands whatever node appears to be closest to a goal

Greedy search example

Arad 366 ↗ straight-line distance to Bucharest

Greedy search example

Rimnicu Vilcea

Zerind

Arad

Sibiu

Arad Fagaras Oradea

Timisoara 329 374

366 176 380 193

Greedy search example

Rimnicu Vilcea

Zerind

Arad

Sibiu

Arad Fagaras Oradea

Timisoara

Sibiu Bucharest

329 374

366 380 193

253 0

Properties of greedy search

Complete? No. Can get stuck in loops: Iasi → Neamt → Iasi → Neamt → Complete in finite space with repeated-state checking

Time?

Properties of greedy search

Complete? No. Can get stuck in loops: Iasi → Neamt → Iasi → Neamt → Complete in finite space with repeated-state checking

Time? O(bm), but a good heuristic can give dramatic improvement

Space?

Properties of greedy search

Complete? No. Can get stuck in loops: Iasi → Neamt → Iasi → Neamt → Complete in finite space with repeated-state checking

Time? O(bm), but a good heuristic can give dramatic improvement

Space? O(bm)—keeps all nodes in memory

Optimal? No

Problem with terminology: Greedy search is not the same as an ordinary greedy algorithm.

An ordinary greedy algorithm doesn’t remember all of fringe. It remembers only the current path, and never backtracks. Hence: ♦ Repeated-state checking cannot make it complete ♦ It runs in time O(l) if it finds a solution of length l

A∗^ search

Idea: avoid expanding paths that are already expensive

Evaluation function f (n) = g(n) + h(n)

g(n) = cost so far to reach n h(n) = estimated cost to goal from n f (n) = estimated total cost of path through n to goal

First requirement for A∗^ search:

A∗^ needs an admissible heuristic i.e., 0 ≤ h(n) ≤ h∗(n) where h∗(n) is the true cost from n. (Thus h(G) = 0 for any goal G.)

E.g., hSLD(n) never overestimates the actual road distance

Romania with step costs in km

Recall that we want to get from Arad to Bucharest:

Bucharest

Giurgiu

Urziceni

Hirsova

Eforie

Neamt Oradea

Zerind

Arad

Timisoara

Lugoj Mehadia

Dobreta

Craiova

Sibiu

Fagaras

Pitesti Rimnicu Vilcea

Vaslui

Iasi

Straight−line distanceto Bucharest

0 160 242 161 77 151

241

366

193

178

253 329 80 199

244

380

226

234

374

98

Giurgiu

Urziceni Hirsova

Eforie

Neamt

Oradea

Zerind

Arad

Timisoara Lugoj

Mehadia

Dobreta Craiova

Sibiu (^) Fagaras

Pitesti

Vaslui

Iasi

Rimnicu Vilcea

Bucharest

71

75

118

111 70

75 120

151 140 99 80

97 101

211

138

146 85

90

98

142

92

87

86

A∗^ search

Arad 366=0+