Problem Solving by Searching Chapter 3 Spring 2005
Problem Solving by Searching Chapter 3 Spring 2005 CSE 471/598, CBS 598 by H. Liu Copyright, 1996 © Dale Carnegie & Associates, Inc.
Problem-Solving Agents This is a kind of goal-based agents that decide what to do by finding sequences of actions that lead to desirable states. Formulating problems Example problems Searching for solutions CSE 471/598, CBS 598 by H. Liu 2
A simple problem-solving agent Goal formulation - limiting the objectives n A goal is a set of world states in which the goal is satisfied. Problem formulation - deciding what actions and states to consider Search - looking for the best sequence of actions CSE 471/598, CBS 598 by H. Liu 3
A simple agent Solutions - the results of search, so they are sequences of actions that lead to the goal Execution - acting upon the world Formulate -> Search -> Execute An algorithm in Fig 3. 1 CSE 471/598, CBS 598 by H. Liu 4
Well-defined problems and solutions A problem is defined by four components n n Initial state is where an agent starts Possible actions, successor function <action, successor> Goal test determines if a state is a goal state Path cost function, step cost A solution is a path from the initial state to a goal state n Path - connecting sets of states CSE 471/598, CBS 598 by H. Liu 5
Problems and Solutions States and actions are the basic elements of a problem A world of states: initial state I, operator O (or successor) State space - the set of all states reachable from I by any sequences of O Example: a simplified Romania road map (Fig 3. 2) CSE 471/598, CBS 598 by H. Liu 6
Formulating Problems Choosing states and actions The real art of problem solving is in what goes into the description of the states and operators and what does not Abstraction - removing detail from a representation n What are irrelevant details for the case of Fig 3. 2? CSE 471/598, CBS 598 by H. Liu 7
Measuring problem-solving performance Performance measures n Completeness n Optimality n Time complexity n Space complexity Reach the goal Search cost Total cost = path cost + search cost CSE 471/598, CBS 598 by H. Liu 8
Example Problems Toy problems: concise and exact, used to illustrate or exercise various problemsolving methods - ideal cases Real-world problems: more difficult and we want solutions, but there might be many different descriptions CSE 471/598, CBS 598 by H. Liu 9
Toy problem (1) Vacuum world (Fig 3. 3) n States: 8 (2*2^2) or n*2^n w What is the first n about? n n Initial states: any Successor function: Left, Right, Suck Goal test: Clean or not Path cost: Each step costs 1 Comparing with the real world case CSE 471/598, CBS 598 by H. Liu 10
Toy problem (2) The 8 -puzzle n n n States: O(9!) Initial state: Start state (Fig 3. 4) Successor function: Left, Right, Up, Down Goal test: Goal state (Fig 3. 4) Path cost: Each step costs 1 CSE 471/598, CBS 598 by H. Liu 11
Toy problem (3) The 8 -queens (Fig 3. 5) n n n States: 64*63*…*57 Initial states: Empty board Successor function: Add a queen to any empty square Goal test: 8 queens on the board, none attacked Path cost: N/A A better formulation with constraint n n One per column in the leftmost n column w/o attacking queens Add a queen to any square in the leftmost empty column w/o attaching queens CSE 471/598, CBS 598 by H. Liu 12
Real-world problems Route finding Touring and traveling salesperson problem VLSI layout Robot navigation Assembly sequencing Protein design Internet searching CSE 471/598, CBS 598 by H. Liu 13
Search Generating action sequences n n Expanding the current state by. . . Generating a new set of states Let’s look at a situation we come to BY … w PHX -> ASU -> BY A state map CSE 471/598, CBS 598 by H. Liu 14
What is search? The essence of search is to consider one choice at a time. Search tree – generated by the initial state and successor, defines the state space (two examples - Figs 3. 6 and 3. 8) n root, nodes, fringe (leaf nodes) A general search algorithm (Fig 3. 9) n n n Initial state, test, expand, … How to expand is determined by a search strategy How to implement the fringe - a queue CSE 471/598, CBS 598 by H. Liu 15
Search Evaluation Evaluating search strategies (Criteria) n n n Completeness – guaranteed to find a solution if there is one Time complexity – big O Space (memory) complexity – big O Optimality – the solution is optimal Branching factor (b), depth of the shallowest goal (d), maximum length of any path (m) Two types of search n n Blind search (uninformed) Heuristic search (informed) CSE 471/598, CBS 598 by H. Liu 16
Uninformed Search Strategies Breadth-first search (a binary tree example) n Expanding the shallowest node n n n Complete? Optimal? How to implement it branching factor - a killing cost (Fig 3. 11) The main concerns n n the memory requirements exponential complexity Uniform-cost search – expands the node with the lowest path cost n n Complete? Optimal? What if cost is non-decreasing When is it identical to BFS? CSE 471/598, CBS 598 by H. Liu 17
Search Strategies (2) Depth-first search n n n A binary tree example (Fig 3. 12) Complete? Optimal? How to implement it The main concerns n n Wrong branch Deep branch The cures n Depth-limited search (Fig 3. 13) w Determining depth limit based on the problem (how many cities in the map of Romania? ) n Iterative deepening search (Fig 3. 15) CSE 471/598, CBS 598 by H. Liu 18
Search Strategies (3) Comparing ID Depth-First with Breadth-First n Which one is faster? Bidirectional search n n The two directions: Start, Goal (Fig 3. 16) What’s the saving? The main concerns n n n How to search backwards Multiple goal states Efficient checking to avoid redundant search in the other tree CSE 471/598, CBS 598 by H. Liu 19
Search Strategies (4) Which one to use and when n We need to know the strategies in terms of the four criteria w Comparing uninformed search strategies (Fig 3. 17) n We need to know the problem to be solved CSE 471/598, CBS 598 by H. Liu 20
Avoiding Repeated States It’s wasting time to expand states that have already been encountered and expanded before. How to avoid n n Systematic search Remembering what have been visited (open list vs. closed list) w Graph-Search (Fig 3. 19) CSE 471/598, CBS 598 by H. Liu 21
Searching with partial information Sensorless problems n Reason about sets of states instead of a single state (Fig 3. 21) Contingency problems n n Environment is partially observable, actions are uncertain [Suck, Right, if [R, Dirty] then Suck] with position and local dirt sensors Exploration problems n n Both the states and actions of E are unknown Can be viewed as an extreme case of contingency problems CSE 471/598, CBS 598 by H. Liu 22
Summary Problem solving is goal-based A problem consists of 4 parts n initial state, operator, goal test, path cost A single general search algorithm can solve any problem, but … Four criteria: completeness, optimality, time complexity, space complexity Various search strategies CSE 471/598, CBS 598 by H. Liu 23
- Slides: 23