Download presentation
Presentation is loading. Please wait.
Published byPiers Williams Modified over 9 years ago
1
1 Artificial Intelligence CS 165A Tuesday, October 9, 2007 Blind search (Ch. 3) 1
2
2 Notes Homework assignment #1 coming soon.... –And overall assignment schedule Midterm schedule too CS is looking to hire a “peer advisor” –Apply to Julia Orr (in CS office) by 4pm Friday
3
3 2007-2008 Peer Advisor Position Available Eligibility Criteria: Computer Science Major (full major status) Junior or Senior status Available to work 8-10 hours/ week for the entire 2007-2008 academic year Some responsibilities of the peer advisor include: Advising students about courses and course loads Assisting students in scheduling Being the Undergraduate Representative on the Computer Science Undergraduate Affairs Committee Completing progress checks for students If you are interested, please submit your resume and application to Julia Orr in Harold Frank Hall 2104 by Friday, October 12th 4pm.
4
4 Review Problem formulation and search –State-space description S: Possible states S 0 : Initial state of the agent S G : Goal state(s) –Or equivalently, a goal test G(S) O: Operators O: {S} => {S} –Describes the possible actions of the agent g: Path cost function, assigns a cost to a path/action Uninformed (blind) search –Is this a goal state or not? –Know current path cost (from start to current node) –No information about the “goodness” of a state
5
5 Example: MU-Puzzle States: Strings comprising the letters M, I, and U Initial state: MI Goal state: MU Operators: (where x stands for any string, including the null string) 1. x I x IU“Append U” 2. M x M x x“Replicate x” 3. x I I I x x U x“Replace with U” 4. x UU x x x“Drop UU” Path cost: one per step Try it –Can you draw the state-space diagram? –Are you guaranteed a solution? M I M I I M I I I I M U I M U I U M U I U U I U M U I U U I U U I U U I U M U I I I I U M U U I U M I U … M I M I I M I I I I M U I M U I U M U I U U I U M U I U U I U U I U U I U M U I I I I U M U U I U M I U …
6
6 Example: The Vacuum World Simplified world: 2 grids States: Location of vacuum, dirt in grids Operators: Move left, move right, suck dirt Goal test: Grids free of dirt Path cost: Each action costs 1
7
7 The Vacuum World (cont.) How to reach the goal? –If starting at top left state: S, R, S –If starting at middle far right state: L, S What if agent doesn’t know its initial state? –You probably need to redraw the state diagram! –Represent initial uncertainty as one “meta-state” For example…
8
8 The Vacuum World (cont.)
9
9 Example: Measuring Problem You have three empty buckets –3 gallon bucket –5 gallon bucket –9 gallon bucket You can fill buckets to the top and you can empty buckets onto the ground or into other buckets Task: Measure out 7 gallons of water in fewest # of steps States, initial state, operators, goal test, path cost? 3 5 9
10
10 Example: Measuring Problem (cont.) (0 0 0) (3 0 0) (0 0 3) (3 0 3) (0 0 6) (3 0 6) (0 3 6) (3 3 6) (1 5 6) (0 5 7) (0 0 0) (0 5 0) (3 2 0) (3 0 2) (3 5 2) (3 0 7) Two solutions: Note: In this problem, a goal test is more efficient than explicit goal states (why?) Is this the best solution?
11
11 Searching for Solutions Finding a solution is done by searching through the state space –While maintaining a set of partial solution sequences The search strategy determines which states should be expanded first –Expand a state = Applying the operators to the current state and thereby generating a new set of successor states Conceptually, the search process builds up a search tree that is superimposed over the state space –Root node of the tree Initial state –Leaves of the tree States to be expanded (or expanded to null) –At each step, the search algorithm chooses a leaf to expand
12
12 State Space vs. Search Tree The state space and the search tree are not the same thing! –A state represents a (possibly physical) configuration –A search tree node is a data structure which includes: { parent, children, depth, path cost } –States do not have parents, children, depths, path costs –Number of states number of nodes
13
13 State Space vs. Search Tree (cont.) State space: 8 states
14
14 State Space vs. Search Tree (cont.) Search tree (partially expanded) BCCBF DHG ADGADE BC A
15
15 Example: Missionaries and Cannibals Problem: Three missionaries and three cannibals are on one side of a river, along with a boat that can hold one or two people. Find a way to get everyone to the other side, without ever leaving a group of missionaries in one place outnumbered by the cannibals in that place States, operators, goal test, path cost? Demo
16
16 M&C (cont.) Initial stateGoal state MMM CCC MMM CCC (3 3 1)(0 0 0)(M L C L B L )
17
17 M&C (cont.) M M M C C C (2 2 0)
18
18 M&C (cont.) Problem description {S} : { ({1,2,3} {1,2,3} {1 0}) } S 0 : (3 3 1) S G : (0 0 0) g = 1 {O} : { (x y b) (x’ y’ b’) } Constraints: –x >= 0, y >= 0 –x’ >= 0, y’ >= 0 –If x > 0 then x >= y –If x’ > 0 then x’ >= y’ –b + b’ = 1 Operators: (x y 1) (x-2 y 0) (x y 1) (x-1 y-1 0) (x y 1) (x y-2 0) (x y 1) (x-1 y 0) (x y 1) (x y-1 0) (x y 0) (x+2 y 1) (x y 0) (x+1 y+1 1) (x y 0) (x y+2 1) (x y 0) (x+1 y 1) (x y 0) (x y+1 1)
19
19 M&C (cont.) One solution path: (3 3 1) (2 2 0) (3 2 1) (3 0 0) (3 1 1) (1 1 0) (2 2 1) (0 2 0) (0 3 1) (0 1 0) (0 2 1) (0 0 0) 11 steps 5 11 = 48 million states to explore 3 3 1 1 3 02 2 03 1 02 3 03 2 0
20
20 Search Criteria Primary criteria to evaluate search strategies –Completeness Is it guaranteed to find a solution (if one exists)? –Optimality Does it find the “best” solution (if there are more than one)? –Time complexity Number of nodes generated/expanded (How long does it take to find a solution?) –Space complexity How much memory does it require? Some performance measures –Best case –Worst case –Average case –Real-world case
21
21 Search Criteria (cont.) Complexity analysis and O( ) notation (see Appendix A) –b = Maximum branching factor of the search tree –d = Depth of an optimal solution (may be more than one) –m = maximum depth of the search tree (may be infinite) Examples –O( b 3 d 2 ) – polynomial time –O( b d ) – exponential time b = 2, d = 2, m = 3For chess, b ave = 35 Search tree
22
22 Uninformed (“Blind”) Search Strategies No information is available other than –The current state Its parent (perhaps complete path from initial state) Its operators (to produce successors) –The goal test –The current path cost (cost from start state to current state) Blind search strategies –Breadth-first search –Uniform cost search –Depth-first search –Depth-limited search –Iterative deepening search –Bidirectional search
23
23 General Search Algorithm (Version 1) Various strategies are merely variations of the following function: function G ENERAL -S EARCH (problem, strategy) returns a solution or 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 nodes to the search tree end function G ENERAL -S EARCH (problem, strategy) returns a solution or 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 nodes to the search tree end (Called “Tree-Search” in the textbook)
24
24 General Search Algorithm (Version 2) function G ENERAL -S EARCH (problem, Q UEUING -F N ) returns a solution or failure nodes M AKE -Q UEUE (M AKE -N ODE (I NITIAL -S TATE [problem])) loop do if nodes is empty then return failure node R EMOVE -F RONT (nodes) if G OAL -T EST [problem] applied to S TATE (node) succeeds then return node nodes Q UEUING -F N (nodes, E XPAND (node, O PERATORS [problem])) end function G ENERAL -S EARCH (problem, Q UEUING -F N ) returns a solution or failure nodes M AKE -Q UEUE (M AKE -N ODE (I NITIAL -S TATE [problem])) loop do if nodes is empty then return failure node R EMOVE -F RONT (nodes) if G OAL -T EST [problem] applied to S TATE (node) succeeds then return node nodes Q UEUING -F N (nodes, E XPAND (node, O PERATORS [problem])) end Uses a queue (a list) and a queuing function to implement a search strategy –Queuing-Fn(queue, elements) inserts a set of elements into the queue and determines the order of node expansion
25
25 Breadth-First Search All nodes at depth d in the search tree are expanded before any nodes at depth d+1 –First consider all paths of length N, then all paths of length N+1, etc. Doesn’t consider path cost – finds the solution with the shortest path Uses FIFO queue function B READTH -F IRST -S EARCH (problem) returns a solution or failure return G ENERAL -S EARCH (problem, E NQUEUE -A T -E ND ) function B READTH -F IRST -S EARCH (problem) returns a solution or failure return G ENERAL -S EARCH (problem, E NQUEUE -A T -E ND )
26
26 Example B A C DE F State space graphSearch tree D Queue (A) (B C) (C D) (D B D E) (B D E) (D E D) (E D) (D F) (F) ( ) D F DEB BC A
27
27 Example: MU-Puzzle State space description Start state: MI Goal state: MU Operators: 1. x I x IU 2. M x M x x 3. xI I Ix xUx 4. xUUx xx Search tree MIUIUIUIU 2 MIIUIIU 2 MIIIIUMIIIIIIIIMUIMIU 1 2 3 3 2 MIIUMIIII 1 MIUIU 2 MIU 1 MII 2 MI
28
28 Example: MU-Puzzle (cont.) MIIIIUMIUIUIUIU Search tree MIUIU MIU MIIUIIU MIIIIMIIU MII MI MIIIIIIIIMUIMIU Queue (MI) (MIU MII) (MII MIUIU) (MIUIU MIIU MIIII) (MIIU MIII MIUIUIUIU) (MIII MIUIUIUIU MIIUIIU) (MIIIIU MIIIIIIII MUI MIU MIUIUIUIU MIIUIIU)
29
29 Breadth-First Search Complete? Optimal? Time complexity? Space complexity? Yes Exponential: O( b d ) In practice, the memory requirements are typically worse than the time requirements
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.