1 / 59

Lecture Notes on AI-NN

Lecture Notes on AI-NN. Chapter 5 Information Processing & Utilization. Categories of Information Processing -- Problem-Solving -- Game-Playing -- Theorem-Proving -- Logic-Deduction. Section 5.1 Problem-Solving §5-1 Introduction Description of a problem:

Download Presentation

Lecture Notes on AI-NN

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture Notes on AI-NN Chapter 5 Information Processing & Utilization

  2. Categories of Information Processing -- Problem-Solving -- Game-Playing -- Theorem-Proving -- Logic-Deduction

  3. Section 5.1 Problem-Solving §5-1 Introduction Description of a problem: Problem defining: the start - goal conditions Rule defining: a set of IF-THEN Strategy-finding: rule-application controlling

  4. Example The Water Jug Problem Initial Base: There are 2 jugs, a 4-kilo jug and a 3-kilo jug. Neither has any measurement marks on it. Rule Base: (1) There is a pump that can be used to fill the jug with water, or (2) You can pour water from jug on the ground or into another jug. Question: How to get exactly 2-kilo of water into the 4-kilo jug ?

  5. Representation and Solution: Kilos in 4-kilo jug kilos in 3-kilo jug 0 0 0 3 3 0 3 3 4 2 0 2 2 0 R1 3 R2 R1 1 R2 2 R2 2 R2

  6. It is clear that the Production System is suitable means of representation for Problem-Solving. Procedure PRODUCTION 1. DATA ← initial database 2. Until DATA satisfies the termination condition, do: i) begin ii) select some rule, R, in the set of rules that can be applied to DATA iii) DATA ← result of applying R to DATA

  7. In most of AI applications, the information available to the control strategy is usually not sufficient to permit selection of the most appropriate rule on every stage. The operation of AI production system can thus be characterized as a SEARCH PROCESS in which rules are tried until some sequence of them is found that produces a database satisfying the termination condition Further, if the database of the problem to be solved is represented by means of graph, the search is called GRAPH-SEARCH.

  8. Procedure GRAPH-SEARCH 1. Create a search graph, G, consisting sole of the start node, S. Put S on OPEN (OPEN: a list of nodes just generated but not examined yet). 2. Create a list, CLOSED, that is initially empty. (CLOSED is a list of nodes examined already) 3. LOOP: if OPEN is empty, exit with failure. 4. Select the first node on OPEN, remove it from OPEN to CLOSED, Call it node n. 5. Examine n: if n is a goal node, exit with success. The solution is obtained by tracing a path along the pointers from n back to S in G.

  9. 6. Expand n (Apply a rule to n), generating the set, M, of its successors that are not ancestors of n. Install these members of M as successors of n. 7. Establish a pointer to n from these members of M that were not already on either OPEN or CLOSED. Add there members of M to OPEN. For each member of M that was already on OPEN or CLOSED, decide whether or not to redirect its pointer to n. For each member of M already on CLOSED, decide for each of its descendants in G whether or not to redirect its pointer. 8. Reorder the list OPEN according to a certain rule. 9. Go LOOP

  10. Redirection S Node on CLOSED 1=n Node on OPEN 6 2 3 Pointers need to be redirected to 5 4

  11. The crucial factor in search process is the ordering regulation that determines the fashion of the selection of nodes for expansion next. The search efficiency is dependent on the utility of problem information in node selection. In accord with the utility of problem information in node selection, search strategy can be divided into: a) Blind Search, and b) Heuristic Search

  12. §5-1-1 Blind Search on Tree 1) Breadth-First Search Node ordering: FIFO Procedure BFS 1. Put start node s on OPEN. Set pointer P=0 2. If OPEN=NIL, failure. 3. Select the first node on OPEN. Put it on CLOSED, Call it node n. 4. If n=g, successful. The solution is obtained by tracing a path along the pointers from g to s in G. 5. Expand n. If it has no successors, go to step 2. Or, generate all its successors, add them successivelyto the end on OPEN, and establish pointers from them to n; go to step 2.

  13. The shortest solution path Example: BFS 1=S 283 164 7 5 2 4 3 283 283 283 164 1 4 164 75 765 75 5 6 9 8 7 283 283 2 3 283 283 64 14 184 14 16 175 765 765 765 754 19 10 11 83 283 83 283 23 23 28 283 283 28 264 6 4 214 714 184 184 143 145 1 6 163 175 175 765 65 765 765 765 76 754 754 20 21 22 23 24 25 26 27 28 29 30 31 32 33 8 3 2 3 283 283 8 3 283 123 234 2 8 283 2 3 283 283 2 8 264 684 64 674 214 714 84 18 143 145 186 156 16 163 175 175 175 1 5 765 6 5 765 765 765 7 6 754 7 4 754 754 34 83 123 264 35 36 37 38 39 40 41 42 43 44 45 8 4 See Nilsson p.71 Fu p.37 175 765 46=g

  14. Comments on BFS: It is guaranteed to find a optimal solution because of its systematic search feature. The major weakness with BFS is its inability to use the information related to the problem and thus a) It requires a large memory to store the great number of the nodes; b) It require a great amount of work to examine the great number of the nodes c) As result, BFS has low efficiency of search.

  15. § 5-1-2 Depth First Search: Node Ordering: LIFO Procedure DFS 1. Put start node s on OPEN. Set d(s)=0, P=0 2. If OPEN=NIL, F. 3. Select the first node on OPEN. Put it on CLOSED. Call it node n. 4. If n=g, S. 5. If d(n)=d , go to step 2. 6. If n is not expandable, go to step 2. 7. Expand node n, generating all its successors. Establish pointers from them to n. Let d(successor)=d(n)+1. Add them to the front on OPEN in any order, then go to step 2. B

  16. The solution path Example: DFS d =5 B 283 1=S 164 7 5 2 See Nilsson p.70 Fu p.42 18 283 283 164 283 1 4 164 75 765 75 3 19 283 283 2 3 283 28 64 14 184 14 175 765 765 765 4 20 24 8 29 83 83 283 23 283 264 214 714 184 8 4 6 4 175 765 65 765 175 5 9 12 15 21 25 30 8 3 2 3 283 283 8 3 283 123 264 684 64 674 214 714 84 175 175 175 1 5 765 6 5 765 31 6 7 10 11 13 14 16 17 22 23 26 27 83 863 23 23 28 283 283 283 83 813 283 283 123 123 264 2 4 684 684 643 645 674 674 214 2 4 7 4 714 8 4 784 175 175 175 175 175 17 15 15 765 765 615 65 765 65

  17. Compared with BFS, DFS has the following features: 1) If d is too small, the goal node may be missed, if too large, the greater amount of storage is needed. 2) DFS may find the goal faster than BFS, while the the solution path may not be the shortest one if there are more than one goal node. 3) DFS can often be carried out using a reasonably small amount of storage. B g g

  18. §5-1-3 Informed (Heuristic) Search on Tree (1) General Remarks -- The weakness in blind search: ignoring the information associated with the problem in selecting node for expansion next. -- Solution: Try to use the heuristic information in node ordering on OPEN -- Heuristic Search. -- The heuristic information is used in terms of Evaluation Function, f(.): f(n): node n Real number mapping nodes to their promising values.

  19. For any node n on a tree, let g*(n) be the actual cost of a minimal cost path from s to n. h*(n) be the cost of minimal cost path from n to g. f*(n) = g*(n) + h*(n) be the cost of an optimal path from s to g constrained to going through n. Let again g be an estimation of g*, h be an estimation of h*, and f(n) = g(n) + h(n) be an estimation of f*(n), which can be used as an evaluation function for ordering nodes on OPEN.

  20. Practically, g(n): the sum of the arc costs encountered while tracing the pointers from n to s. h(n): a function based on heuristic information from the problem, hence is called Heuristic Function. The practical regulation is If h(n) is very high, node n may be ignored; If h(n) is low, node n may be chosen to expand next.

  21. (2) Algorithm A and Algorithm A* on Tree Algorithm A is a special Tree-Search using evaluation function f(n) for ordering nodes on OPEN and always selecting for expansion the node with the lowest value of f(n). The key for Algorithm A is the settings of h and g: When h=0, g=d, it reduces to BFS; h=0, g=0, random search; h=1/d, g=0, DFS; h>h*, the optimal path may be lost; h<h*, some search may be redundant, but optimal path can be found.

  22. Algorithm A with h(n)<h*(n), for all n, is Algorithm A*. Thus BFS is Algorithm A* and A* can always find a minimal length path to a goal. Informed-ness of Algorithm A*: A1*: f1(n) = g1(n) + h1(n) A2*: f2(n) = g2(n) + h2(n) with h1(n) < h*(n), h2(n) < h*(n) A2* is more informed than A1*, iff h*(n) > h2(n) > h1(n) for all non-goal node n.

  23. Example of A*: 8-Puzzle Problem Let f(n) = g(n) + h(n) = d(n) + w(n) d(n): depth of node n on search tree w(n): number of misplaced digits at node n 283 1# 0+4=4 164 7 5 283 283 3# 1+3=4 2# 1 4 4# 283 1+5=6 1+5=6 164 164 765 75 75 283 2 3 283 2+3=5 7# 8# 2+4=6 6# 14 184 14 2+3=5 765 765 765 23 23 3+4=7 283 14# 15# 3+2=5 83 13# 184 184 12# 714 214 765 765 65 765 3+4=7 3+3=6 123 26# 4+1=5 84 8 4 765 13 out of 27 123 27# 123 8 4 784 765 65 5+0=5

  24. Algorithm A* with h(n) = w(n) is more informed than BFS which uses h(n) = 0. h(n) = w(n) is a lower bound on the exact number of steps needed to reach the goal, h*(n), hence it is an Algorithm A*. However, w(n) does not provide good-enough estimate of h*(n). The information of “following order” is not utilized in w(n).

  25. A better estimate of h*(n) is h(n) = P(n) + 3S(n) P(n): the sum of the absolute distances that a digit is from “home”; S(n): a sequence score, taking value 2, for each non-central digit not proper followed 1, if a digit in the center 0, for other digits E.g., for s = and g = , we have 216 123 4 8 8 4 753 765 P(s) = (3x1) + (3x2) + (1x3) + (1x0) = 12 (1,2,5) (3,4,8) (6) (7) S(s) = 8x2 = 16

  26. By using this h(n), we have f(n) = g(n) + P(n) +3S(n) with g(n) = d(n) and the above problem will find the same optimal path but with fewer nodes expanded: 283 164 7 5 283 283 1 4 283 164 164 765 75 75 283 2 3 283 14 184 14 765 765 765 23 23 184 184 765 765 123 8 4 84 765 11 out of 13 123 123 8 4 784 765 65

  27. Since 0 < w(n) < h*(n) < P(n) + 3S(n), the solution path found happens to be of minimal path, although we were not guaranteed of finding an optimal path. Summary: From the example above, we can see that the key in heuristic search is to determine the form of estimation function f(n) by utilizing heuristic information. As is seen, the crucial difference between blind search and heuristic search is the ordering regulation. In Heuristic search, the node with the smallest value of evaluation function will be chosen to be expanded first.

  28. (3) Algorithm A* for Graph Search 1. s OPEN. Set g(s)=0, f(s)=h(s)=whatever, P=0, CLOSED=NIL 2. If OPEN=NIL, F 3. Take first node on OPEN, call it Best-Node (BN), BN CLOSED 4. If BN=g, S 5. If BN not expandable, go to step 2 6. Expand BN, generating successors (SUCs) and do: (1) Set P: SUC BN (2) Compute g(SUC)=g(BN)+g(BN, SUC) (3) If SUC=old node (OLD) on OPEN, add OLD to the list of BN’s successors

  29. If g(SUC)<g(OLD), the OLD’s parent link should be reset to point to BN, record g(SUC) in the place of g(OLD) If g(SUC)>g(OLD), do nothing (4) If SUC= old node (OLD) on CLOSED, add OLD to the list of BN’s successors; do the same thing as in step 6(3), set the parent link and g and f values appropriately; However, if g(SUC)<g(OLD), the improvement must be propagate to OLD’s successors. 7. Go to step 2.

  30. (4) Heuristic Power The total cost of heuristic search consists of two parts: (a) Path cost = (path length) x unit length cost (b) Search cost spent for searching the solution path (a) Costs (b) Informed-ness

  31. (5) Measures of Heuristic Performance (a) Penetrance, P, of A Search P is the extent to which the search has focused to a goal, rather than wandered off: P = L / T where L: the length of the path found to the goal T: the total number of nodes generated during the search (including the goal node but not including the start node) Hence,P can be considered as a measure of search efficiency.

  32. (b) Effective Branching factor, B, of A Search B is defined by the equation: B + B + … + B = T (total number of nodes) Hence T = 2 L L L (B - 1) L (B - 1) B P = = T B - 1 L B(B - 1) Where the assumptions are made: (1) The depth of the search tree = the length of path L (2) T = the number of nodes generated during search (3) B is a constant for all nodes in the tree

  33. Home-Works 1. Propose two h functions for the traveling salesman problem. Is either these h functions a lower bound on h*? Which of them would result in more efficient search ? Apply algorithm A with these h functions to the TSP problem. 2. Use the evaluation function f(n)=d(n)+w(n) with algorithm A to search backward from the goal to the start node in the 8-puzzle problem. 3. Discuss ways in which an h function might be improved during a search.

  34. § 5-2 Game-Playing: AND/OR Graph Search I. Game-Playing and AO Graph Two-Person-Zero-Sum-Perfect Information Games Example: Grundy’s Game Two Players, Max and Min, have a pile of pennies. The first player, Min, divides the original pile into two piles that must be unequal. Each player alternatively thereafter does the same to some single pile when it is his turn to play. The game proceeds until every pile has either just one penny or two. The player who first can not play is the loser.

  35. 7; Min 6,1;Max 5,2;Max 4,3;Max 5,1,1;Min 4,2,1;Min 3,2,2;Min 3,3,1;Min 4,1,1,1;Max 3,2,1,1;Max 2,2,2,1;Max 3,1,1,1,1;Min 2,2,1,1,1;Min AND/OR Graph 2,1,1,1,1,1;Max Wining path for Max

  36. From Max’s point of view, a win must be obtainable from all of Min’s successors and from at least one of Max’s successors. It is an AND/OR graph. In AND/OR graphs, there are hyper-arcs connecting a parent node with a set of its successors. The hyper-arcs are called connectors. Each k-connector is directed from a parent node to a set of k successor nodes.

  37. II. Features of AND/OR Graph Search The choice of the node to expand next must depend not only on the f value of thatnode itself, but also on whether that node is part of thecurrent bestpath from theinitial node. E.g., A A 20 18 9 B C D 17 9 B C D 9 E F G H I J h=5 3 4 5 10 3 4 3 4

  38. Thus, to search an AND/OR graph, it needs to do three things at each step: 1) Traverse the graph, starting at the initial node and following the current best path, and accumulate the set of nodes that are on that path and haven’t been expanded. 2) Pick one of these nodes and expand it. Add to the graph its successors, compute f for each of them. 3)Change the f value of the newly expanded node to reflect the new information provided by successors. Propagate this change backward through the graph. At each node that is visited while going up the graph, decide which of its successor arcs is the most promising and mark it as part of the current best path.

  39. A 6 A 9 12 B C D 6 C B D 3 4 5 4 10 G H E F A 9 5 7 4 4 B C D This may cause the current best path to change. 3 4 10 F E 4 4

  40. Thus, an important feature in AND/OR graph search is that one must search a solution graph each time from the start node to the terminal node and needs to frequently check to see if the start node solvable. The definition of solvable node in AND/OR graph: 1) Terminal node is solvable node; 2) An OR node is solvable iff at least one of its successors is solvable; 3) An AND node is solvable iff all its successors solvable.

  41. III. Procedure AO* (1) Create a search graph, G, consisting solely of the start node, s. Compute h(s). If s is a terminal node, h(s)=0, label s SOLVED. (2) Until s is labeled SOLVED, do: (3) Begin (4) Compute a partial solution graph, G’, in G by tracing down the marked connectors in G from s. (5) Select any non-terminal tip node, n, of G’. (6) Expand n generating all its successors and install these in G as successors of n. For each successor, n , not already occurring in G, computing h(n ). Label SOLVED any of these successors that are terminal nodes. j j

  42. (7) Create a singleton set of nodes, S, consisting just of node n. (8) Until S is empty, do: (9) Begin (10) Remove from S a node m such that m has no descendants in G occurring in S. (11) Revise the cost h(m) for m, as follows: For each connector directed from m to a set of nodes {n , …, n }, compute h (m)=c + h(n ) + …+h(n ). Set h(m) to the minimum over all outgoing connectors of h (m) and mark the connector through which this minimum is achieved, erasing the previous marking if different. li ki i i 1i ki i

  43. If all of the successors through this connector are labeled SOLVED, then label node m SOLVED. (12) If m has been marked SOLVED, or if the revised cost of m is different than its just previous cost, then add to S all these parent of m such that m is one of their successors through a marked connector. (13) End (14) End

  44. IV Search The Game Tree: MinMax Procedure 1. Localized Solution It is usually impossible to decide a best movebased on anentire search of a whole tree due to the nature of combinatorial explosion. Instead, we must merely try to find a good first move based on local search that is segmented by the artificial termination conditions. After search artificially terminated, the estimation of the “best” first move can be made by applying a static evaluation function to the tips of the search tree.

  45. 2. Some Conventions Two person, zero-sum, complete information games: (a) 2 players: Max and Min (b) Try to find a wining strategy for Max. (c) Max moves first, and alternatively thereafter. (d) The top node of a game tree is of depth 0. (e) Nodes at even-numbered depths are called Max nodes in which it is Max’s move next. (f) The artificial termination condition is a certain depth of search given previously. (g) Game positions favorable to Max cause evaluation function to have positive values, while positions favorable to Min cause f to have negative values.

  46. Rules: (a) If Max were to choose among tip nodes, he chooses the node having largest evaluation. Thus, the Max node is assigned a back-up value equal to the maximum of the evaluation of the tip nodes. (b) If Min were to choose among tip nodes, he chooses the node having smallest evaluation. Thus the Min node is assigned a back-up value equal to minimum of the evaluations of the tip nodes. (c) After the parents of all tip nodes have been assigned back-up values, we back up values another level. (d) Continue to back up values, level by level, until all successors of the start node are assigned backed-up values.

  47. Example: Tic-Tac-Toe Game The player who first places his pieces in a straight line in the matrix is the winner. Suppose that Max is marked by while Min by ; Max plays first. A BFS is conducted with some revisions: -- Artificial termination condition: depth bound = 2; --A static evaluation function for position p is defined: N( ) - N( ), if p isn’t a wining position e(p) = 0 , if p is a wining position for Max -0 , if p is a wining position for Min where N( ) is the number of complete lines open for . 0 0

  48. The process is assumed to be shown below: 1 Max Node Best Move -2 -1 Min Node 1 5-4 6-4 6-5 5-5 4-5 6-5 5-5 5-6 5-5 4-6 5-6 6-6

  49. Another Best Move 1 1 Best Move for Max 1 0 0 1 4-2 4-2 3-2 5-2 3-2 3-2 4-2 4-2 5-2 3-2 4-2 4-2 4-3 4-3 3-3 4-3 4-3 3-3 5-3 3-3 4-3

  50. Best Move -o -o -o 1 o o o -o o -o o -o o 2-1 2-1 2-1 2-1 3-1 2-1 3-1 2-2 2-2 3-2 -o o 3-2 2-2 3-2 -o o 2-1 3-1 3-1 A B C D

More Related