The document discusses uninformed search techniques. It provides examples of representing problems as states and operators that transform states. This includes problems like the water jug problem, 8-puzzle, and 8-queens. It then describes common uninformed search algorithms like breadth-first search, depth-first search, iterative deepening, and uniform cost search. It analyzes the properties of these algorithms like completeness, time complexity, space complexity, and optimality.
Everyday â searchexamples Searching for the shortest route to RP? Searching for your keys? Searching for classes to take? Searching for where the party is? Searching for the best way to pack your car/truck when you move?
2.
Industry â searchexamples Searching for ways to break a code? Searching for ways to configure wireless antennae? Searching for ways to set up the pipeline to transport oil/gas/water? Searching for ways to schedule your workers? Searching for ways to configure the shop floor?
3.
Todayâs lecture Uninformedsearch Why is it called âuninformedâ? What are the search techniques? How does the algorithm work? How do you code these in lisp?
Problem solving bysearch Represent the problem as STATES and OPERATORS that transform one state into another state. A solution to the problem is an OPERATOR SEQUENCE that transforms the INITIAL STATE into a GOAL STATE . Finding the sequence requires SEARCHING the STATE SPACE by GENERATING the paths connecting the two.
6.
Example: Measuring problemâwater jug problem! Problem: Using these three buckets, measure 7 liters of water. 3 l 5 l 9 l
Example: Measuring problem!Another Solution: A B C 0 0 0 start 0 5 0 3 2 0 3 0 2 3 5 2 3 0 7 goal A B C 3 l 5 l 9 l
9.
Which solution dowe prefer? Solution 1: A B C 0 0 0 start 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 goal Solution 2: A B C 0 0 0 start 0 5 0 3 2 0 3 0 2 3 5 2 3 0 7 goal
10.
OkâŚLetâs review Whatwas the initial state? What was the goal state? What was the set of operations that took us from the initial state to the goal state? What is the path that, if followed, would get us from the initial state to the goal state? What would be the STATE SPACE?
11.
Basic concepts (1)State : finite representation of the world that you want to explore at a given time. Operator : a function that transforms a state into another ( also called rule, transition, successor function, production, action). Initial state : The problem at the beginning. Goal state : desired end state (can be several) Goal test : test to determine if the goal has been reached. Solution Path : The sequence of actions that get you from the initial state to the goal state.
12.
Basic concepts (2)Reachable goal : a state for which there exists a sequence of operators to reach it. State space : set of all reachable states from initial state (possibly infinite). Cost function : a function that assigns a cost to each operation. Performance (not for ALL uninformed): cost of the final operator sequence cost of finding the sequence
13.
Problem formulation Thefirst task is to formulate the problem in terms of states and operators Some problems can be naturally defined this way, others not! Formulation makes a big difference! Examples: water jug problem, tic-tac-toe, 8-puzzle, 8-queen problem, cryptoarithmetic robot world, travelling salesman, parts assembly
14.
Example 1: waterjug (1) 9 5 Given 3 jugs (9, 5 and 3 liters), a water pump, and a sink, how do you get exactly 7 liters into the 9 liter jug? State : (x y z) for liters in jugs 1, 2 , and 3 integers 0 to 9 assigned to all possible permutations of 1 2 3 Operations : empty jug, fill jug, EX. (fill (0 5 0)) Initial state : (0 0 0) Goal state : (x x 7) Solution seqence (5 0 0 (0 5 0 (0 0 0 etcâŚ.) Jug 2 Jug 3 Sink Pump 3 Jug 1
15.
Example 2: cryptoarithmeticF O R T Y + T E N + T E N S I X T Y Assign numbers to letters so that the sum is correct 2 9 7 8 6 + 8 5 0 + 8 5 0 3 1 4 8 6 State space: All letters and all numbers assigned to the letters Operations : replace all occurrences of a letter with a digit not already there Initial State : Letters that make words, integers Goal State: only digits, sum is correct Solution : F= 2, etc. see above Solution F=2, O=9 R=7, T=8 Y=6, E=5 N=0, I=1 X=4
16.
Example 4: 8-queensState : any arrangement of up to 8 queens on the board Operation: add a queen (incremental), move a queen (fix-it) Initial state: no queens on board Goal state: 8 queens, with no queen is attacked Solution Path: The set of operations that allowed you to get to the The board that you see above at the indicated positions.
Example: 8-puzzle Operators:moving blank left, right, up, down (ignore jamming) Goal test: goal state State: integer location of tiles (ignore intermediate locations) Solution: move 4 tile to blank, move 1 tile blank, etc. start state goal state
19.
A different Problemhttp://www.cs.wisc.edu/~jgast/cs540/sample/8puzzle.html Initial State State: Operators: Goal test:
20.
How do werepresent the problem in Lisp? Data structures? State: a list of lists, or a series of property lists Node: state, depth level # of predecesors, list of cconnected nodes # of successors, list of cconnected nodes Edge: the cdr of the list or the get of the propertyâŚmay also have a cost associated with it. Operation: taking things off the list (or getting the property of a node, matching function Queue or stack or list of lists to keep states to be expanded
21.
Tree for waterjug problem (0,0,0) (0,3,0) (4,0, 0) (0,0,0) (1,3,0) (4,3,0) (0,0,0) (3,0,0) (0,3,0) (1,0,0) (4,0,0) (4,3,0) ďĄ ď˘ ďĄ ď˘ (4,3,0)
22.
Search algorithms Function General-Search( problem , strategy ) returns a solution , or failure initialize the search tree using the initial state problem loop do if there are no candidates for expansion then return failure choose a leaf node for expansion according to some strategy if the node contains a goal state then return the corresponding solution else expand the node and add resulting nodes to the search tree end Basic idea: offline, systematic exploration of simulated state-space by generating successors of explored states (expanding)
23.
Implementation of searchalgorithms Function General-Search(problem, Queuing-Fn) returns a solution, or failure nodes ď make-queue(make-node(initial-state[problem])) loop do if node is empty then return failure node ď Remove-Front(nodes) if Goal-Test[problem] applied to State(node) succeeds then return node nodes ď Queuing-Fn(nodes, Expand(node, Operators[problem])) end Queuing-Fn( queue , elements ) is a queuing function that inserts a set of elements into the queue and determines the order of node expansion . Varieties of the queuing function produce varieties of the search algorithm.
24.
Evaluation of searchstrategies Search algorithms are commonly evaluated according to the following four criteria: Completeness: does it always find a solution if one exists? Time complexity: how long does it take as a function of number of nodes? Space complexity: how much memory does it require? Optimality: does it guarantee the least-cost solution? Time and space complexity are measured in terms of: b â max branching factor of the search tree d â depth of the least-cost solution m â max depth of the state-space (may be infinity)
25.
Uninformed search strategiesUse only information available in the problem formulation Breadth-first Depth-first Depth-limited Iterative deepening Uniform Cost Bi-Directional
Breath-first search Expandthe tree in successive layers, uniformly looking at all nodes at level n before progressing to level n+1 function Breath-First-Search( problem ) returns solution nodes := Make-Queue(Make-Node(Initial-State( problem )) loop do if nodes is empty then return failure node := Remove-Front (nodes) if Goal-Test[ problem ] applied to State( node ) succeeds then return node new-nodes := Expand (node, O perators [problem])) nodes := Insert-At-End-of-Queue (new-nodes) end
36.
Another Breath-first searchS A D B D A E C E E B B F D F B F C E A C G G C G F 14 19 19 17 17 15 15 13 G 25 11
37.
Properties of breadth-firstsearch Completeness: (Does it always find a solution?) Time complexity: (How long does it take?) Space complexity: (How much memory does it take?) Optimality: (I t always finds the shortest path)
38.
Properties of breadth-firstsearch Completeness: Yes, if b is finite Time complexity: O(b d ) , i.e., exponential in d (Rem: b is no. of branches) Space complexity: O(b d ) , keeps every node in memory Optimality: Yes, if cost = 1 per step; not optimal in general
Depth first searchDive into the search tree as far as you can, backing up only when there is no way to proceed function Depth-First-Search( problem ) returns solution nodes := Make-Queue(Make-Node(Initial-State( problem )) loop do if nodes is empty then return failure node := Remove-Front (nodes) if Goal-Test[ problem ] applied to State( node ) succeeds then return node new-nodes := Expand (node, O perarors [problem])) nodes := Insert-At-Front-of-Queue (new-nodes) end
48.
Depth-first search SA D B D A E C E E B B F D F B F C E A C G G C G F 14 19 19 17 17 15 15 13 G 25 11
49.
Properties of depth-firstsearch Completeness: No, fails in infinite state-space Time complexity: O(b m ) Space complexity: O(bm) Optimality: No â it may never find the path!
Properties of searchstrategies Completeness guarantees to find a solution if a solution exists, or return fail if none exists Time complexity # of operations applied in the search Space complexity # of nodes stored during the search
56.
Where are we?Make very certain that you can by now write simple lisp functions. Examples: take two numbers (i.e. write a function of two arguments) and sum them take a list of two numbers (i.e. write a function of one argument) and sum them take an arbitrary list of numbers and sum them take a list of numbers and return a list of all the numbers which were negative