1 / 66

CSNB234 ARTIFICIAL INTELLIGENCE

CSNB234 ARTIFICIAL INTELLIGENCE. Chapter 5 State Space Search. Instructor: Alicia Tang Y. C. State Space Representation.

dobrien
Télécharger la présentation

CSNB234 ARTIFICIAL INTELLIGENCE

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. CSNB234ARTIFICIAL INTELLIGENCE Chapter 5 State Space Search Instructor: Alicia Tang Y. C.

  2. State Space Representation • A state space can be considered as consisting of a collection of points, each point corresponding to a state of a problem. So there will be as many number of points in the state space as the number of different possible states of the problem. Thus, a state space is the collection of all possible states, a problem can have. States can be represented as nodes of a tree. The searching of a goal node is by traversing the tree’s nodes using some well-established algorithms.

  3. Defining A Search Problem • State Space • is described by • an initial state space • a set of possible actions (operators) • goal state • Path • is any sequence of actions that lead from a state to another state and finally reached (hopefully) the goal node

  4. Defining a Search Problem • Other considerations are: • Path cost: it is only relevant if there exists more than one path leading to the goal state. • & certainly that we want the shortest path • Goal test: it is applicable to single state problem, I.e. only one goal is found in the state space problem

  5. Relationship between Initial states, actions and goal(s) Initial States Actions Goal(s) Control Strategy

  6. Why ‘Search’? • Search is an important (and powerful ) aspect in AI problem solving • Search will • will help to explore alternatives in tree • will find sequence of steps in a planning situation/case • All goal-driven activities (such as one used in B. C. reasoning) occur in a state space, and we call the problem a state space problem

  7. Classical Search Domains • 8-Puzzle • Water Jug • Blocks World • Travelling Salesman • Maze • Chess • Tower of Hanoi • etc.

  8. An Example of Search Preparation 2 4 8 1 8 7 7 3 2 6 Goal State Initial State 1 5 6 3 4 5 Initial State: The location of each of the 8-puzzle in one of the nine squares Path cost: Each step costs 1 point, total path cost will be equal to the number of steps taken Goal test: State matches the goal configuration (given board pattern) Operators: blank moves [1] Left, [2] Right, [3] Up & [4] Down.

  9. S e a r c h A p p r o a c h e s Test Search Process Solution complete Comparisons stop when all checked All possible solutions are checked Blind optimal partial Check only some alternatives Best among alternatives Comparisons Stop when solution is good enough Good enough Heuristics Only promising solutions Generate improved solutions Stop when no improvement is possible Optimisation optimal

  10. Methods of Search (I) • Popular blind search methods are • Depth-first • Breadth-first • Bi-directional • Iterative deepening • Depth-limited • Uniform cost

  11. Methods of Search (II) • Heuristic Search • Hill-climbing • Best-first • Generate & test • Induction • Greedy search • Optimal Searching • A* search

  12. Methods of search at the first glance • Depth-first • explores search tree branch by branch • Breadth-first • examines search tree row by row • Hill-climbing • it is depth first but mostpromising child node is examined first • Best-first • expands the most promisingpartialpath of all those so far discovered • A* • Best-first and Branch and bound algorithm To be calculated Decision required

  13. .… Blind…. • The entire search tree is examined in an orderly manner. • It can be classified as exhaustive or partial. • Two well-known partial methods are • breadth-first • depth-first

  14. DEPTH-FIRST SEARCH(DFS) A ~ begins at the root node and works downward to successively deeper level. This process continues until a solution is found or backtracking is forced by reaching a dead end. Blind ....

  15. DEPTH-FIRST SEARCH Basic steps used Delete FIRSTNODE from start of QUEUE Take children of FIRSTNODE Add to the front of QUEUE Put result in NEWQUEUE

  16. BREADTH-FIRST SEARCH (BFS) A ~ examines all the nodes in a search tree, beginning with the root node. The nodes in each level are examined completely before moving to the next level.

  17. BREADTH-FIRST SEARCH The algorithm Take children of FIRSTNODE Delete FIRSTNODE from start of QUEUE Append list of children to the end of QUEUE Put result in NEWQUEUE

  18. Heuristics Search • Heuristics search is designed to reduce the amount of search for a solution. • It is based on rule-of-thumb principle. • When a problem is presented, such as a goal state is given, this approach tries to reduce the size of the search tree by pruning non promising or inferior nodes. • It can normally speed up the search process in obtaining a good enough solution.

  19. Benefits of Heuristics • It has inherent flexibility • It is better when an optimal/best solution is too costly to generate • even though it can only produce “good enough” answer • Simpler for decision maker to understand (especially the managers) • because they think in the same way as “heuristics” does

  20. A heuristics search in general Problem: Tic-Tac-Toe x x x o o x x o o o o o o o x o x x x x x x x x x x x x x x x

  21. Consider the Tic-Tac-Toe game Blind search is surely not practical… Each nine first moves has eight possible responses, which in turn have seven continuing moves, and so on. A simple analysis tells that the number of states to be considered in an exhaustive search is 9 * 8 * 7 *… or 9! However, symmetry reduction in second level leads to only 12 * 7! (much smaller than above), further reduction in search space will further reduce the number or search required

  22. HILL-CLIMBING SEARCH Main steps used Delete FIRSTNODE from start of QUEUE Take children of FIRSTNODE Order children with most promising first Place them at the front of QUEUE Put result in NEWQUEUE

  23. HILL-CLIMBING SEARCH A complete function:

  24. Hill-Climbing • Hill-climbing combines depth-first search with a method for ordering the alternatives by measuring the probability of success at each decision point. In other word it tries to reach a goal by choosing those nodes which are predicted to be nearest to the goal. Quality measurements turn depth-first search into hill-climbing.

  25. Hill-Climbing It is about fin ding the shortest h(n) • Earlier slide says that it is quite similar to depth-first blind search. • However, paths are not selected arbitrarily, but in relationship to their proximity to the desired goal (i.e. how close to it) • let’s take a look at this tree: • notice that there are numbersattached nodes • those are potential numbers of defects in a product

  26. Apply hill-climbing search to find ‘1’ defect node START A I III II B 13 C D 11 8 4 E F G 5 H 3 7 I J 2 1

  27. Each production process I, II and III can continue for several stages. • If this is done by depth-first, it goes to I then to II and then to III . • In Hill-climbing method, nodes B, C and D are compared, and it starts in branch I (lowest, 8 here). • Since one defect was not found, backtracking is exercised to branch III. (branch III is done before II, why)? • The search goes to D and H; backtracking is then done and D, G, J path leads to the desired solution. Path A--C--F was not visited therefore much time and cost are saved This is exactly the aims of ‘heuristics’!

  28. Hill-climbing • Few more words on hill-climbing method: If we imagine the goal as the top of hill, h(n) as the difference in heights between n and the top, the hill-climbing procedure corresponds to climbing the hill by always going upwards.

  29. Problems with hill-climbing: • Foothill problem. • Go up to the top of a hill and not advancing further. - misses the overall maximum • Plateau problem. • Problem with multidimensional problem space, i.e. no hill to climb (is flat). Gradient equals to zero. - not informative • Ridges. • Where there are steep slopes and the search direction is not towards the way up (but side)

  30. Some solutions to hill-climbing problems are: • Random restart hill-climbing • where random initial states are generated • Simulated annealing • allow for bad moves as well, where the probability of such a move decreases exponentially with its badness

  31. BEST-FIRST SEARCH • Based on some heuristics evaluation function • More flexible than hill-climbing • An evaluation function is used to assign a score to each candidate node • Next move is made by selecting the best value node • It expands the best partial path, for that It could lead to “shortsighted” situation

  32. BEST-FIRST SEARCH Best-first search has been used in such applications as games and web crawlers In a web crawler, each web page is treated as a node, and all the hyperlinks on the page are treated as unvisited successor nodes in the search space. A crawler that uses best-first search generally uses an evaluation function that assigns priority to links based on how closely the contents of their parent page resemble the search query

  33. BEST-FIRST SEARCH Delete FIRSTNODE from start of QUEUE Take children of FIRSTNODE Append children to QUEUE Order result with most promising first Put ordered result in NEWQUEUE

  34. Apply best-first search to find ‘3’ defect in a production [A] [B D C] [E I D C] [I D C] [D C] [H G C] [G C] [J C] [A] [B D C] [D C E I] [H G C E I] [G C E I] [J C E I] A B 13 C D 11 8 E I 14 16 23 F G 5 H 7 Traversing order (i.e. the search path) is A B D H G J J 3 If hill climbing is used, the solution path will be A B E I D H G J (it is longer, less ‘intelligent’)

  35. Optimal Search • Will produce optimal (best) answer • Based on some optimisation function • Mathematical functions are used • for improvements • for “optimisation”

  36. BRANCH AND BOUND ALGORITHM • One way to find optimal paths with less work is to use branch-and-bound. • It always keeps track of all partial paths contending for further consideration. • The shortest one is extended one level, creating as many new partial paths. • Next, these new paths are considered, along with the remaining old ones, again, the shortest is extended. • The process is repeated until the goal is reached along some path.

  37. Branch-and-Bound • Keys to remember: • To turn likely to certain, you have to extend all partial paths until they are as long or longer than the complete path. The reason is that the last step in reaching the goal may be long enough to make the supposed solution longer than one or more partial paths. • It might be that only a tiny step would extend one of the partial paths to the solution node. • To be sure that this is not so, instead of terminating when a path is found, you terminate when the shortest partial path is longer than the shortest complete path

  38. An Example for B-N-B The length of the complete path from S to G, S-D-E-F-G is 15. Similarly, the length of the partial path S-D-A-B also 15 and any additional movement along a branch will make it longer than 15. Accordingly, there is no need to try S-D-A-B any further. Because it will be longer than the complete path already known. Only other paths emerging from S and from S-D-E have to be considered, as they may provide a shorter path. S D A E F B 15 G 15

  39. To conduct a branch-and-bound search: • Form a one-element queue consisting of zero length path (only root node) • Until the first path in the queue terminated at the goal node or the queue is empty, • remove the first path from the queue; create new paths by extending the first path to all the neighbours of the terminal node • reject all paths with loops • add the reaming new paths, if any, to the queue • sort the entire queue by path length with least-cost paths in front • If the goal is found, announce success; otherwise announce failure.

  40. Consider this search tree:

  41. Solution Search path to goal node: [S(0)] [B(1) A(4)] [E(3) A(4) F(4)] [A(4) F(4) I(6) H(7)] [F(4) C(5) I(6) D(6) H(7)] [G(5) C(5) I(6) D(6) J(6) H(7)]  Goal node reached and stopped. Use your tie breaker solution

  42. A* Search • All A* algorithms are admissible • A search algorithm is admissible if it always produces an optimal solution • The A* search is branch-and-bound, with an estimate of remaining cost combined with dynamic programming principle • Theorem of A* algorithm • For each node n, let h*(n) denote the cost of an optimal path from n to a goal node • The algorithm uses a heuristic function h that satisfies h(n) <= h*(n) for all n in the state space, is admissible

  43. A* SEARCH Delete FIRSTNODE from start of QUEUE Append children of FIRSTNODE Order resulting list according to cost-so-far + underestimate of remaining cost Put result in NEWQUEUE

  44. A* SEARCH

  45. To conduct a A* search: • Form a one-element queue consisting of zero length path (only root node) • Until the first path in the queue terminated at the goal node or the queue is empty, • remove the first path from the queue; create new paths by extending the first path to all the neighbours of the terminal node • reject all paths with loops • if two or more paths reach a common node, delete all those paths except the one that reaches the common node with the minimum cost • sort the entire queue by SUM of the path length and a lower-bound estimate of the cost remaining, with least-cost paths in front • If the goal is found, announce success; otherwise announce failure.

  46. Function definition in A* • Consider the evaluation function f(n) = g(n) + h(n) wheren is any state in the search g(n)is the cost from the start state h(n)is the heuristic estimate of the cost going from n state to goal node

  47. Using A* in 8-puzzle problem Figure 1 shows a start state and the first set of moves 2 8 3 START 1 6 4 7 5 2 8 3 2 8 3 2 8 3 First level of The tree search 1 4 1 6 4 1 6 4 7 6 5 7 5 7 5 A2 A3 A1 Which one will the A* takes? & Why? On what basis it is chosen?

  48. What is the GOAL we wanted to achieve? i.e. what is the question? To reach this GOAL state 1 2 3 8 4 7 6 5 Many levels of search and many solutions are possible to reach the goal state

More Related