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.
3
Example: 8 Puzzle
1 2 37 46
85
1 2 38 47 6 5
4
1 2 3
6 5
7 8 4
leftup
Which move is best?
right
1 2 3
5
7 8 4
1 2 3
6 5
7 8 4
1 2 3
6 5
7
8
4
6
1 2 3
7 6 5
8 4
GOAL
5
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).
6
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.
7
1 2 3
6 5
7 8 4
leftup
right
1 2 3
5
7 8 4
1 2 3
6 5
7 8 4
1 2 3
6 5
7
8
4
6
1 2 3
7 6 5
8 4
GOAL
h=2 h=4 h=3
8
Another 8-puzzle heuristic
• Count how far away (how many tile movements) each tile is from it’s correct position.
• Sum up this count over all the tiles.• This is another estimate on the number of
moves away from a solution.
9
1 2 3
6 5
7 8 4
leftup
right
1 2 3
5
7 8 4
1 2 3
6 5
7 8 4
1 2 3
6 5
7
8
4
6
1 2 3
7 6 5
8 4
GOAL
h=2 h=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 TREE-SEARCH 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., n-
queens• 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
27
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.
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
30
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!
31
TSP Example
A B
CD 4
6
35
1 2
32
TSP Hill Climb State Space
CABDCABD ABCDABCD ACDBACDB DCBADCBA
Initial State
Swap 1,2 Swap 2,3Swap 3,4 Swap 4,1
Swap 1,2
Swap 2,3
Swap 3,4
Swap 4,1
ABCDABCD
BACDBACD ACBDACBD ABDCABDC DBCADBCA
Recommended