problem solving by search problem solving by search
play

Problem Solving by Search Problem Solving by Search Course: CS40002 - PowerPoint PPT Presentation

Problem Solving by Search Problem Solving by Search Course: CS40002 Course: CS40002 Instructor: Dr. Pallab Dasgupta Pallab Dasgupta Instructor: Dr. Department of Computer Science & Engineering Department of Computer Science &


  1. Problem Solving by Search Problem Solving by Search Course: CS40002 Course: CS40002 Instructor: Dr. Pallab Dasgupta Pallab Dasgupta Instructor: Dr. Department of Computer Science & Engineering Department of Computer Science & Engineering Indian Institute of Technology Kharagpur Kharagpur Indian Institute of Technology

  2. Search Frameworks Search Frameworks � State space search State space search � � Uninformed / Blind search Uninformed / Blind search � � Informed / Heuristic search Informed / Heuristic search � � Problem reduction search Problem reduction search � � Game tree search Game tree search � � Advances Advances � � Memory bounded search Memory bounded search � � Multi Multi- -objective search objective search � � Learning how to search Learning how to search � CSE, IIT Kharagpur Kharagpur CSE, IIT 2

  3. State space search State space search � Basic Search Problem: Basic Search Problem: � � Given: Given: [S, s, O, G]where where [S, s, O, G] � � S is the (implicitly specified) set of states S is the (implicitly specified) set of states � � s is the start state s is the start state � � O is the set of state transition operators O is the set of state transition operators � � G is the set of goal states G is the set of goal states � � To find a sequence of state transitions To find a sequence of state transitions � leading from s to a goal state leading from s to a goal state CSE, IIT Kharagpur Kharagpur CSE, IIT 3

  4. 8- -puzzle problem puzzle problem 8 � State description (S) State description (S) � � Location of each of the eight tiles (and the Location of each of the eight tiles (and the � blank) blank) � Start state (s) Start state (s) � � The starting configuration (given) The starting configuration (given) � � Operators (O) Operators (O) � � Four operators, for moving the blank left, right, Four operators, for moving the blank left, right, � up or down up or down � Goals (G) Goals (G) � � One or more goal configurations (given) One or more goal configurations (given) � CSE, IIT Kharagpur Kharagpur CSE, IIT 4

  5. 8- -queens problem queens problem 8 Placing 8 queens on a chess board, so Placing 8 queens on a chess board, so that none attacks the other that none attacks the other � Formulation Formulation – – I I � � A state is any arrangement of 0 to 8 A state is any arrangement of 0 to 8 � queens on board queens on board � Operators add a queen to any square Operators add a queen to any square � CSE, IIT Kharagpur Kharagpur CSE, IIT 5

  6. 8- -queens problem queens problem 8 � Formulation Formulation – – II II � � A state is any arrangement of 0 A state is any arrangement of 0- -8 8 � queens with none attacked queens with none attacked � Operators place a queen in the left Operators place a queen in the left- -most most � empty column empty column CSE, IIT Kharagpur Kharagpur CSE, IIT 6

  7. 8- -queens problem queens problem 8 � Formulation Formulation – – III III � � A state is any arrangement of 8 queens, A state is any arrangement of 8 queens, � one in each column one in each column � Operators move an attacked queen to Operators move an attacked queen to � another square in the same column another square in the same column CSE, IIT Kharagpur Kharagpur CSE, IIT 7

  8. Missionaries and cannibals Missionaries and cannibals � Three missionaries and three cannibals Three missionaries and three cannibals � are on one side of a river, along with a are on one side of a river, along with a boat that can hold one or two people. Find boat that can hold one or two people. Find a way to get everyone to the other side, a way to get everyone to the other side, without ever leaving a group of without ever leaving a group of missionaries outnumbered by cannibals missionaries outnumbered by cannibals CSE, IIT Kharagpur Kharagpur CSE, IIT 8

  9. Missionaries and cannibals Missionaries and cannibals � State: State: (#m, #c, 1/0) (#m, #c, 1/0) � � #m: number of missionaries in the first #m: number of missionaries in the first � bank bank � #c: number of cannibals in the first bank #c: number of cannibals in the first bank � � The last bit indicates whether the boat The last bit indicates whether the boat � is in the first bank. is in the first bank. � Start state: Start state: (3, 3, 1) (3, 3, 1) Goal state: Goal state: (0, 0, 0) (0, 0, 0) � � Operators: Operators: � Boat carries (1, 0) or (0, 1) or (1, 1) Boat carries (1, 0) or (0, 1) or (1, 1) or (2, 0) or (0, 2) or (2, 0) or (0, 2) CSE, IIT Kharagpur Kharagpur CSE, IIT 9

  10. Outline of a search algorithm Outline of a search algorithm 1. Initialize: Initialize: Set OPEN = {s} 1. Set OPEN = {s} 2. Fail: Fail: 2. If OPEN = { }, Terminate with failure If OPEN = { }, Terminate with failure 3. Select: Select: Select a state, n, from OPEN 3. Select a state, n, from OPEN 4. Terminate: Terminate: 4. ∈ G, terminate with success If n ∈ G, terminate with success If n 5. Expand: Expand: 5. Generate the successors of n using O Generate the successors of n using O and insert them in OPEN and insert them in OPEN 6. Loop: Loop: Go To Step 2. 6. Go To Step 2. CSE, IIT Kharagpur Kharagpur CSE, IIT 10

  11. Basics of the search algorithm Basics of the search algorithm OPEN is a queue (FIFO) vs vs a stack (LIFO) a stack (LIFO) OPEN is a queue (FIFO) � � Is this algorithm guaranteed to terminate? Is this algorithm guaranteed to terminate? � � Under what circumstances will it terminate? Under what circumstances will it terminate? � � CSE, IIT Kharagpur Kharagpur CSE, IIT 11

  12. Complexity Complexity � b: branching factor b: branching factor d: depth of the goal d: depth of the goal � � Breadth Breadth- -first search: first search: � 2 + b 3 + … + d = O( � Time: Time: 1 + b + b 1 + b + b 2 + b 3 + … + b b d = O(b b d d ) ) � � Space: Space: O(b b d d ) ) O( � � Depth Depth- -first search: first search: � � Time: Time: O(b b m m ), ), O( � where m: depth of state space tree where m: depth of state space tree � Space: Space: O(bm bm) ) O( � CSE, IIT Kharagpur Kharagpur CSE, IIT 12

  13. Tradeoff between space and time Tradeoff between space and time � Iterative deepening Iterative deepening � � Perform DFS repeatedly using Perform DFS repeatedly using � increasing depth bounds increasing depth bounds � Works in O( Works in O(b b d d ) time and O( ) time and O(bd bd) space ) space � � Bi Bi- -directional search directional search � � Possible only if the operators are Possible only if the operators are � reversible reversible � Works in O( Works in O(b b d d/2 /2 ) time and O( ) time and O(b b d d/2 /2 ) space ) space � CSE, IIT Kharagpur Kharagpur CSE, IIT 13

  14. Saving the explicit space Saving the explicit space 1. Initialize: Set OPEN = {s}, CLOSED = { } CLOSED = { } 1. Initialize: Set OPEN = {s}, 2. Fail: If OPEN = { }, 2. Fail: If OPEN = { }, Terminate with failure Terminate with failure 3. 3. Select: Select: Select a state, n, from OPEN and Select a state, n, from OPEN and save n in CLOSED save n in CLOSED ∈ G, terminate with success If n ∈ 4. Terminate: G, terminate with success 4. Terminate: If n 5. Expand: 5. Expand: Generate the successors of n using O. Generate the successors of n using O. For each successor, m, insert m in OPEN For each successor, m, insert m in OPEN ∪ CLOSED] [OPEN ∪ ∉ [OPEN only if m ∉ CLOSED] only if m 6. Loop: Go To Step 2. 6. Loop: Go To Step 2. CSE, IIT Kharagpur Kharagpur CSE, IIT 14

  15. Search and Optimization – Given: Given: [S, s, O, G] – [S, s, O, G] – To find: To find: – – A minimum cost sequence of A minimum cost sequence of – transitions to a goal state transitions to a goal state – A sequence of transitions to the A sequence of transitions to the – minimum cost goal minimum cost goal – A minimum cost sequence of A minimum cost sequence of – transitions to a min cost goal transitions to a min cost goal CSE, IIT Kharagpur Kharagpur CSE, IIT 15

  16. Uniform Cost Search Uniform Cost Search This algorithm assumes that all operators have a This algorithm assumes that all operators have a cost: cost: 1. Initialize: Initialize: Set OPEN = {s}, 1. Set OPEN = {s}, CLOSED = { } Set C(s) = 0 Set C(s) = 0 CLOSED = { } 2. Fail: Fail: If OPEN = { }, Terminate & fail 2. If OPEN = { }, Terminate & fail 3. Select: Select: 3. Select the minimum cost state, n, , n, Select the minimum cost state from OPEN and save n in CLOSED from OPEN and save n in CLOSED 4. Terminate: Terminate: 4. ∈ G, terminate with success If n ∈ G, terminate with success If n CSE, IIT Kharagpur Kharagpur CSE, IIT 16

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend