You are on page 1of 32

Informed search algorithms

Uninformed and informed search


Uninformed techniques (blind search) are
not always possible (they require too
much time or memory).
Informed techniques can be effective if
applied correctly on the right kinds of
tasks.
Typically require domain specific information.

Example: 8 Puzzle

1 2 3
7 8 4
6
5

1 2 3
8
4
7 6 5
3

1 2 3
8

GOAL

1 2 3
7 8 4

7 6 5

left

right

up

1 2 3

1 2 3

1 2 3

7 8 4

7 8 4

6 5

6 8 5

6 5

Which move is best?


4

8 Puzzle Heuristics
Blind search techniques used an arbitrary
ordering (priority) of operations.
Heuristic search techniques make use of
domain specific information - a heuristic.
What heurisitic(s) can we use to decide
which 8-puzzle move is best (worth
considering first).

A Simple 8-puzzle heuristic


Number of tiles in the correct position.
The higher the number the better.
Easy to compute (fast and takes little
memory).
Probably the simplest possible heuristic.

Number of tiles in the incorrect position.


The best move is the one with the lowest
number returned by the heuristic.
6

1 2 3
8

GOAL

1 2 3
7 8 4

7 6 5

left

right

up

1 2 3

1 2 3

1 2 3

7 8 4

7 8 4

6 5

6 8 5

6 5
h=2

h=4

4
h=3

Another 8-puzzle heuristic


Count how far away (how many tile
movements) each tile is from its correct
position.
Sum up this count over all the tiles.
This is another estimate on the number of
moves away from a solution.

1 2 3
8

GOAL

1 2 3
7 8 4

7 6 5

left

right

up

1 2 3

1 2 3

1 2 3

7 8 4

7 8 4

6 5

6 8 5

6 5
h=2

h=4

4
h=4

Best-first search
Idea: use an evaluation function f(n) for each node
estimate of "desirability
Expand most desirable unexpanded node

Special cases:
greedy best-first search
A* search

Romania with step costs in km

Greedy best-first search


Evaluation function f(n) = h(n) (heuristic)
= estimate of cost from n to goal
e.g., hSLD(n) = straight-line distance from n
to Bucharest
Greedy best-first search expands the
node that appears to be closest to goal

Greedy best-first search


example

Greedy best-first search


example

Greedy best-first search


example

Greedy best-first search


example

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 from n to goal
f(n) = estimated total cost of path through
n to goal

A search example
*

A search example
*

A search example
*

A search example
*

A search example
*

A search example
*

Admissible heuristics
A heuristic h(n) is admissible if for every node n,
h(n) h*(n), where h*(n) is the true cost to reach
the goal state from n.
An admissible heuristic never overestimates the
cost to reach the goal, i.e., it is optimistic
Example: hSLD(n) (never overestimates the actual
road distance)
Theorem: If h(n) is admissible, A* using TREESEARCH is optimal

Local search algorithms


In many optimization problems, the path to the
goal is irrelevant; the goal state itself is the
solution
State space = set of "complete" configurations
Find configuration satisfying constraints, e.g., nqueens
In such cases, we can use local search
algorithms
keep a single "current" state, try to improve it

Example: n-queens
Put n queens on an n n board with no
two queens on the same row, column, or
diagonal

Simple Hill Climbing


Use heuristic to move only to states that
are better than the current state.
Always move to better state when
possible.
The process ends when all operators have
been applied and none of the resulting
states are better than the current state.
27

Hill-climbing search
"Like climbing Everest in thick fog with
amnesia"

Hill-climbing search
Problem: depending on initial state, can
get stuck in local maxima

Example - Traveling Salesman


Problem (TSP)
Traveler needs to visit n cities.
Know the distance between each pair of
cities.
Want to know the shortest route that visits
all the cities once.
n=80 will take millions of years to solve
exhaustively!
30

TSP Example
A
1

2
3

C
31

TSP Hill Climb State Space


Initial State

ABCD
ABCD
Swap 1,2
BACD
BACD

Swap 2,3
Swap 3,4
ACBD
ACBD

Swap 1,2

ABCD
ABCD

ABDC
ABDC

DBCA
DBCA

Swap 3,4

Swap 2,3
CABD
CABD

Swap 4,1

Swap 4,1
ACDB
ACDB

DCBA
DCBA

32

You might also like