problem solving by searching
play

Problem Solving by Searching Russell and Norvig, chapter 3.1-3.3 - PDF document

Puzzles! Problem Solving by Searching Russell and Norvig, chapter 3.1-3.3 The missionaries and cannibals Formulating the problem problem n A state description that allows us to describe our n Goal: transport the missionaries and state


  1. Puzzles! Problem Solving by Searching Russell and Norvig, chapter 3.1-3.3 The missionaries and cannibals Formulating the problem problem n A state description that allows us to describe our n Goal: transport the missionaries and state and goal: cannibals to the right bank of the river. (M L , C L , B) n Constraints: M L : number of missionaries on left bank q Whenever cannibals outnumber missionaries, C L : number of cannibals on left bank the missionaries get eaten B: location of boat (L,R) q Boat can hold two people and can’t travel empty n Initial state: (3,3,L) Goal: (0,0,R) Problem solving agents Graph formulation of the problem n Problem Formulation n Nodes: all possible states. q States and actions (successor function). n Edges: edge from state u to state v if v is reachable n Goal Formulation from u (by an action of the agent) q Desired state of the world. n Edges for missionaries and cannibals problem? n Search q Determine a sequence of actions that lead to a goal state. n Problem is now to find a path from (3,3,L) to (0,0,R). n Execute n In general, paths will have costs associated with q Perform the actions. them, so the problem will be to find the lowest cost n Assumptions: path from initial state to the goal. q Environment is fully observable and deterministic q Agent knows the effects of its actions 1

  2. Formulating a search problem Back to our problem 33L § State space S (nodes) CMR CCR CR S § Successor function: the states 31R 32R 22R 1 you can move to by an action 2 3 (edge) from the current state State: 33L three missionaries and three cannibals on left § Initial state bank, boat is on left bank § Goal test Actions (operators): is a state x a goal? CCR - transport two cannibals to the right bank § Cost MCL - transport a missionary and a cannibal to the left bank Why no MMR transition from this state? 7 The (partially expanded) search Repeated states tree 33L 33L CMR CCR CR 31R 32R 22R 31R 32R 22R CL CCL CL ML 32L 33L 33L 32L 32L 33L 33L 32L CCR CR MCR MR 30R 31R 22R 21R 30R 31R 22R 21R CCL CR Actions: 32L 31L 32L 31L CCR - transport two cannibals to the right bank MCL - transport a missionary and a The search tree contains duplicate nodes, since the underlying graph in which we are searching is not a tree! cannibal to the left bank The state space graph Aside: Searching the graph 33L function GRAPH-SEARCH( problem ) returns a solution, or failure initialize the frontier using the initial state of problem initialize the explored set to be empty 31R 32R 22R loop do if the frontier is empty then return failure 32L choose a leaf node and remove it from the frontier To address this, need to track if the node contains a goal state then return the corresponding solution previously explored states add the node to the explored set 30R expand the chosen node add the resulting nodes to the frontier only if not in the frontier or explored 31L The difference between BFS and DFS is in how the node is chosen and/or how it is added to the frontier: queue versus 11R stack. 12 2

  3. Searching the state space Searching the state space n Often it is not feasible (or too expensive) to build a complete representation of the state graph n A problem solver must construct a solution by exploring a small portion of the graph Search tree 13 14 Searching the state space Searching the state space Search tree Search tree 15 16 Searching the state space Searching the state space Search tree Search tree 17 18 3

  4. Searching the state space The 8 puzzle n States? n Initial state? n Actions? n Goal test? Search tree n Path cost? 19 The 8 puzzle (n 2 -1)-puzzle 1 2 3 4 .... 8 2 5 6 7 8 3 4 7 9 10 11 12 5 1 6 n States? Integer location of each tile. How many of them are there? n Initial state? Any state 13 14 15 n Actions? (tile, direction) where direction is one of { Left , Right , Up , Down } n Goal test? Check whether goal configuration is reached n Path cost? Number of actions to reach goal n Is the search graph a tree? 22 The 15-puzzle Sam Loyd offered $1,000 of his own money to the first person who would solve the following problem: 1 2 3 4 1 2 3 4 5 6 7 8 5 6 7 8 ? 9 10 11 12 9 10 11 12 13 14 15 13 15 14 But no one ever won the prize !! 23 24 4

  5. Why? Solution to the Search Problem n A solution is a path connecting the initial node to a goal node (any one) G I 25 26 Solution to the Search Problem Path Cost n An edge cost is a positive number measuring n A solution is a path connecting the initial the “cost” of performing the action node to a goal node (any one) corresponding to the edge, e.g.: n The cost of a path is the sum of the edge q 1 in the 8-puzzle example costs along this path n We will assume that for any given problem n An optimal solution is a solution path of the cost c of an edge always satisfies: minimum cost c ≥ ε > 0, where ε is a constant n There might be I q Why? Has to do with the cost of arbitrarily long no solution ! paths G 27 28 Goal State Another example: the 8 queens problem 1 2 3 n It may be explicitly described: 4 5 6 7 8 1 a a n or partially described: a 5 a a a (“a” stands for “any” 8 other than 1, 5, and 8) n or defined by a condition, n Incremental vs. complete state formulation: e.g., the sum of every row, of every column, q Incremental formulation starts with an empty state and and of every diagonal equals 30 involves operators that augment the state description 15 1 2 12 q A complete state formulation starts with all 8 queens on the 4 10 9 7 board and moves them around 8 6 5 11 3 13 14 29 5

  6. 8 queens problem: representation is A better representation key Incremental formulation Another incremental formulation: States? Any arrangement of 0 to 8 queens on the board States? n (between 0 and 8) queens on the board, one in each of the n n n Initial state? No queens left-most columns; no queens attacking each other. n Actions? Add queen in empty square n Initial state? No queens n Goal test? 8 queens on board and none attacked n Actions? Add queen in leftmost empty column such that it does not n Path cost? None attack any of the queens already on the board. n 64 x 63 x … 57 ~ 3 x 10 14 states to investigate Goal test? 8 queens on board n Is the search graph a tree? 2057 possible sequences to investigate 8 queens solved n-queens problem n A solution is a goal node, not a path to this node (typical of design problem) n Number of states in state space: q 8-queens à 2,057 q 100-queens à 10 52 n But techniques exist to solve n-queens problems efficiently for large values of n � Animated gif from 34 https://sites.google.com/a/lclark.edu/drake/courses/ai/search-and-n-queens Path planning Path planning This path is the shortest in the discretized What is the state space ? This path is the shortest one in the discretized space, but not in the original space. 35 6

  7. An alternative formulation An alternative formulation Visibility graph The solution in this space is the same as in the continuous Cost of a step is the length of the step space! Lozano-Pérez, Tomás; Wesley, Michael A. (1979), "An algorithm for planning collision-free paths among polyhedral obstacles", Communications of the ACM 22 (10): 560–570, Assumptions in Basic Search Search and AI n Search methods are ubiquitous in AI systems. n The world is static n An autonomous robot uses search to decide which n The world is discretizable actions to take and which sensing operations to perform, to quickly anticipate collision, to plan trajectories, … n The world is fully observable n Logistics companies use search to allocate resources, n The actions are deterministic plan routes, schedule employees … n Agents or opponents in games use search to navigate, select moves, anticipate other’s actions, and decide on Search remains an important tool even their own actions. if not all these assumptions are satisfied 39 40 Applications n Search plays a key role in many applications, e.g.: q Route finding (google/mapquest, internet, airline) q VLSI Layout q Robot navigation. q Pharmaceutical drug design, protein design q Video games 41 7

Recommend


More recommend