



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Chris Brooks Department of Computer Science University of San Francisco Department of Computer Science — University of San Francisco – p.1/
Heuristic Search - exploiting knowledge about the problem Heuristic Search Algorithms “Best-first” search Greedy Search A* Search Extensions to A* Constructing Heuristics Department of Computer Science — University of San Francisco – p.2/
Previous algorithms were able to find solutions, but were very inefficient. Exponential number of nodes expanded. By taking advantage of knowledge about the problem structure, we can improve performance. Two caveats: We have to get knowledge about the problem from somewhere. This knowledge has to be correct. Department of Computer Science — University of San Francisco – p.3/
Recall Uniform-cost search Nodes were expanded based on their total path cost A priority queue was used to implement this.
. evaluation function Path cost is an example of an to refer to an evaluation )n( f We’ll use the notation 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.4/
f By ordering and expanding nodes according to their value, we search the “best” nodes “first” was perfect, we would expand a straight path from the f If initial state to the goal state. Arad, Sibiu, Rimnicu Vilcea, Pitesti, Bucharest , we wouldn’t need to solve f Of course, if we had a perfect the problem in the first place. that )n(h Instead, we’ll try to develop heuristic functions .)n( f help us estimate
Best-first Pseudocode enqueue(initialState) do dequeue() = node goalTest(node) if node return else successor-fn(node) = children children in child for f(child)) insert-with(child, where insert-with orders our priority queue accordingly.
Let’s start with the opposite of uniform-cost search f UCS used the solution cost to date as an estimate of uses an estimate of distance to the goal Greedy search
. f for Rationale: Always pick the node that looks like it will get you closest to the solution. for the Romania f Let’s start with a simple estimate of domain. Straight-line distance between that city and) =city( h Bucharest. Department of Computer Science — University of San Francisco – p.7/
Notice that there wasn’t anything in the problem description about straight-line distance or the fact that that would be a useful estimate. We used our knowledge about the way roads generally work. knowledge. common sense This is sometimes called Department of Computer Science — University of San Francisco – p.8/
Urziceni NeamtOradea Zerind Timisoara Mehadia Sibiu PitestiRimnicu Vilcea Vaslui Bucharest GiurgiuHirsova Eforie Arad Lugoj DobretaCraiova Fagaras Iasi 0160 242161 77151 366 (^244226) 176 241 253329 80199 (^380234) 374 100193 A = 336 (dequeue A) S = 253, T = 329, Z = 374 (dequeue S) F = 176, RV = 193, T = 329, A = 336, Z = 374, O = 380 (dequeue F) B = 0, RV = 193, S = 253, T = 329, A = 336, Z = 374, O = 380 dequeue B - solution: A -> S -> F ->B We found a solution quickly, but it was not optimal. What was the problem with our approach? Department of Computer Science — University of San Francisco – p.9/
Sometimes the optimal solution to a problem involves moving ’away’ from the goal. For example, to solve 8-puzzle, you often need to ‘undo’ a partial solution. Greedy search has many of the same appeals and weaknesses as DFS. Expands a linear number of nodes Is not complete or optimal Its ability to cut toward a goal is appealing - can we salvage this? Department of Computer Science — University of San Francisco – p.10/
A* search is a combination of uniform cost search and greedy search. )n(h ) +n(g ) =n( f A node’s = current path cost )n( g = heuristic estimate of distance to goal. )n( h Favors nodes that have a cheap solution to date and also look like they’ll get close to the goal. satisfies certain conditions, A* is both complete )n(h If (always finds a solution) and optimal (always finds the best solution).
= straight-line distance h Urziceni NeamtOradea Zerind Timisoara Mehadia Sibiu PitestiRimnicu Vilcea Vaslui Bucharest GiurgiuHirsova Eforie Arad Lugoj DobretaCraiova Fagaras Iasi 0160 242161 77151 366 (^244226) 176 241 253329 80199 (^380234) 374 100193 Arad = 0 + 366 = 366 T = 118 + 329 = , S = 140 + 253 = 393 (dequeue A: g = 0) Z = 75 + 374 = 449 , 447 F = 239 + , RV = 220 + 193 = 413 (dequeue S: g = 140) A = , T = 118 + 329 = 447, Z = 374 + 75 = 449,176 = 415 , O = 291 + 380 = 671 , 280 + 336 = 616 P = 317 + (dequeue RV: g = 220) F = 239 + 176 = 415, C = , T = 118 + 329 = 447, Z = 374 + 75 = 449,100 = 417 , A = 280 + 336 = S = 300 + 253 = 553 , 366 + 160 = 526 616, O = 291 + 380 = 671 (dequeue F: g = 239) P = 317 + 100 = 417, T = 118 + 329 B = 550 = 447, Z = 374 + 75 = 449, C = 366 + 160 = 526, ,A = S = 338 + 253 = 591 , S = 300 + 253 = 553,+ 0 = 550 280 + 336 = 616, O = 291 + 380 = 671
While A* is optimally efficient, actual performance depends on developing accurate heuristics. )as∗h is as close to the actual cost to the goal ( h Ideally, possible while remaining admissible. Developing an effective heuristic requires some understanding of the problem domain. Department of Computer Science — University of San Francisco – p.19/
h1 - number of misplaced tiles. This is clearly admissible, since each tile will have to be moved at least once. between each tile’s current Manhattan distance h2 - position and goal position. Also admissible - best case, we’ll move each tile directly to where it should go. Which heuristic is better? Department of Computer Science — University of San Francisco – p.20/
h2 is better. as possible. ∗h to be as close to h We want h1. dominates , we say that h2n for all )n1( > h )n2(h If We would prefer a heuristic that dominates other known heuristics. Department of Computer Science — University of San Francisco – p.21/
So how do we find a good heuristic? Solve a relaxed version of the problem. Cost of an optimal solution to the relaxed version is an admissible heuristic for the original problem. 8-puzzle - allow tiles to move over each other. Romania - assume that there is a road from every city to the goal. Solve subproblems Cost of moving one tile, traversing a path Often, these subproblems (and their solutions) are then cached. Learning from experience Department of Computer Science — University of San Francisco – p.22/
A* has one big weakness - Like BFS, it potentially keeps an exponential number of nodes in memory at once. Iterative deepening A* is a workaround. Rather than searching to a fixed depth, we search to a fixed f-cost. and start f If the solution is not found, we increase again. Works in worlds with uniform, discrete-valued step costs
Recursive best-first search Combination of DFS and A. Do DFS, but keep the f-cost of all fringe nodes. If expansion leads to a node worse than something in the fringe, backtrack. Improvement over A, but not spectacular. Both IDA* and RBFS throw away too much.
Regular A, plus a fixed limit on memory used. When memory is full, discard the node with the highest f. Value of discarded node is assigned to the parent. This allows SMA to ’remember’ the value of that branch. If all other branches get a higher f value, this child will be regenerated. SMA* is complete and optimal. On very hard problems, SMA* can wind up repeatedly deleting and regenerating branches. Moral: Often, memory requirements make our problem Department of Computer Science — University of San Francisco – p.25/27 intractable before time requirements.
Problem-specific heuristics can improve search. Greedy search
Developing heuristics Admissibility, monotonicity, dominance Memory issues Department of Computer Science — University of San Francisco – p.26/
Project 1 assigned Start on Constraint Satisfaction Scheduling Map coloring Satisfiability Department of Computer Science — University of San Francisco – p.27/