KR-IST - Lecture 4a Heuristic search with A*

Chris Thornton


The problem of the supersized search space

Search is a flexible tool which can be used, in principle, to obtain a solution to any problem.

In practice, there is a serious difficulty.

For most problems, the search tree is just too big to explore in a reasonable amount of time.

Even for a problem as simple as the 8-puzzle, there are more than 31 thousand, million states to be checked.

Checking states at the rate of one per millisecond, this would take nearly a year.

The need for knowledge

If the search process is left to blindly explore the entire search space there is the risk that it will take too long.

It is generally necessary to provide knowlege which will enable the search to move more directly towards a solution node.

Search processes with knowledge of this type are said to be informed.

Processes which carry out the search in a blind or exhaustive fashion are said to be uninformed.

Evaluation functions

Knowledge is provided to the search in the form of an evaluation function for search nodes.

This function returns a value which estimates the cost of a given node, i.e., how far it is from a goal node.

The search process can use the function to select the best node to expand at any point (i.e., to choose `which way to go').

Evaluation functions are heuristic functions

Evaluation functions are often called heuristic functions on the grounds that they utilise rules-of-thumb.

Search using evaluation functions is therefore heurstic search.

But this is more than just terminology.

It would be inconsistent to use a completely accurate evaluation function for purposes of guiding a search.

Or at least it would be strange to describe the resulting process as `search'.

With a completely accurate evaluation function, the right branch can be selected at every stage. Search is not required.

Best-first search

Let's say we have an evaluation function which estimates the cost of reaching a goal from any given node, i.e., its `distance'.

We can use a cost function of this type to decide which of a set of nodes should be expanded next. We just expand the node with the lowest f value.

This procedure is known as best-first or ordered search.

Implementational issues

With best-first search, successors are not checked in a fixed sequence.

So it is necessary to maintain some sort of data structure to show which nodes remain unchecked.

This is normally done using two list structures:

Processing loop

In each iteration, the algorithm selects the most promising node from OPEN, e.g., the node with lowest estimated cost.

If the node is a goal node, a solution has been obtained.

If the node is not a goal, it is then moved from OPEN to CLOSED.

Its successors are then examined and any that don't currently appear in OPEN or CLOSED are added to OPEN.

Best-first search algorithm

(1) Put the start node n on a list called OPEN, of unexpanded nodes and associate the f(n) value with it.

(2) If OPEN is empty, exit with failure; no solution exists.

(3) Select from OPEN a node n for which f(n) is a minimum. If several nodes qualify, choose a solution node if there is one, and otherwise choose among them arbitrarily.

(4) Remove node n from OPEN and place it on CLOSED.

(5) If n is a goal node, exit with success; a solution has been found.

(6) Expand node n, creating nodes for all its successors. For every successor n, if n is neither in OPEN nor in CLOSED, then add it to OPEN, with its f(n) value. Attach a pointer from n back to the predecessor node (to provide access to the path to the goal node.)

(7) Go to step (2).

A* search

A* search is essentially best-first search upgraded for use with path-oriented evaluation functions.

This is the kind of evaluation function that we will need to use whenever the solution is the path to the goal node rather than the node itself.

Evaluation with A*

In A* search, evaluation of the cost of a given node is assumed to be defined in terms of two components, g(n) and h(n), where

and

The final evaluation of cost is then the sum of g(n) and h(n):

(In some presentations these functions are written as f*, g* and h* with the unadorned letters being used to denote the actual costs.)

Node updates are required in A* search

The catch with A* is that, due to taking the known part of the solution into account when working out costs, it is actually possible for f(n) values to change.

This happens if the search uncovers a new, lower-cost path to a previously expanded state.

If this situation is detected, the algorithm must update the evaluations associated with the state, both in OPEN and CLOSED, and change the predecessor pointer so as to connect it to the new path.

If there is an improvement in the evaluation of a state in CLOSED, that state must be transferred back to OPEN.

(See step step 6.c in the Handbook of AI, vol 1, p. 61).

A heuristic which guarantees that f(n) values will never drop in this way is said to be consistent.

Evaluation change for open node, state 1

Evaluation change for open node, state 2

Evaluation change for open node, state 3

Evaluation change for open node, state 4

Evaluation change for closed node, state 1

Evaluation change for closed node, state 2

Evaluation change for closed node, state 3

Evaluation change for closed node, state 4

Evaluation change for closed node, state 5

Optimality

How reliable is A* search?

The g(n) value is always right, since it measures the cost of a path which has already been identified. (This is normally the path length.)

The h value is an estimate.

But provided it never overestimates the cost, the search is guaranteed to be optimal.

The requirement that h not overestimate the cost is known as the admissibility criterion.

Why admissibility guarantees optimality

The cost of node at the end of a solution path is guaranteed to be correct. At this point, h(n) = 0, so f(n) = g(n).

If h never overestimates, the cost of a node at the end of a sub-optimal solution path must be greater than the cost of any node on an optimal solution path.

Assuming A* always expands the node with the lowest cost, search will continue until the optimal solution path is identified.

Unfortunately, in practice, the admissibility criterion may not be satisfied.

Heuristic function for the 8-puzzle

Russell and Norvig investigate the performance of two possible heuristic functions for the 8-puzzle problem (see pp. 101-103).

They use empirical performance evaluations and the concept of branching factor, to demonstrate that that h2 is considerably more effective than h1.

They also show that A* search (using either heuristic) is orders of magnitude faster than ordinary iterative-deepening search, the best of the `uninformed' bunch.

This result, showing the supremacy of A* search over uninformed iterative-deepening search, is common across most search problems.

.

Summary

Questions

More questions

More questions

Exercises

    1 2
  3 4 5
  6 7 8

draw out the search tree down to four levels of search (i.e., four levels plus the start node) using this as the start state. The tree should only contain one instance of any given state.

  3 1 2
  4 7 5
  6 8

Exercises cont.

    2 1
  4 5 3
  7 8 6

as the starting state. In what way is this problem qualitatively different to the original?

Exercises cont.

Resources