1 / 44

Problem Solving by Searching

Learn the different algorithms used to solve problems by searching and how to assess their performance. Explore problem formulation, blind search, and informed search techniques.

pannell
Download Presentation

Problem Solving 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. Chapter 2 Problem Solving by Searching (1)

  2. Objectives • Learn how to formulate a search problem. • Learn the different algorithms used to solve problems by searching. • Learn how to assess the performance of a search algorithm.

  3. Introduction • Solving a particular problem → Need to define the elements of a problem and its solution. • Define the problem precisely. • Isolate and represent the task knowledge that is necessary to solve the problem. • Choose and apply the best problem solving technique(s) to the particular problem.

  4. Introduction: Problem solving as search Task = Search • Search is required to solve a wide range of problems. • Search is a method that can be used by computers to examine a huge problem space to find a goal. • e.g Searching for a contact lens on a football field • Challenge: How to find the goal as quickly as possible or without using too many resources.

  5. Introduction: Problem solving as search • A problem can be considered to consist of a goal and a set of actions that can be taken to lead to the goal • Task = finding the sequence of actions that lead to the desirable goal. Start End

  6. Introduction: Problem solving as search • Toy problems • Vacuum world • The N-Queen • Rubik's cube • The 8-Puzzle • The 8-puzzle belongs to the family of Sliding-block puzzles. • The 8-puzzle has 9!/2=181,440 reachable states. • The 15-puzzle has around 1.3 trillion states… • Real world Problems • Touring problems • - Route Finding • - Travelling salesperson • - VLSI Layout • - Robot navigation • - Internet searching

  7. Introduction: Problem solving as search • Search can be performed without any additional information about how to reach a solution: Blind Search (Uniformed search) • Search can be performed using heuristics: Informed Search

  8. Uninformed search • To successfully operate, blind search should satisfy some properties: • It must be complete: It must generate every possible solution otherwise it might miss a suitable solution. • It must be able to find the best solution.

  9. Uninformed search • Key questions to be addressed: • What goal do we need to achieve? • How to know when a goal is reached? • What knowledge we need? • What actions do we need to do? • A goal can be described as: • A task to be accomplished • A situation to be reached • A set of properties to be acquired

  10. Uninformed search: Basic concepts • State: configuration, situation, point…… • Problem formulation: Process of deciding what actions and states to consider given a goal. • Solution: Sequence of actions that help achieving the goal: a path from an initial state to the goal state . • Search: Process of looking for a solution. Takes input (problem) and returns solution. • Execution: To carry out the actions recommended by the solution

  11. Uninformed search: Problem formulation • Problem definition: a problem can be formally defined by: • State representation. • Initial state. • Successor function. • Goal test: determines whether a given state is a goal state. • Path cost function: assigns a cost to each path. Should reflect the performance measure used to assess the quality of any solution.

  12. Uninformed search: Problem formulation • Successor function: • Given a particular state x, fsuccessor(x) = {(<action, new state>) } where action is one of the legal actions in state x and new state is the successor state that can be reached from x by applying action. • The successor function allows together with the initial state to define the state space. • STATE SPACE: The set of all states reachable from the initial state. • A path in the state space is a sequence of states connected by a sequence of actions.

  13. Uninformed search: Problem formulation • Example problem: The vacuum world • State representation: The agent is on one of two locations, each of which might or might not contain dirt. Thus, there are 2 x 22 = 8 possible world states. • Initial state: Any state can be designated as the initial state. • Successor function: Generates the legal states that result from applying the following actions: (Left, Right, Suck). • Goal test: Check whether all the squares are clean. • Path cost function: Each step costs 1. So the path cost is the number of steps.

  14. Uninformed search: Problem formulation • Example problem: The vacuum world state space

  15. Uninformed search: Problem formulation • Solution definition: • A potential solution is a path from the initial state to a goal state. • Solution quality is measured by the path cost function. • An optimal solution has the lowest path cost among all solutions.

  16. Arad Zerind Sibiu Timisoara Oradea Fagaras Arad Rimnicu Vilcea Sibiu Bucharest Uninformed search: Problem formulation • Solution path:

  17. Uninformed search: An example • Touring problem: Given a set of n cities, the touring problem consists in visiting cities at least once starting and ending in the same city. • States: Specified by the current city and the set of cities already visited. • Initial state: Any state can be designed as the initial state. • Successor function: Generates the next city to visit according to the current state. • Goal test: Ending city reached and all cities have been visited. • Path cost: Sum of all step costs.

  18. Uninformed search: Searching for solutions • To solve the problem, we need to define a search strategy that allows to explore efficiently the state space. • The possible action sequences starting at the initial state form a search tree. • Each state is represented by a node. • Expansionoperation: A node is expanded if the successor function for the corresponding state generates new states

  19. Uninformed search: Informal description Function Tree-Search(problem, strategy) returns a solution or a failure Initialize the search tree using the initial state of problem Loop do If there are no candidates for expansion then return failure Choose a leaf node for expansion according to strategy If the node contains a goal state then return the corresponding solution Else expand the node and add the resulting node to the search tree End Loop

  20. Uninformed search: Towards a formal description • Node definition: Data structure with 5 components: • State: representation of a physical configuration. • Parent node: The node in the search tree that generated this node. • Action: action applied to the parent node to generate this node. • Path cost: cost of the path from the initial state to the node. • Depth: The number of steps along the path from the initial state. Parent node Node Children

  21. Uninformed search: Repeated states • Problem: Possibility of wasting time by expanding states that have already been encountered and expanded before. • Occurs when actions are reversible. (Example: move left, and move right) • A solvable problem can become unsolvable if the algorithm does not detect them systematically. • For detection purposes, a comparison operation is needed. Solution: keep a list to store every expanded node.

  22. Uninformed search: Performance evaluation • The performance of problem solving algorithms can be evaluated along the following dimensions: • Completeness: is it guaranteed to find a solution when there is one? • Optimality: Does the strategy find the optimal solution? • Time complexity: how long does it take to find a solution? It can be measured by the number of generated nodes. • Space complexity: how much memory is needed to perform the search? It can be measured in terms of the maximum number of nodes stored in memory.

  23. Uninformed search: Performance evaluation Complexity is expressed in terms of 3 quantities: • b: The branching factor: maximum number of successors of any node. • d: The depth of the shallowest goal node. • m: The maximum length of any path in the state space.

  24. Uninformed search: Basic strategies • Breadth First Search (BFS) • Depth First Search (DFS) • Depth Limited Search (DLS) • Uniform Cost Search (UCS) • Iterative Deepening Search (IDS)

  25. Uninformed search: Basic strategies • Strategies that order nodes without using any domain specific information (only problem definition is provided). • Generate successors and simply differentiate between a goal state and a non goal state. • Blind search strategies differ by the order of node expansion.

  26. Uninformed search: Breadth First Search • Main idea: Nodes at depth i are expanded before nodes at depth (i+1). • Implementation: use of a First-In-First-Out queue (FIFO). Nodes visited first are expanded first. • Shallow nodes are expanded before deeper nodes.

  27. Uninformed search: BFS evaluation • Completeness: Yes, if the branching factor b is finite. • Optimality: shallowest goal is not necessarily the optimal one. It is optimal if all actions have the same cost. • Time complexity: At the worst case, BFS expands every node (except goal node) thus taking time as follows: • 1 +b + b2 + b3 +….+ bd + (bd+1 – b)=O(bd+1) • Memory complexity: BFS keeps every node in memory. Space is a big problem.

  28. Uninformed search: Depth First Search • DFS expands the deepest node in the current fringe on the search tree. • As nodes are expanded, they are dropped from the fringe so then the search “backs up” to the next shallowest node that still has unexplored successors. • DFS strategy is implemented using Last-In_First-Out (LIFO) queue or stack. • Another alternative is to implement DFS with a recursive function that calls itself on each of its children in turn.

  29. Uninformed search: Depth First Search

  30. Uninformed search: DFS evaluation • Completeness: Incomplete in case of unbounded depth containing no solution. • Optimality: does not provide always optimal solutions. • Time complexity: At the worst case, DFS generates about O(bm) nodes in the search tree. • Memory complexity: DFS requires less memory than BFS. It needs to store only a single path from the root to a leaf node along with the remaining unexpanded sibling nodes for each node in the path. The required storage is (bm+1) where b is the branching factor and m maximium depth.

  31. Uninformed search: Depth Limited Search • It is simply DFS with a depth bound. • Searching is not permitted beyond the depth bound. • Works well if we know what the depth of the solution is. • Termination is guaranteed. • If the solution is beneath the depth bound, the search cannot find the goal (hence this search algorithm is incomplete). • Otherwise use Iterative deepening search (IDS).

  32. Uninformed search: Iterative Deepening depth First Search

  33. Uninformed search: IDS (cont.) • Key idea: Iterative deepening search (IDS) applies DLS repeatedly with increasing depth. It terminates when a solution is found or no solutions exists. • IDS combines the benefits of BFS and DFS: Like DFS the memory requirements are very modest (O(bd)). Like BFS, it is complete when the branching factor is finite. • In general, iterative deepening is the preferred Uninformed search method when there is a large search space and the depth of the solution is not known.

  34. Uninformed search: Uniform Cost Search • In case of equal step costs, Breadth First search finds the optimal solution. • For any step-cost function, Uniform Cost search expands the node n with the lowest path cost. • UCS takes into account the total cost. • UCS is guided by path costs rather than depths. Nodes are ordered according to their path cost.

  35. Uninformed search: UCS

  36. Uninformed search: UCS

  37. Uninformed search: UCS

  38. Uninformed search: Searching with partial information • Vaccum world example: initial belief state: set of possible states

  39. Uninformed search: Summary • Search: process of constructing sequences of actions that achieve a goal given a problem. • Goal formulation is the first step in solving problems by searching. It facilitates problem formulation. • Formulating a problem requires specifying four components: Initial states, successor function, goal test and path cost function. Environment is represented as a state space. • A solution is a path from the initial state to a goal state. • Search algorithms are judged on the basis of completeness, optimality, time complexity and space complexity. • Several search strategies: BFS, DFS, DLS, IDS,UCS…

  40. Uninformed Search Examples

  41. S C B A D G E 8 3 1 3 15 7 20 5 Example for illustrating uninformed search strategies

  42. Uninformed Search Results

  43. How they perform • Breadth-First Search: • Expanded nodes: S A B C D E G • Solution found: S A G (cost 18) • Depth-First Search: • Expanded nodes: S A D E G • Solution found: S A G (cost 18) • Uniform-Cost Search: • Expanded nodes: S A D B C E G • Solution found: S B G (cost 13) This is the only uninformed search that worries about costs. • Iterative-Deepening Search: • nodes expanded: S S A B C S A D E G • Solution found: S A G (cost 18)

  44. Any question ?

More Related