160 likes | 267 Views
CS621 : Artificial Intelligence. Pushpak Bhattacharyya CSE Dept., IIT Bombay Lecture 4: Search. Graph Search. S. 1. 10. 5. 3. A. B. C. 10. 9. 4. 5. 6. 3. I. H. D. E. 2. 6. 3. 2. 7. J. F. G(oal). 8-puzzle problem. 1. 2. 3. 4. 3. 6. 1. 4. 2. 8. 5. 6.
E N D
CS621 : Artificial Intelligence Pushpak BhattacharyyaCSE Dept., IIT Bombay Lecture 4: Search
Graph Search S 1 10 5 3 A B C 10 9 4 5 6 3 I H D E 2 6 3 2 7 J F G(oal)
8-puzzle problem 1 2 3 4 3 6 1 4 2 8 5 6 5 8 7 7 S0 G Tile movement represented as the movement of the blank space. Operators: L : Blank moves left R : Blank moves right U : Blank moves up D : Blank moves down C(L) = C(R) = C(U) = C(D) = 1
8-puzzle: heuristics Example: 8 puzzle s n g h*(n) = actual no. of moves to transform n to g h1(n) = no. of tiles displaced from their destined position. h2(n) = sum of Manhattan distances of tiles from their destined position. h1(n) ≤ h*(n) and h1(n) ≤ h*(n) h* h2 h1 Comparison
Theorem A version A2* of A* that has a “better” heuristic than another version A1* of A* performs at least “as well as” A1* Meaning of “better” h2(n) > h1(n) for all n Meaning of “as well as” A1* expands at least all the nodes of A2* h*(n) h2*(n) h1*(n) For all nodes n, except the goal node
Proof by induction on the search tree of A2*. A* on termination carves out a tree out of G Induction on the depth k of the search tree of A2*. A1* before termination expands all the nodes of depth k in the search tree of A2*. k=0. True since start node S is expanded by both Suppose A1* terminates without expanding a node n at depth (k+1) of A2* search tree. Since A1* has seen all the parents of n seen by A2* g1(n) <= g2(n) (1)
Since A1* has terminated without expanding n, f1(n) >= f*(S) (2) Any node whose f value is strictly less than f*(S) has to be expanded. Since A2* has expanded n f2(n) <= f*(S) (3) S k+1 G From (1), (2), and (3) h1(n) >= h2(n) which is a contradiction. Therefore, A1* has to expand all nodes that A2* has expanded. Exercise If better means h2(n) > h1(n) for some n and h2(n) = h1(n) for others, then Can you prove the result ?
Monotone Restriction • Very reasonable assumption • That is the estimated cost of reaching the goal node for a particular node is no more than the cost of reaching a child and the estimated cost of reaching the goal from the child • This obviates the need for redirecting parent pointer for a less costly path in the closed list • This means that for any node taken up for expansion, the optimal path is already found n1 C(n1,n2) n2 h(n1) h(n2) g
Beam Search • Run A*, but with a “Beam width K” • That is, for each iteration keep K most promising nodes and throw away other nodes • Incomplete and non-optimal, but fast
Genetic Algorithm Based • Use the operators of mutation and cross over • Mutation: flip a bit randomly to produce a new state • Cross over: produce by crossing portion of two states a new state
Blank 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 GA for 8-puzzle 4 3 6 1 2 8 5 7 Represented as 0100 0011 0110 0010 0001 1000 0111 0000 0101 1 6 2 3 4 7 8 5 9
Mutation and Crossover Mutation: flip any bit randomly A 0100 0011 0110 0010 0001 1000 0111 0000 0101 B 0100 0111 0110 0010 0001 1000 0111 0000 0101 Crossover: cross a set of bit 1000 0111 0000 0101 0001 1000 0111 0000 0101 First 16 bits of A crossed With last 16 bits of B 0100 0111 0110 0010 0001 0100 0011 0110 0010
Care to be exercised • The bit strings are called chromosomes • Mutation and crossover produce bit strings which are state descriptions • But care has to be exercised to see that the produced state is • Legal • Reachable
Lab assignment • Implement A* algorithm for the following problems: • 8 puzzle • Specifications: • Try different heuristics and compare with baseline case, i.e., the breadth first search. • Violate the condition h ≤ h*. See if the optimal path is still found. Observe the speedup. • Now implement for the same problem • Beam Search • Genetic Algorithm