Loading in 5 sec....

State Space 3 Chapter 4 PowerPoint Presentation

State Space 3 Chapter 4

- 133 Views
- Uploaded on

Download Presentation
## PowerPoint Slideshow about ' State Space 3 Chapter 4 ' - dougal

**An Image/Link below is provided (as is) to download presentation**

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

### State Space 3Chapter 4

Heuristic Search

- Backtrack
- Depth First
- Breadth First
All work if we have well-defined:

- Goal state
- Start state
- State transition rules
But could take a long time

- An informed guess that guides search through a state space
- Can result in a suboptimal solution

A D

B C

C B

D A

Two rules:

clear(X) on(X, table)

clear(X) ^ clear(Y) on(X,Y)

Generate part of the search space BF. We’ll find the answer, but it could take a long time.

Blocks World: A Stack of Blocks- For each block that is resting where it should, subtract 1
- For each block that is not resting where it should, add 1

- At every level, generate all children
- Continue down path with lowest score
Define three functions:

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

Where:

h(n) is the heuristic estimate for n--guides the search

g(n) is path length from start to current node—ensures that we choose node closest to root when more than 1 have same h value

B DA

A

D

At level n

The f(n) of each structure is the same

f(n) = g(n) = (1+1-1-1) = g(n)

But which is actually better

Problem: heuristic is localB

A

D

- Must be entirely undone
- Goal Requires 6 moves
CBDA

- Goal requires only two moves

Takes the entire structure into account

- Subtract 1 for each block that has correct support structure
- Add 1 for each block in an incorrect support structure

C

B

A

C f(n) = g(n) + (3+2+1+0) =g(n) + 6

B

A

D

CB f(n) = g(n) + (1 + 0 -1+ 0) = g(n)

DA

So the heuristic correctly chose the second structure

Seems to Work- Open contains current fringe of the search
- Open: priority queue ordered by f(n)
- Closed: queue of states already visited
- Nodes could contain backward pointers so that path back to root can be recovered

path best_first(Start)

{

open = [start], closed = [];

while (!open.isEmpty())

{

cs = open.serve();

if (cs == goal)

return path;

generate children of cs;

for each child

{

case:

{

child is on open; //node has been reached by a shorter path

if (g(child) < g(child) on open)

g(child on open) = g(child);

break;

child is on closed;

if (g(child < g(child on closed))

{ //node has been reached by a shorter path and is more attractive

remove state from closed;

open.enqueue(child);

}

break;

default:

{

f(child) = g(child) + h(child);//child has been examined yet

open.enqueue(child);

}

}

}

closed.enqueue(cs);//all cs’ children have been examined.

open.reorder();//reorder queue because case statement may have affected ordering

}

return([]); //failure

}

- Admissible Search Algorithms
- Find the optimal path to the goal if a path to the goal exists

- Breadth-First: Admissible
- Depth-First: Not admissible

Where

- g*(n) is the cost of the shortest path from start to n
- h*(n) is the cost of the shortest path from n to goal
So, f*(n) is the actual cost of the optimal path

Can we know f*(n)?

- Not without having exhaustively searched the graph
- Goal: Approximate f*(n)

- g(n) – actual cost to n
- g*(n) – shortest path from start to n
So g(n) >= g*(n)

When g*(n) = g(n), the search has discovered the optimal path to n

- Often we can know
- Ifh(n) is bounded above by h*(n)
- (This sometimes means finding a function h2(n) such that h(n) <= h2(n) <= h*(n))

- Meaning: the optimal path is more expensive than the one suggested by the heuristic
- Turns out this is a good thing (within bounds)

164 -> 8 4

7 5 765

Invent two heuristics: h1 and h2

h1(n): number of tiles not in goal position

h1(n) = 5 (1,2,6,8,B)

h2(n): number of moves required to move out-of-place tiles to goal

T1 = 1, T2 = 1, T6 = 1, T8 = 2, TB = 1

h2(n) =6

h1(n) <= h2(n) ?

An 8-puzzle Intuitionh2(n) <= h*(n)

- Each out-of-place tile has to be moved a certain distance to reach goal
h1(n) <= h2(n)

- h2(n) requires moving out-of-place tiles at least as far as h1(n)
So, h1(n) <= h2(n) <=h*(n)

If algorithm A uses a heuristic that returns a value h(n) <= h*(n) for all n, then it is called A*

What does this property mean?

Leads to a Definition- It means that the heuristic estimate chosen never thinks a path is better than it is

goal

- Suppose: h(rst) = 96
- But we know it is really 1 (i.e. h*(rst) = 1) because we’re the oracle
- Suppose: h(lst) = 42
- Left branch looks better than it really is
- This makes the left branch seem better than it actually is

Suppose: path is better than it is

- h(n) = 0 and so <= h*(n)
Search will be controlled by g(n)

If g(n) = 0, search will be random: given enough time, we’ll find an optimal path to the goal

If g(n) is the actual cost to n, f(n) becomes breadth-first because the sole reason for examining a node is its distance from start.

We already know that this terminates in an optimal solution

- h(n) = h*(n) path is better than it is
Then the algorithm will go directly to the goal since h*(n) computes the shortest path to the goal

Therefore, if our algorithm is between these two extremes, our search will always result in an optimal solution

Call h(n) = 0, h’(n)

So, for any h such that

h’(n) <= h(n) <= h*(n) we will always find an optimal solution

The closer our algorithm is to h’(n), the more extraneous nodes we’ll have to examine along the way

For any two A* heuristics, ha, path is better than it ishb

If ha(n) <= hb(n), hb(n) is more informed.

InformednessComparison of two solutions that discover the optimal path to the goal state:

- BF: h(n) = 0
- h(n) = number of tiles out of place
The better informed solution examines less extraneous information on its path to the goal

Download Presentation

Connecting to Server..