Informed Search & Explorationweb.ntnu.edu.tw/~tcchiang/ai/3_Informed_search-1.pdf · Informed...
Transcript of Informed Search & Explorationweb.ntnu.edu.tw/~tcchiang/ai/3_Informed_search-1.pdf · Informed...
1
Artificial Intelligence, Spring, 2009
Informed Search &Exploration
Instructor: Tsung-Che [email protected]
Department of Computer Science and Information EngineeringNational Taiwan Normal University
2Artificial Intelligence, Spring, 2009
Outline
Informed Search StrategiesHeuristic FunctionsLocal Search & Optimization ProblemsOnline Search Agents and Unknown
EnvironmentsSummary
2
3Artificial Intelligence, Spring, 2009
Informed Search Strategies
Can we select the node from the fringe in amore efficient way?
Artificial Intelligence: A Modern Approach, 2nd ed., Figure 3.19
4Artificial Intelligence, Spring, 2009
Informed Search Strategies
Best-first search selects the node forexpansion according to an evaluationfunction f(n).
There is a whole family of best-firstsearch algorithms with different evaluationfunctions.
A key component of them is a heuristicfunction h(n).
h(n) = estimated cost of the cheapest pathfrom node n to a goal node
3
5Artificial Intelligence, Spring, 2009
Informed Search Strategies
Example of a heuristic functionThe straight line distance
6Artificial Intelligence, Spring, 2009
Informed Search Strategies
Heuristic functions are the most commonform to impart additional knowledge.
There is one constraint:for a goal node n, h(n) = 0.
4
7Artificial Intelligence, Spring, 2009
Greedy Best-first Search
Greedy best-first search expands the nodethat is closest to the goal, namely usingf(n) = h(n).
Assume we use the straight-line distanceas the heuristic function.
Exercise: Apply the greedy best-first search.
8Artificial Intelligence, Spring, 2009
Greedy Best-first Search
253
176
Artificial Intelligence: A Modern Approach, 2nd ed., Figure 4.2
366
h(n), straight-line distance
5
9Artificial Intelligence, Spring, 2009
Greedy Best-first Search
The solution is not optimal.Notice that the name reveals that it just tries
to get as close to the goal as it can.
10Artificial Intelligence, Spring, 2009
Greedy Best-first Search
ProblemsFrom Iasi to Fagaras
Dead end?Infinite loop?
6
11Artificial Intelligence, Spring, 2009
Greedy Best-first Search
Analysis It is neither optimal nor complete.The worst-case time and space complexity is
O(bm), where m is the maximum depth of thesearch space.
The complexity can be reduced substantially,and the amount of reduction depends on theproblem and the quality of the heuristic.
12Artificial Intelligence, Spring, 2009
A* Search
It is the most well-known form of best-first search.
It evaluates the nodes by
f(n) = g(n) + h(n), where
g(n) = the cost to reach the node h(n) = the estimated cost from the node to the
goal
f(n) = estimated cost of thecheapest solution through n
7
13Artificial Intelligence, Spring, 2009
A* Search
Exercise
14Artificial Intelligence, Spring, 2009
A* Search
366=366+0
393=140+253
415=239+176 413=220+193
417=317+100
Artificial Intelligence: A Modern Approach, 2nd ed., Figure 4.3
1
23
4
5
0
8
15Artificial Intelligence, Spring, 2009
A* Search
A* using TREE-SEARCH is optimal if h(n) isadmissible. It requires that h(n) never overestimates the
cost to reach the goal. Consequently, f(n) never overestimates the true
cost of a solution through n.
In our route-finding example, the straight-line distance is an admissible heuristic.
16Artificial Intelligence, Spring, 2009
A* Search
Proof of optimalityG2 is a suboptimal goal node appearing on the
fringe. n is a fringe node on an optimal path.C* is the cost of the optimal solution.
f(G2) = g(G2) + h(G2) = g(G2) > C*f(n) = g(n) + h(n) C* < f(G2)
G2 will not be expanded and A*must return an optimal solution.
9
17Artificial Intelligence, Spring, 2009
A* Search
What if we use GRAPH-SEARCH?There are two ways to keep the optimality.
(1) Extend GRAPH-SEARCH so that it discardsthe more expensive of any two paths found tothe same node. The extra bookkeeping is messy.
(2) Ensure that the optimal path to anyrepeated state is always the FIRST onefollowed. An extra requirement of h(n) –consistency
(monotonicity)
18Artificial Intelligence, Spring, 2009
A* Search
A* using GRAPH-SEARCH is optimal if h(n)is consistent. n: node n: successor generated from n by action a c(n, a, n): cost from n to n
h(n) c(n, a, n) + h(n)
10
19Artificial Intelligence, Spring, 2009
A* Search
Every consistent heuristic function is alsoadmissible.
It is quite hard to find heuristics that areadmissible but not consistent.
The straight-line distance heuristic isconsistent.
h(n) c(n, a, n) + h(n)
n
goal
n
h(n)
h(n)
c(n, a, n)
20Artificial Intelligence, Spring, 2009
A* Search
If h(n) is consistent, then the values of f(n) alongany path are nondecreasing.
f(n) = g(n) + h(n)= g(n) + c(n,a,n) + h(n)g(n) + h(n) = f(n)
It follows that A* using GRAPH-SEARCH expandsthe nodes in nondecreasing order of f(n). Hence,the first goal being expanded must be an optimalsolution.
11
21Artificial Intelligence, Spring, 2009
A* Search
The fact that f-cost are nondecreasing along anypath means that we can draw contours in the statespace.
Artificial Intelligence: A Modern Approach, 2nd ed., Figure 4.4
All nodes inside thecontour labeled 420 havef(n) be at most 420.
380
400
420
22Artificial Intelligence, Spring, 2009
A* Search
With uniform-cost search (A* using h(n) =0), the bands will be “circular”around thestart state.
With more accurate heuristics, the bandbecome more narrowly focused around theoptimal path.
A* expands all nodes with f(n) < C*. It might expand some of the nodes right on the
contour with f(n) = C* before selecting a goalnode.
12
23Artificial Intelligence, Spring, 2009
A* Search
Intuitively, the first solution found mustbe an optimal one.Nodes in all subsequent contours will have
higher f-cost and thus higher g-cost (h=0).
It is also intuitive that A* search iscomplete. It requires that there is only finitely many
nodes with cost no greater than C*. step cost exceeding some finite finite b
24Artificial Intelligence, Spring, 2009
A* Search
A* is optimally efficient for any heuristicfunction.No optimal algorithm can guarantee to expand
fewer nodes than A*.This is because any algorithm that does not
expand all nodes with f(n) < C* runs the risk ofmissing the optimal solution.
A* is complete, optimal, and optimallyefficient. What else can you ask for?
13
25Artificial Intelligence, Spring, 2009
A* Search
Complexity For most problems, the number of nodes within
the goal contour is still exponential in thelength of the solution,
unless …
))((log)()( ** nhOnhnh h*(n) is the true costfrom n to the goal.
26Artificial Intelligence, Spring, 2009
A* Search
Space requirement is more serious thanthe time requirement.
It’s impractical to insist on the optimality.One can use heuristic functions that are more
accurate but not admissible.
Next, we will discuss algorithms thatovercome the space problem withoutsacrificing the optimality.
14
27Artificial Intelligence, Spring, 2009
Demonstration
BFS: http://www.youtube.com/watch?v=NpeEWq09mMw
DFS: http://www.youtube.com/watch?v=Xjppe7LfvnQ
A* Algorithm with Python-Pygame:http://www.youtube.com/watch?v=FNRfSQDF7TA
A-Star Pathfind Test:http://www.youtube.com/watch?v=vxX5A3-I88I
A* Personality-guided Pathfinding :http://www.youtube.com/watch?v=GA5vhBkH29I