Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Science CPSC 322 Lecture 4 Search: Intro (textbook Ch: 3.0-3.4) 1.

Similar presentations


Presentation on theme: "Computer Science CPSC 322 Lecture 4 Search: Intro (textbook Ch: 3.0-3.4) 1."— Presentation transcript:

1 Computer Science CPSC 322 Lecture 4 Search: Intro (textbook Ch: 3.0-3.4) 1

2 Announcements (1) Reminder on Slide Posting I post a version of the lecture slides by 2:30pm after class (by the end of the day usually) I’ll post the version with material filled-in in class. So you’ll always have to double check the posted slides after class if you want to have the most up-to-date copy (2) Office hours are posted on the class syllabus 2

3 Course Overview Environment Problem Type Query Planning Deterministic Stochastic Constraint Satisfaction Search Arc Consistency Search Logics STRIPS Vars + Constraints Value Iteration Variable Elimination Belief Nets Decision Nets Markov Processes Static Sequential Representation Reasoning Technique Variable Elimination First Part of the Course 3

4 Course Overview Environment Problem Type Query Planning Deterministic Stochastic Constraint Satisfaction Search Arc Consistency Search Logics STRIPS Vars + Constraints Value Iteration Variable Elimination Belief Nets Decision Nets Markov Processes Static Sequential Representation Reasoning Technique Variable Elimination We’ll focus on Search 4

5 (Adversarial) Search: Checkers Source: IBM Research Early learning work in 1950s by Arthur Samuel at IBM Chinook program by Jonathan Schaeffer (UofA) Search explores the space of possible moves and their consequence 1994: world champion 2007: declared unbeatable 5

6 Slide 6 (Adversarial) Search: Chess In 1997, Gary Kasparov, the chess grandmaster and reigning world champion played against Deep Blue, a program written by researchers at IBM Source: IBM Research

7 Slide 7 (Adversarial) Search: Chess Deep Blue’s won 3 games, lost 2, tied 1 30 CPUs + 480 chess processors Searched 126.000.000 nodes per sec Generated 30 billion positions per move reaching depth 14 routinely

8 Today’s Lecture Simple Search Agent Examples General Search Procedure (time permitting) 8

9 Often we are not given an algorithm to solve a problem, but only a specification of what a solution is we have to search for a solution. –Enumerate a set of potential partial solutions –Check to see if they are solutions or could lead to one Search 9

10 Simple Search Agent Deterministic, goal-driven agent Agent is in a start state Agent is given a goal (subset of possible states) Environment changes only when the agent acts Agent perfectly knows: actions that can be applied in any given state the state it is going to end up in when an action is applied in a given state The sequence of actions (and appropriate ordering) taking the agent from the start state to a goal state is the solution 10

11 Definition of a search problem Initial state(s) Set of actions (operators) available to the agent An action function that, given a state and an action, returns a new state Goal state(s) Search space: set of states that will be searched for a path from initial state to goal, given the available actions states are nodes and actions are links between them. Not necessarily given explicitly (state space might be infinite) Path Cost (we ignore this for now) 11

12 Today’s Lecture Simple Search Agent Examples General Search Procedure (time permitting) 12

13 Slide 13 Three examples 1.The delivery robot planning the route it will take in a bldg. to get from one room to another (Ch 1.6) 2.Vacuum cleaner world 3.Solving an 8-puzzle

14 Environment for Delivery Robot (ch.1.6) Simplified Consider only bold locations here Limits in direction of movement (e.g., can only move in the direction a door opens, can’t go back to previous location, etc.) Start: o103 Goal: r123 14

15 Search Space for the Delivery Robot 15

16 Slide 16 Example: vacuum world Possible start state Possible goal state States Two rooms: r1, r2 Each room can be either dirty or not Vacuuming agent can be in either in r1 or r2

17 Slide 17 Example: vacuum world States Two rooms: r1, r2 Each room can be either dirty or not Vacuuming agent can be in either in r1 or r2 Feature-based representation: -Features? -how many states? Possible start state Possible goal state

18 Suppose we have the same problem with k rooms. The number of states is…. D. 2 * k k A. k 3 C. k * 2 k B. k * 2k ….. 18

19 Cleaning Robot States – one of the eight states in the picture Actions –left, right, suck Possible Goal – no dirt 19

20 Search Space 20 Actions – left, right, suck - Successor states in the graph describe the effect of each action applied to a given state Possible Goal – no dirt

21 Search Space 21 Actions – left, right, suck - Successor states in the graph describe the effect of each action applied to a given state Possible Goal – no dirt

22 Search Space 22 Actions– left, right, suck - Successor states in the graph describe the effect of each action applied to a given state Possible Goal – no dirt

23 Search Space 23 Actions – left, right, suck - Successor states in the graph describe the effect of each action applied to a given state Possible Goal – no dirt

24 Search Space 24 Actions – left, right, suck - Successor states in the graph describe the effect of each action applied to a given state Possible Goal – no dirt

25 Eight Puzzle 25

26 Eight Puzzle States: Actions: Goal: 26

27 Eight Puzzle States: each state specifies which number/blank occupies each of the 9 tiles HOW MANY STATES ? Actions: blank moves left, right, up down Goal: configuration with numbers in right sequence 9! 27

28 Slide 28 Search space for 8puzzle

29 Slide 29 Search space for 8puzzle

30 Slide 30 How can we find a solution? How can we find a sequence of actions and their appropriate ordering that lead to the goal? Need smart ways to search the space graph

31 Today’s Lecture Simple Search Agent Examples General Search Procedure (time permitting) 31

32 Slide 32 Search: Abstract Definition How to search Start at the start state Evaluate the effect of taking different actions starting from states that have been encountered in the search so far Stop when a goal state is encountered To make this more formal, we'll use the formal definition of a graph that you reviewed for today

33 A directed graph consists of a set N of nodes (vertices) and a set A of ordered pairs of nodes, called edges (arcs). Node n 2 is a neighbor of n 1 if there is an arc from n 1 to n 2. That is, if  n 1, n 2   A. A path is a sequence of nodes n 0, n 1,..,n k such that  n i-1, n i   A. A cycle is a non-empty path such that the start node is the same as the end node. A directed acyclic graph (DAG) is a graph with no cycles Given a set of start nodes and goal nodes, a solution is a path from a start node to a goal node Graphs 33

34 Graph specification for the Delivery Robot N={mail, ts, o103, b3, o109,...} A={ 〈 ts,mail 〉, 〈 o103,ts 〉, 〈 o103,b3 〉, 〈 o103,o109 〉,...} One of several solution paths: 〈 o103, o109, o119, o123, r123 〉 34

35 Generic search algorithm:  given a graph, start nodes, and goal nodes, incrementally explore paths from the start nodes.  Maintain a frontier of paths from the start node that have been explored.  As search proceeds, the frontier expands into the unexplored nodes until a goal node is encountered. The way in which the frontier is expanded defines the search strategy. Graph Searching 35

36 Problem Solving by Graph Searching 36

37 Input: - a graph - a set of start nodes - Boolean procedure goal(n) testing if n is a goal node frontier:= [ : s is a start node]; While frontier is not empty: select and remove path from frontier; If goal(n k ) return ; For every neighbor n of n k, add to frontier; end Generic Search Algorithm 37

38 The forward branching factor of a node is the number of arcs going out of the node The backward branching factor of a node is the number of arcs going into the node If the forward branching factor of a node is b and the graph is a tree, how many nodes are n steps away from that node? Branching Factor ( you reviewed this for today ) 38 C. n b A. nb B. b n D. n/b

39 The forward branching factor of a node is the number of arcs going out of the node The backward branching factor of a node is the number of arcs going into the node If the forward branching factor of a node is b and the graph is a tree, how many nodes are n steps away from that node? Branching Factor ( you reviewed this for today ) 39 B. b n

40 Slide 40 Comparing Searching Algorithms: Will it find a solution? the best one? Def. : A search algorithm is complete if whenever there is at least one solution, the algorithm is guaranteed to find it within a finite amount of time. Def.: A search algorithm is optimal if when it finds a solution, it is the best one

41 Slide 41 Comparing Searching Algorithms: Complexity Def.: The time complexity of a search algorithm is the worst- case amount of time it will take to run, expressed in terms of maximum path length m maximum branching factor b. Def.: The space complexity of a search algorithm is the worst-case amount of memory that the algorithm will use (i.e., the maximum number of nodes on the frontier), also expressed in terms of m and b. Branching factor b of a node is the number of arcs going out of the node

42 Slide 42 Search is a key computational mechanism in many AI agents We will study the basic principles of search on the simple deterministic search agent model Generic search approach: define a search space graph start from initial state state, incrementally explore paths from current state until goal state is reached. The way in which the frontier is expanded defines the search strategy. To Summarize

43 Learning Goals for today’s class Identify real world examples that make use of deterministic, goal-driven search agents Assess the size of the search space of a given search problem. Implement the generic solution to a search problem. Define completeness, optimality, time complexity and space complexity for search algorithms

44 TODO for Wednesday 44 Uninformed search strategies (read textbook Sec. 3.5) First Practice Exercise 3.A http://www.aispace.org/exercises.shtml


Download ppt "Computer Science CPSC 322 Lecture 4 Search: Intro (textbook Ch: 3.0-3.4) 1."

Similar presentations


Ads by Google