Professional Documents
Culture Documents
CH 4 - Informed Search
CH 4 - Informed Search
INTELLIGENCE- CS411
Prof. Alaa Sagheer
Artificial Intelligence “CS 411”
• Textbook:
S. Russell and P. Norvig
Artificial Intelligence: A Modern Approach
Prentice Hall, 2010, Third Edition
Informed Search
S
4
Informed Search
In which we see how information about the
state space can prevent algorithms from
blundering about in the dark
Best-First Search
• A node is selected for expansion based on an evaluation
function, f(n)
- Traditionally, the node with the lowest evaluation is selected for expansion,
because the evaluation measures distance to the goal.
What is Heuristic?
• Merriam-Webster's Online Dictionary
Heuristic (pron. \hyu-’ris-tik\): adj. [from Greek heuriskein to discover.]
involving or serving as an aid to learning, discovery, or problem-solving by
experimental and especially trial-and-error methods
• The Free On-line Dictionary of Computing (15Feb98)
heuristic 1. <programming> A rule of thumb, simplification or educated
guess that reduces or limits the search for solutions in domains that are
difficult and poorly understood. Unlike algorithms, heuristics do not
guarantee feasible solutions and are often used with no theoretical
guarantee. 2. <algorithm> approximation algorithm.
• From WordNet (r) 1.6
heuristic adj 1: (computer science) relating to or using a heuristic rule 2: of
or relating to a general formulation that serves to guide investigation [ant:
algorithmic] n : a commonsense rule (or set of rules) intended to increase
the probability of solving some problem [syn: heuristic rule, heuristic
program]
The values of hSLD cannot be computed from the problem description itself
Artificial Intelligence Ch4: Informed Search Dr. Alaa Sagheer
10
• Time?
O(bm), but a good heuristic can give dramatic improvement
• Space?
O(bm) -- keeps all nodes in memory
b : The branching factor (or maximum number of successors of any node)
m : The maximum depth of the search space.
8 S g = 0 h=6
e h=1 g = 1 h=5 a
1
1 3 2 g=9
S a d G g = 2 h=6 b d e h=1
h=6 g = 4 h=2
1 h=5 h=2 h=0
1
c b g = 10
g = 3 h=7 c G d
g = 6 h=0 h=2
h=7 h=6
G
• A* Search orders by the sum: f(n) = g(n) + h(n) g = 12
h=0
19
A*
• Idea: avoid expanding paths that are already expensive.
• It evaluates nodes by combining g(n), the cost to reach the node, and
h(n), the cost to get from the node to the goal.
A*
A*
A*
A*
A*
A*
Examples
On the Romanian map, explain the available paths for a tourist would like to travel from
Lugoj to Bucharest. What are the costs of each path using the A* search algorithm via the
given extra information in table? Which shortest path the tourist should take?
- You SHOULD enhance your answer with a tree includes all possible paths!
27
Solution
Solution
Solution
Examples
On the given graph, write the Queue form of this problem. Which shortest path from S to G
Solution
Examples
On the given graph, write the Queue form of this problem. Which shortest path from S to G
Solution
34
Example
On the given graph, write the Queue form of this problem. Which shortest path from S to G
Admissible Heuristics
• A heuristic h(n) is admissible if for every node n,
h(n) ≤ h*(n), where h*(n) is the true/actual cost to reach the goal
state from n.
Optimality of A* (proof)
• Suppose some suboptimal goal path G2 has been generated and is in the
frontier. Let n be an unexpanded node in the frontier such that n is on a
shortest path to an optimal goal G.
Prove that G2 can NOT be chosen?
Optimality of A* (proof)
• Suppose some suboptimal goal path G2 has been generated and is in the
frontier. Let n be an unexpanded node in the frontier such that n is on a
shortest path to an optimal goal G.
•Prove that G2 can NOT be chosen?
Properties of A*
• Complete? Yes (unless there are infinitely many nodes
with f ≤ f(G) )
•
• Optimal? Yes
•
• Time? Exponential
•
• Space? Keeps all nodes in memory
Heuristic Functions
• The average solution cost for a randomly generated 8-puzzle instance is
about 22 steps. The branching factor is about 3 *.
• This means that an exhaustive search to depth 22 would look at about
Heuristic Functions
For this target, two ways for solution (finding h) we have:
• h1(S) = ?
• h2(S) = ?
•
Admissible Heuristic
Two ways for solution (finding h)
• 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. Or h2 is better for search
• Domination translates directly into efficiency: A* using h2 will never expand
more nodes than A* using h1.
Dominance
We generated 1200 random problems of 8-puzzle with solution lengths from 2
to 24 (100 time for each even d). Here the average number of nodes generated
•If h2(n) >= h1(n) for all n (both admissible)…then h2 dominates h1 and is better
for search
-Solution with length 12, A* with h2 is 50,000 times more efficient than uninformed
iterative deepening search.
Artificial Intelligence Ch4: Informed Search Dr. Alaa Sagheer
Inventing Admissible Heuristics
• One problem with generating new heuristic functions is that one often
fails to get one "clearly best” heuristic.
45
Artificial Intelligence Ch4: Informed Search Dr. Alaa Sagheer
Local Search Algorithms
Till now: Systematic exploration of search space.
- Path to goal is solution to problem
47
Artificial Intelligence Ch4: Informed Search Dr. Alaa Sagheer
Hill-Climbing Search
• It is simply a loop that continually moves in the direction of
structure need only to record the state and its objective function
value
2 8 3 1 2 3
start 1 6 4 h = -4 goal 8 4 h=0
7 5 7 6 5
-5 -5 -2
2 8 3 1 2 3
1 4 h = -3 8 4 h = -1
7 6 5 7 6 5
-3 -4
2 3 2 3
1 8 4 1 8 4 h = -2
7 6 5 7 6 5
h = -3 -4
50
Artificial Intelligence Ch4: Informed Search Dr. Alaa Sagheer
HCS Example 8-queens problem
• Put n queens on an n x n board with no two queens on the same
row, column, or diagonal
51
Artificial Intelligence Ch4: Informed Search Dr. Alaa Sagheer
HCS Example 8-queens problem
a) b)
• Local Maxima is a peak that is higher than each of its neighboring states, but
lower than the global maximum – figure shows a local Maxima *
• Ridge = sequence of local maxima difficult for greedy algorithms to navigate
• Plateaux = an area of the state space where the evaluation function is flat –
no uphill exit seems to exist, i.e. gives no direction (random walk)
In each case, the algorithm reaches a point at which no progress is being
made.
• Remedy:
• Introduce randomness!
53
Artificial Intelligence Ch4: Informed Search Dr. Alaa Sagheer
55
Applications
Find the shortest path? And then judge, does the attached
heuristic admissible?
State h A 12
1
S 7 5
A 6 S
2 C G
3
B 2 4 B 2
C 1
G 0
Applications
Find the shortest path? And then judge, does the attached
heuristic admissible?
State h
1 C
A 5 12
B 6 B
2 7 D 5
C 4
D 15 S 2 G
4 E
E 5 1 A
F 8 3
7 F
Program Task:
The 8-Queens Puzzle