Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
2006
Review: Exercise
10 A
7
5
B C D
5 20 15
6 25 20
E F
G H I J
10
12
10 15
K L 8
N M O - Initial: A; Goal: I , N
Solution:
(1) ABCDEFGHI - Find seq. for each
(2) ABEKLFCGMN tree search algrithm?:
(3) ACDBGEN (1)BFS; (2)DFS; (3)uniform-cost;
(4) ABEFCGDHI (4)Depth-limited (l=2);
(5) A; ABCD; ABEKLFCGMN (5)Iterative deepening
Informed search
Best-first search
¾ (Greedy) best-first search
¾ A* search
Heuristics
Local search
¾ Hill
climbing
¾ Simulated annealing
¾ Genetic algorithms
Best-first search
Idea: use an evaluation function f(n) for each node
¾ estimate of "desirability"
Æ Expand most desirable unexpanded node
Implementation:
Order the nodes in fringe in decreasing order of
desirability
Special cases:
¾ greedy best-first search
¾ A* search
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
Consistent heuristics
A heuristic is consistent if for every node n, every successor n' of n
generated by any action a,
If h is consistent, we have
f(n') = g(n') + h(n')
= g(n) + c(n,a,n') + h(n')
≥ g(n) + h(n) triangle inequality
= f(n)
i.e., f(n) is non-decreasing along any path.
Theorem: If h(n) is consistent, A* using GRAPH-SEARCH is optimal
Optimality of A*
A* expands nodes in order of increasing f value
Gradually adds "f-contours" of nodes
Contour i has all nodes with f=fi, where fi < fi+1
Properties of A*
Complete? Yes (unless there are infinitely many
nodes with f ≤ f(G) )
Time? Exponential
Space? Keeps all nodes in memory
Optimal? Yes
Admissible heuristics
E.g., for the 8-puzzle:
h1(n) = number of misplaced tiles
h2(n) = total Manhattan distance
(i.e., no. of squares from desired location of each tile)
h1(S) = ? 8
h2(S) = ? 3+1+2+2+2+3+3+2 = 18
Dominance
If h2(n) ≥ h1(n) for all n (both admissible)
then h2 dominates h1
h2 is better for search
Relaxed problems
A problem with fewer restrictions on the actions is called a
relaxed problem
The cost of an optimal solution to a relaxed problem is an
admissible heuristic for the original problem
If the rules of the 8-puzzle are relaxed so that a tile can
move anywhere, then h1(n) gives the shortest solution
If the rules are relaxed so that a tile can move to any
adjacent square, then h2(n) gives the shortest solution
Example: n-queens
Put n queens on an n × n board with no two queens
on the same row, column, or diagonal
Move queens to reduce conflicts
Hill-climbing search
"Like climbing Everest in thick fog with amnesia"
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
Hill-climbing variations
Stochastic hill-climbing
¾ Random selection among the uphill moves.
¾ The selection probability can vary with the steepness of the
uphill move.
First-choice hill-climbing
¾ cfr. stochastic hill climbing by generating successors
randomly until a better one is found.
Random-restart hill-climbing
¾ Tries to avoid getting stuck in local maxima.
local minimum
global minimum
Genetic algorithms
Variant of local beam search with sexual recombination.
Genetic algorithms
A successor state is generated by combining two parent states
Genetic algorithms
Genetic algorithms
References
Slides provided by Prof. Russell at http://aima.cs.berkeley.edu/
AIMA chapter 4