Informed Search & Exploration (II) - ntnu.edu.tw
Transcript of Informed Search & Exploration (II) - ntnu.edu.tw
1
Artificial Intelligence, Spring, 2009
Informed Search &Exploration (II)
Instructor: Tsung-Che [email protected]
Department of Computer Science and Information EngineeringNational Taiwan Normal University
29Artificial Intelligence, Spring, 2009
Recursive Best-first Search
Its structure is similar to that of arecursive DFS.
It keeps track of the f-value of the bestalternative path available from anyancestor of the current node.
If the current node exceeds this limit, therecursion unwinds back to the alternativepath.
2
30Artificial Intelligence, Spring, 2009
Recursive Best-first Search
A first glance
Artificial Intelligence: A Modern Approach, 2nd ed., Figure 4.5
31Artificial Intelligence, Spring, 2009
Recursive Best-first Search
Artificial Intelligence: A Modern Approach,2nd ed., Figure 4.6(a)
447
447
3
32Artificial Intelligence, Spring, 2009
Recursive Best-first Search
Artificial Intelligence: A Modern Approach,2nd ed., Figure 4.6(a)
415
415
447
33Artificial Intelligence, Spring, 2009
Recursive Best-first Search
Artificial Intelligence: A Modern Approach, 2nd ed., Figure 4.6(a)
415
4
34Artificial Intelligence, Spring, 2009
Recursive Best-first Search
Artificial Intelligence: A Modern Approach, 2nd ed., Figure 4.6(b)
447
417
417
35Artificial Intelligence, Spring, 2009
Recursive Best-first Search
Artificial Intelligence: A Modern Approach, 2nd ed., Figure 4.6(b)
417
5
36Artificial Intelligence, Spring, 2009
Recursive Best-first Search
Artificial Intelligence: A Modern Approach, 2nd ed., Figure 4.6(c)
450
447
447
37Artificial Intelligence, Spring, 2009
Recursive Best-first Search
Artificial Intelligence: A Modern Approach, 2nd ed., Figure 4.6(c)
447
447
6
38Artificial Intelligence, Spring, 2009
Recursive Best-first Search
RBFS uses only linear space, but it suffersfrom excessive node re-generation.
39Artificial Intelligence, Spring, 2009
Recursive Best-first Search
RBFS is optimal if h(n) is admissible.Its time complexity depends on
the accuracy of the heuristic function, and how often the best path changes as nodes are
expanded.
The problem is caused by using too littlememory. It cannot check for repeated states other than
those on the current path.They may explore the same state many times.
7
40Artificial Intelligence, Spring, 2009
Simplified Memory-bounded A*
SMA* proceeds just like A*, expanding thebest leaf until the memory is full.
It drops the worst leaf node –the one withthe highest f-value. Like RBFS, it backs up the value of the
forgotten node to its parent.When all leaf nodes have the same f-value, it
expands the newest and deletes the oldest.
41Artificial Intelligence, Spring, 2009
Simplified Memory-bounded A*
It regenerates the subtree only when allother paths have been shown to look worsethan the path it has forgotten.
It is complete if there is any reachablesolution.
It is optimal if any optimal solution isreachable.
8
42Artificial Intelligence, Spring, 2009
Simplified Memory-bounded A*
It might be the best general-purposealgorithm for finding optimal solutions.
On very hard problems, however, SMA* isforced to switch back and forth continually.
“Memory limitations can make a problemintractable from the point of view ofcomputation time.”
43Artificial Intelligence, Spring, 2009
Tea Time (Roomba)
Officialhttp://www.youtube.com/watch?v=HqhIMFQNGCg
Unofficialhttp://www.youtube.com/watch?v=D0DEPpFL9OY
Wiimba http://www.youtube.com/watch?v=NqbcfSqPnLA
Pacmba http://www.youtube.com/watch?v=2wsP_nmk_iw
Surfin’bahttp://www.youtube.com/watch?v=tLbprdjTX0w
9
44Artificial Intelligence, Spring, 2009
Heuristic Functions
Revisit of 8-puzzleThe average solution cost for a random 8-
puzzle problem is about 22 steps.The branching factor is about 3.An exhaustive search to depth 22 would look at
about 322 3.1 1010 states. But by keeping track of repeated states, there
are only 9!/2 = 181,440 distinct states, which ismanageable.
Artificial Intelligence: A ModernApproach, 2nd ed., Figure 4.7
45Artificial Intelligence, Spring, 2009
Heuristic Functions
But for 15-puzzle, there is roughly 1013
distinct states. (Try: http://www.ababasoft.com/kids/15.html)
It means that we need a good heuristicfunction.
Two common heuristic functions: h1: the number of misplaced tiles (8) h2: Manhattan distance (18)
Both are admissible.
Artificial Intelligence: A ModernApproach, 2nd ed., Figure 4.7
[3] [1] [2]
[2] [3]
[2] [2] [3]
18
10
46Artificial Intelligence, Spring, 2009
Heuristic Functions
One way to evaluate a heuristic is theeffective branching factor b*.N: total number of nodes generated by A* d: solution depth
N + 1 = 1 + b* + (b*)2 + (b*)3 + … + (b*)d
e.g. A* finds a solution at depth 5 using 52nodes, then b* is about 1.92.
47Artificial Intelligence, Spring, 2009
Heuristic Functions
The effective branching factor is fairlyconstant for sufficiently hard problems.
A well-designed heuristic would have avalue of b* close to 1.
11
48Artificial Intelligence, Spring, 2009
Heuristic Functions
Performance comparison
Artificial Intelligence: A Modern Approach, 2nd ed., Figure 4.8
Data are averaged over 100 randomly generated instances.
30,000 times
49Artificial Intelligence, Spring, 2009
Heuristic Functions
Is h2 always better than h1? For any node n, h2(n) h1(n). (h2 dominates h1.) Every node with g(n) + h(n) = f(n) < C* will be
surely be expanded.
This is the same as saying that every node withh(n) < C* g(n) will be expanded.
Every node that is surely expanded by A* withh2 will also surely be expanded with h1.
Yes.
12
50Artificial Intelligence, Spring, 2009
Heuristic Functions
“It is always better to use a heuristicfunction with higher values,
provided it does not overestimate and doesnot take too long computation time.”
51Artificial Intelligence, Spring, 2009
Inventing Heuristic Functions
The relation between h1(h2) and 8-puzzleThey are perfectly accurate path lengths for
the relaxed 8-puzzle problem.
h1: the number of misplaced tiles (8)h2: Manhattan distance (18)
Artificial Intelligence: A ModernApproach, 2nd ed., Figure 4.7
13
52Artificial Intelligence, Spring, 2009
Inventing Heuristic Functions
An example of generating relaxed problems
Original:A tile can move from square A to square Bif A is adjacent to B and B is blank.
Relaxed:(1) A tile can move from A to B if A is adjacent to B.(2) A tile can move from A to B if B is blank.(3) A tile can move from A to B.
h2
h1
Notice that the relaxed problem should be easy to solve,or calculation of h(n) will be too time-consuming.
53Artificial Intelligence, Spring, 2009
Inventing Heuristic Functions
The cost of an optimal solution to a relaxedproblem is an admissible heuristic for theoriginal problem.
In addition, it obeys the triangle inequalityand is therefore consistent. (because the derived heuristic is an exact cost
for the relaxed problem)
14
54Artificial Intelligence, Spring, 2009
Inventing Heuristic Functions
How do we select from a set of heuristicsh1, h2, …, hm?
“We need not make a choice!”
Define h(n) = max{h1(n), h2(n), …, hm(n)},then
h is admissible, consistent, and dominates allits component heuristics.
55Artificial Intelligence, Spring, 2009
Inventing Heuristic Functions
Admissible heuristics can also be derivedfrom the solution cost of a subproblem.
Artificial Intelligence: A Modern Approach, 2nd ed., Figure 4.9
The heuristic issubstantially moreaccurate than Manhattandistance in some cases.
15
56Artificial Intelligence, Spring, 2009
Inventing Heuristic Functions
The idea behind pattern databases is tostore these exact solution costs for everypossible subproblem instances.
Then we compute an admissible heuristicduring the search by looking up in thedatabase.
The database itself is constructed bysearching backwards from the goal state. The search cost is amortized over many subproblem
instances.
57Artificial Intelligence, Spring, 2009
Inventing Heuristic Functions
We can construct databases for 1-2-3-4,5-6-7-8, and so on.
These heuristics are then combined bytaking the maximum value.
The number of nodes generated by thisheuristic can be reduced by a factor of1000, comparing with that by theManhattan distance.
16
58Artificial Intelligence, Spring, 2009
Inventing Heuristic Functions
Can we add, rather than taking themaximum of, the heuristics from the 1-2-3-4 and the 5-6-7-8 databases?No, if we add the total number of moves
directly.Yes, if we just count the number of moves of
the relevant tiles.
Using this kind of disjoint patterndatabases, it is possible to solve random15-puzzles in a few milliseconds. (reduction by afactor of 10,000)
59Artificial Intelligence, Spring, 2009
Inventing Heuristic Functions
Disjoint pattern databases do not alwayswork.
It requires that the problem can bedivided up in such a way that each moveaffects only one subproblem.
17
60Artificial Intelligence, Spring, 2009
Inventing Heuristic Functions
Another solution is to learn fromexperience, which means solving lots of 8-puzzles, for instance.
From these instances, learning algorithmslike neural networks can be used.
61Artificial Intelligence, Spring, 2009
A 15-Puzzle Solver
http://www.ic-net.or.jp/home/takaken/e/15pz/index.html