1 / 25

SOLVING PROBLEMS BY SEARCHING

SOLVING PROBLEMS BY SEARCHING. Feng Zhiyong Tianjin University Fall 2008. Problem-solving Agents. Formulating Problems. Well-defined problems and solutions. datatype PROBLEM components: INITIAL-STATE, OPERATORS, GOAL-TEST, PATH-COST-FUNCTION Measuring problem-solving performance

kipling
Download Presentation

SOLVING PROBLEMS BY SEARCHING

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. SOLVING PROBLEMS BYSEARCHING Feng Zhiyong Tianjin University Fall 2008

  2. Problem-solving Agents

  3. Formulating Problems

  4. Well-defined problems and solutions • datatype PROBLEM • components: INITIAL-STATE, OPERATORS, GOAL-TEST, PATH-COST-FUNCTION • Measuring problem-solving performance • The effectiveness of a search can be measured in at least three ways. First, does it rind a solutionSEARCH COST at all? Second, is it a good solution (one with a low path cost)? Third, what is the search costTOTAL COST associated with the time and memory required to find a solution? The total cost of the search isthe sum of the path cost and the search cost.5

  5. Choosing states and actions

  6. Example Problems • The 8-puzzIe • States: a state description specifies the location of each of the eight tiles in one of the ninesquares. For efficiency, it is useful to include the location of the blank. • Operators: blank moves left, right, up, or down. • Goal test: state matches the goal configuration shown in Figure 3.4. • Path cost: each step costs 1, so the path cost is just the length of the path.

  7. The 8-queens problem • Goal test: 8 queens on board, none attacked. • Path cost: zero. • States: any arrangement of 0 to 8 queens on board. • Operators: add a queen to any square. • States: arrangements of 0 to 8 queens with none attacked. • Operators: place a queen in the left-most empty column such that it is not attacked by anyother queen. • States: arrangements of 8 queens, one in each column. • Operators: move any attacked queen to another square in the same column.

  8. Cryptarithmetic

  9. The vacuum world

  10. The vacuum world • State sets: subsets of states 1-8 shown in Figure 3.2 (or Figure 3.6). • Operators: move left, move right, suck. • Goal test: all states in state set have no dirt. • Path cost: each action costs 1.

  11. Missionaries and cannibals • States: a state consists of an ordered sequence of three numbers representing the numberof missionaries, cannibals, and boats on the bank of the river from which they started.Thus, the start state is (3,3,1). • Operators: from each state the possible operators are to take either one missionary, onecannibal, two missionaries, two cannibals, or one of each across in the boat. Thus, there are at most five operators, although most states have fewer because it is necessary to avoid jillegal states. Note that if we had chosen to distinguish between individual people then jthere would be 27 operators instead of just 5. • Goal test: reached state (0,0,0). • Path cost: number of crossings.

  12. Real-world problems • Route finding • Touring and travelling salesperson problems • VLSI layout • Robot navigation • Assembly sequencing

  13. Searching for Solutions • Generating action sequences

  14. Data structures for search trees • the state in the state space to which the node corresponds; • the node in the search tree that generated this node (this is called the parent node); • the operator that was applied to generate the node; • the number of nodes on the path from the root to this node (the depth of the node); • the path cost of the path from the initial state to the node.

  15. Data structures for search trees • MAKE-QUEUE(Elements) creates a queue with the given elements. • EMPTY?(Queue) returns true only if there are no more elements in the queue. • REMOVE-FRONT(Queue) removes the element at the front of the queue and returns it. • QUEUlNG-FN(Elements,Queue) inserts a set of elements into the queue. Different varietiesof the queuing function produce different varieties of the search algorithm.

  16. Search Strategies • Four criteria • Completeness: is the strategy guaranteed to find a solution when there is one? • Time complexity: how long does it take to find a solution? • Space complexity: how much memory does it need to perform the search? • Optimality: does the strategy find the highest-quality solution when there are several different solutions?7

  17. Search Strategies • Breadth-first search • The news about breadth-first search has been good. To see why it is not always the strategy of choice, we have to consider the amount of time and memory it takes to complete a search.

  18. Search Strategies • Breadth-first search • The memory requirements area bigger problem for breadth-first search than the execution time. • The time requirements are still a major factor

  19. Search Strategies • Uniform cost search: modifies the breadth-first strategy by always expanding the lowest-cost node on the fringe (as measured by the path cost g(n)), rather than the lowest-depth node. • g(SUCCESSOR(n)) > g(n)

  20. Search Strategies • Depth-first search • has very modest memory requirements.

  21. Search Strategies • Depth-limited search

  22. Search Strategies • Iterative deepening search: time complexity of iterative deepening is still O(bd), and the space complexity is O(bd).

  23. Search Strategies • Bidirectional search: Time and space complexity areO(bdl2)

  24. Comparing search strategies

  25. Avoiding Repeated States • Do not return to the state you just came from. Have the expand function (or the operator set) refuse to generate any successor that is the same state as the node's parent. • Do not create paths with cycles in them. Have the expand function (or the operator set) refuse to generate any successor of a node that is the same as any of the node's ancestors. • Do not generate any state that was ever generated before. This requires every state that is generated to be kept in memory, resulting in a space complexity of O(bd), potentially. It is better to think of this as O(s), where s is the number of states in the entire state space.

More Related