CS 416 Artificial Intelligence Lecture 3 Uninformed Searches Lecture 3 Uninformed Searches.

Slides:



Advertisements
Similar presentations
Solving problems by searching Chapter 3. Outline Problem-solving agents Problem types Problem formulation Example problems Basic search algorithms.
Advertisements

Additional Topics ARTIFICIAL INTELLIGENCE
Announcements Course TA: Danny Kumar
Artificial Intelligence Solving problems by searching
CS 416 Artificial Intelligence Lecture 3 Uninformed Searches (mostly copied from Berkeley) Lecture 3 Uninformed Searches (mostly copied from Berkeley)
Artificial Intelligence Problem Solving Eriq Muhammad Adams
CS 480 Lec 3 Sept 11, 09 Goals: Chapter 3 (uninformed search) project # 1 and # 2 Chapter 4 (heuristic search)
Blind Search1 Solving problems by searching Chapter 3.
Search Strategies Reading: Russell’s Chapter 3 1.
May 12, 2013Problem Solving - Search Symbolic AI: Problem Solving E. Trentin, DIISM.
1 Chapter 3 Solving Problems by Searching. 2 Outline Problem-solving agentsProblem-solving agents Problem typesProblem types Problem formulationProblem.
Solving Problem by Searching Chapter 3. Outline Problem-solving agents Problem formulation Example problems Basic search algorithms – blind search Heuristic.
PSU CS 370 – Artificial Intelligence Dr. Mohamed Tounsi Artificial Intelligence 3. Solving Problems By Searching.
Search Search plays a key role in many parts of AI. These algorithms provide the conceptual backbone of almost every approach to the systematic exploration.
Solving problems by searching Chapter 3. Outline Problem-solving agents Problem types Problem formulation Example problems Basic search algorithms.
Touring problems Start from Arad, visit each city at least once. What is the state-space formulation? Start from Arad, visit each city exactly once. What.
Artificial Intelligence for Games Uninformed search Patrick Olivier
14 Jan 2004CS Blind Search1 Solving problems by searching Chapter 3.
EIE426-AICV 1 Blind and Informed Search Methods Filename: eie426-search-methods-0809.ppt.
Search Strategies CPS4801. Uninformed Search Strategies Uninformed search strategies use only the information available in the problem definition Breadth-first.
UNINFORMED SEARCH Problem - solving agents Example : Romania  On holiday in Romania ; currently in Arad.  Flight leaves tomorrow from Bucharest.
14 Jan 2004CS Blind Search1 Solving problems by searching Chapter 3.
1 Solving problems by searching Chapter 3. 2 Why Search? To achieve goals or to maximize our utility we need to predict what the result of our actions.
CHAPTER 3 CMPT Blind Search 1 Search and Sequential Action.
AI I: problem-solving and search. 2 Outline Problem-solving agents –A kind of goal-based agent Problem types –Single state (fully observable) –Search.
An Introduction to Artificial Intelligence Lecture 3: Solving Problems by Sorting Ramin Halavati In which we look at how an agent.
CS 380: Artificial Intelligence Lecture #3 William Regli.
Review: Search problem formulation
1 Solving problems by searching Chapter 3. 2 Why Search? To achieve goals or to maximize our utility we need to predict what the result of our actions.
Artificial Intelligence Chapter 3: Solving Problems by Searching
Solving problems by searching
1 Solving problems by searching Chapter 3. 2 Why Search? To achieve goals or to maximize our utility we need to predict what the result of our actions.
Solving problems by searching This Lecture Read Chapters 3.1 to 3.4 Next Lecture Read Chapter 3.5 to 3.7 (Please read lecture topic material before and.
Review: Search problem formulation Initial state Actions Transition model Goal state (or goal test) Path cost What is the optimal solution? What is the.
Solving Problems by Searching CPS Outline Problem-solving agents Example problems Basic search algorithms.
1 Solving problems by searching This Lecture Chapters 3.1 to 3.4 Next Lecture Chapter 3.5 to 3.7 (Please read lecture topic material before and after each.
Search Tamara Berg CS 560 Artificial Intelligence Many slides throughout the course adapted from Dan Klein, Stuart Russell, Andrew Moore, Svetlana Lazebnik,
Artificial Intelligence
AI in game (II) 권태경 Fall, outline Problem-solving agent Search.
Carla P. Gomes CS4700 CS 4700: Foundations of Artificial Intelligence Prof. Carla P. Gomes Module: Search I (Reading R&N: Chapter.
1 Solving problems by searching 171, Class 2 Chapter 3.
An Introduction to Artificial Intelligence Lecture 3: Solving Problems by Sorting Ramin Halavati In which we look at how an agent.
SOLVING PROBLEMS BY SEARCHING Chapter 3 August 2008 Blind Search 1.
A General Introduction to Artificial Intelligence.
1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;
Goal-based Problem Solving Goal formation Based upon the current situation and performance measures. Result is moving into a desirable state (goal state).
Solving problems by searching 1. Outline Problem formulation Example problems Basic search algorithms 2.
CPSC 420 – Artificial Intelligence Texas A & M University Lecture 3 Lecturer: Laurie webster II, M.S.S.E., M.S.E.e., M.S.BME, Ph.D., P.E.
1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further.
Pengantar Kecerdasan Buatan
Uninformed search strategies A search strategy is defined by picking the order of node expansion Uninformed search strategies use only the information.
Problem Solving as Search. Problem Types Deterministic, fully observable  single-state problem Non-observable  conformant problem Nondeterministic and/or.
Problem Solving by Searching
Implementation: General Tree Search
Solving problems by searching A I C h a p t e r 3.
WEEK 5 LECTURE -A- 23/02/2012 lec 5a CSC 102 by Asma Tabouk Introduction 1 CSC AI Basic Search Strategies.
Chapter 3 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.
Artificial Intelligence Solving problems by searching.
EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS
Problem Solving as Search
Problem solving and search
Artificial Intelligence
Solving problems by searching
Artificial Intelligence
Solving problems by searching
Solving problems by searching
Solving problems by searching
Solving problems by searching
Presentation transcript:

CS 416 Artificial Intelligence Lecture 3 Uninformed Searches Lecture 3 Uninformed Searches

Romania On holiday in Romania; currently in Arad. Flight leaves tomorrow from Bucharest at 1:00. Let’s configure this to be an AI problem. On holiday in Romania; currently in Arad. Flight leaves tomorrow from Bucharest at 1:00. Let’s configure this to be an AI problem.

Romania What’s the problem? Accomplish a goalAccomplish a goal –Reach Bucharest by 1:00 So this is a goal-based problem What’s the problem? Accomplish a goalAccomplish a goal –Reach Bucharest by 1:00 So this is a goal-based problem

Romania Is there more to it? Do it well… according to a performance measureDo it well… according to a performance measure –Minimize distance traveled Is there more to it? Do it well… according to a performance measureDo it well… according to a performance measure –Minimize distance traveled

Romania What’s an example of a non-goal-based problem? Live long and prosperLive long and prosper Maximize the happiness of your trip to RomaniaMaximize the happiness of your trip to Romania Don’t get hurt too muchDon’t get hurt too much What’s an example of a non-goal-based problem? Live long and prosperLive long and prosper Maximize the happiness of your trip to RomaniaMaximize the happiness of your trip to Romania Don’t get hurt too muchDon’t get hurt too much

Romania What qualifies as a solution? You can/cannot reach Bucharest by 1:00You can/cannot reach Bucharest by 1:00 You can reach Bucharest in x hoursYou can reach Bucharest in x hours The shortest path to Bucharest passes through these citiesThe shortest path to Bucharest passes through these cities The sequence of cities in the shortest path from Arad to Bucharest is ________The sequence of cities in the shortest path from Arad to Bucharest is ________ The actions one takes to travel from Arad to Bucharest along the shortest pathThe actions one takes to travel from Arad to Bucharest along the shortest path What qualifies as a solution? You can/cannot reach Bucharest by 1:00You can/cannot reach Bucharest by 1:00 You can reach Bucharest in x hoursYou can reach Bucharest in x hours The shortest path to Bucharest passes through these citiesThe shortest path to Bucharest passes through these cities The sequence of cities in the shortest path from Arad to Bucharest is ________The sequence of cities in the shortest path from Arad to Bucharest is ________ The actions one takes to travel from Arad to Bucharest along the shortest pathThe actions one takes to travel from Arad to Bucharest along the shortest path

Romania What additional information does one need? A mapA map What additional information does one need? A mapA map

More concrete problem definition A state space Which cities could you be in An initial state Which city do you start from A goal state Which city do you aim to reach A function defining state transitions When in city foo, the following cities can be reached A function defining the “cost” of a state sequence How long does it take to travel through a city sequence

More concrete problem definition A state space Choose a representation An initial state Choose an element from the representation A goal state Create goal_function(state) such that TRUE is returned upon reaching goal A function defining state transitions successor_function(state) = {,, …} A function defining the “cost” of a state sequence cost (sequence) = number

State Space Real world is absurdly complex  state space must be abstracted for problem solving (Abstract) state = set of real states(Abstract) state = set of real states (Abstract) action = complex combination of real actions, e.g., “Arad  Zerind” represents a complex set of possible routes, detours, rest stops, etc.(Abstract) action = complex combination of real actions, e.g., “Arad  Zerind” represents a complex set of possible routes, detours, rest stops, etc. (Abstract) solution = set of real paths that are solutions in the real world(Abstract) solution = set of real paths that are solutions in the real world Each abstract action should be “easier” than the original problem and should permit expansion to a more detailed solution Real world is absurdly complex  state space must be abstracted for problem solving (Abstract) state = set of real states(Abstract) state = set of real states (Abstract) action = complex combination of real actions, e.g., “Arad  Zerind” represents a complex set of possible routes, detours, rest stops, etc.(Abstract) action = complex combination of real actions, e.g., “Arad  Zerind” represents a complex set of possible routes, detours, rest stops, etc. (Abstract) solution = set of real paths that are solutions in the real world(Abstract) solution = set of real paths that are solutions in the real world Each abstract action should be “easier” than the original problem and should permit expansion to a more detailed solution

Important notes about this example Static environment (available states, successor function, and cost functions don’t change)Static environment (available states, successor function, and cost functions don’t change) Observable (the agent knows where it is… percept == state)Observable (the agent knows where it is… percept == state) Discrete (the actions are discrete)Discrete (the actions are discrete) Deterministic (successor function is always the same)Deterministic (successor function is always the same) Static environment (available states, successor function, and cost functions don’t change)Static environment (available states, successor function, and cost functions don’t change) Observable (the agent knows where it is… percept == state)Observable (the agent knows where it is… percept == state) Discrete (the actions are discrete)Discrete (the actions are discrete) Deterministic (successor function is always the same)Deterministic (successor function is always the same)

Problem Solving Agents Restricted form of general agent: function SIMPLE-PROBLEM-SOLVING-AGENT(percept) returns an action static: seq, an action sequence, initially empty static: seq, an action sequence, initially empty state, some description of the current world state state, some description of the current world state goal, a goal, initially null goal, a goal, initially null problem, a problem definition problem, a problem definition state <- UPDATE-STATE(state, percept) state <- UPDATE-STATE(state, percept) if seq is empty then if seq is empty then goal <- FORMULATE-GOAL(state) goal <- FORMULATE-GOAL(state) problem <- FORMULATE-PROBLEM(state, goal) problem <- FORMULATE-PROBLEM(state, goal) seq <- SEARCH(problem) seq <- SEARCH(problem) action <- RECOMMENDATION(seq, state) action <- RECOMMENDATION(seq, state) seq <- REMAINDER(seq, state) seq <- REMAINDER(seq, state) return action return action Restricted form of general agent: function SIMPLE-PROBLEM-SOLVING-AGENT(percept) returns an action static: seq, an action sequence, initially empty static: seq, an action sequence, initially empty state, some description of the current world state state, some description of the current world state goal, a goal, initially null goal, a goal, initially null problem, a problem definition problem, a problem definition state <- UPDATE-STATE(state, percept) state <- UPDATE-STATE(state, percept) if seq is empty then if seq is empty then goal <- FORMULATE-GOAL(state) goal <- FORMULATE-GOAL(state) problem <- FORMULATE-PROBLEM(state, goal) problem <- FORMULATE-PROBLEM(state, goal) seq <- SEARCH(problem) seq <- SEARCH(problem) action <- RECOMMENDATION(seq, state) action <- RECOMMENDATION(seq, state) seq <- REMAINDER(seq, state) seq <- REMAINDER(seq, state) return action return action

Vacuum world example Floor has two locationsFloor has two locations Vacuum can move from one location to the otherVacuum can move from one location to the other Locations are clean/dirtyLocations are clean/dirty Vacuum can clean the location in which it isVacuum can clean the location in which it is Clean the floorClean the floor Floor has two locationsFloor has two locations Vacuum can move from one location to the otherVacuum can move from one location to the other Locations are clean/dirtyLocations are clean/dirty Vacuum can clean the location in which it isVacuum can clean the location in which it is Clean the floorClean the floor

Example: Vacuum World state space graph States: Integer dirt and robot locations (ignore dirt amounts)Integer dirt and robot locations (ignore dirt amounts)Actions: Left, Right, Suck, NoOpLeft, Right, Suck, NoOp Goal test: No dirtNo dirt Path cost: 1 per action (0 for NoOp)1 per action (0 for NoOp)States: Integer dirt and robot locations (ignore dirt amounts)Integer dirt and robot locations (ignore dirt amounts)Actions: Left, Right, Suck, NoOpLeft, Right, Suck, NoOp Goal test: No dirtNo dirt Path cost: 1 per action (0 for NoOp)1 per action (0 for NoOp)

Example: Vacuum World state space graph States? Actions? Goal test? Path cost?

Other Examples Fifteen Puzzle Robotic Assembly Traveling Salesman Protein Design Fifteen Puzzle Robotic Assembly Traveling Salesman Protein Design

Tree Search Algorithms Basic idea: Simulated exploration of state space by generating successors of already explored states (AKA expanding states)Simulated exploration of state space by generating successors of already explored states (AKA expanding states) function TREE-SEARCH(problem, strategy) returns a solution, or failure returns a solution, or failure initialize the search tree using the initial state of problem initialize the search tree using the initial state of problem loop do loop do if there are no more candidates for expansion then return failure if there are no more 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 else expand the node and add the resulting nodes to the search tree end end Basic idea: Simulated exploration of state space by generating successors of already explored states (AKA expanding states)Simulated exploration of state space by generating successors of already explored states (AKA expanding states) function TREE-SEARCH(problem, strategy) returns a solution, or failure returns a solution, or failure initialize the search tree using the initial state of problem initialize the search tree using the initial state of problem loop do loop do if there are no more candidates for expansion then return failure if there are no more 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 else expand the node and add the resulting nodes to the search tree end end

Example: Arad  Bucharest function TREE-SEARCH(problem, strategy) returns a solution, or failure returns a solution, or failure initialize the search tree using the initial state of problem initialize the search tree using the initial state of problem loop do loop do if there are no more candidates for expansion then return failure if there are no more 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 else expand the node and add the resulting nodes to the search tree end end function TREE-SEARCH(problem, strategy) returns a solution, or failure returns a solution, or failure initialize the search tree using the initial state of problem initialize the search tree using the initial state of problem loop do loop do if there are no more candidates for expansion then return failure if there are no more 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 else expand the node and add the resulting nodes to the search tree end end Arad

Example: Arad  Bucharest function TREE-SEARCH(problem, strategy) returns a solution, or failure returns a solution, or failure initialize the search tree using the initial state of problem initialize the search tree using the initial state of problem loop do loop do if there are no more candidates for expansion then return failure if there are no more 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 else expand the node and add the resulting nodes to the search tree end end function TREE-SEARCH(problem, strategy) returns a solution, or failure returns a solution, or failure initialize the search tree using the initial state of problem initialize the search tree using the initial state of problem loop do loop do if there are no more candidates for expansion then return failure if there are no more 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 else expand the node and add the resulting nodes to the search tree end end Arad

Example: Arad  Bucharest function TREE-SEARCH(problem, strategy) returns a solution, or failure returns a solution, or failure initialize the search tree using the initial state of problem initialize the search tree using the initial state of problem loop do loop do if there are no more candidates for expansion then return failure if there are no more 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 else expand the node and add the resulting nodes to the search tree end end function TREE-SEARCH(problem, strategy) returns a solution, or failure returns a solution, or failure initialize the search tree using the initial state of problem initialize the search tree using the initial state of problem loop do loop do if there are no more candidates for expansion then return failure if there are no more 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 else expand the node and add the resulting nodes to the search tree end end Arad

Example: Arad  Bucharest function TREE-SEARCH(problem, strategy) returns a solution, or failure returns a solution, or failure initialize the search tree using the initial state of problem initialize the search tree using the initial state of problem loop do loop do if there are no more candidates for expansion then return failure if there are no more 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 else expand the node and add the resulting nodes to the search tree end end function TREE-SEARCH(problem, strategy) returns a solution, or failure returns a solution, or failure initialize the search tree using the initial state of problem initialize the search tree using the initial state of problem loop do loop do if there are no more candidates for expansion then return failure if there are no more 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 else expand the node and add the resulting nodes to the search tree end end Arad Zerind (75) Timisoara (118) Sibiu (140)

Example: Arad  Bucharest function TREE-SEARCH(problem, strategy) returns a solution, or failure returns a solution, or failure initialize the search tree using the initial state of problem initialize the search tree using the initial state of problem loop do loop do if there are no more candidates for expansion then return failure if there are no more 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 else expand the node and add the resulting nodes to the search tree end end function TREE-SEARCH(problem, strategy) returns a solution, or failure returns a solution, or failure initialize the search tree using the initial state of problem initialize the search tree using the initial state of problem loop do loop do if there are no more candidates for expansion then return failure if there are no more 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 else expand the node and add the resulting nodes to the search tree end end Arad Zerind (75) Timisoara (118) Sibiu (140)

Example: Arad  Bucharest function TREE-SEARCH(problem, strategy) returns a solution, or failure returns a solution, or failure initialize the search tree using the initial state of problem initialize the search tree using the initial state of problem loop do loop do if there are no more candidates for expansion then return failure if there are no more 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 else expand the node and add the resulting nodes to the search tree end end function TREE-SEARCH(problem, strategy) returns a solution, or failure returns a solution, or failure initialize the search tree using the initial state of problem initialize the search tree using the initial state of problem loop do loop do if there are no more candidates for expansion then return failure if there are no more 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 else expand the node and add the resulting nodes to the search tree end end Arad Zerind (75) Timisoara (118) Sibiu (140)

Example: Arad  Bucharest function TREE-SEARCH(problem, strategy) returns a solution, or failure returns a solution, or failure initialize the search tree using the initial state of problem initialize the search tree using the initial state of problem loop do loop do if there are no more candidates for expansion then return failure if there are no more 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 else expand the node and add the resulting nodes to the search tree end end function TREE-SEARCH(problem, strategy) returns a solution, or failure returns a solution, or failure initialize the search tree using the initial state of problem initialize the search tree using the initial state of problem loop do loop do if there are no more candidates for expansion then return failure if there are no more 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 else expand the node and add the resulting nodes to the search tree end end Arad Zerind (75) Timisoara (118) Sibiu (140) Dradea (151) Faragas (99) Rimnicu Vilcea (80)

Implementation: states vs. nodes State (Representation of) a physical configuration(Representation of) a physical configurationNode Data structure constituting part of a search treeData structure constituting part of a search tree –Includes parent, children, depth, path cost g(x) States do not have parents, children, depth, or path cost! State (Representation of) a physical configuration(Representation of) a physical configurationNode Data structure constituting part of a search treeData structure constituting part of a search tree –Includes parent, children, depth, path cost g(x) States do not have parents, children, depth, or path cost!

Implementation: general tree search function TREE-SEARCH (problem, fringe) returns a solution, or failure fringe  INSERT(MAKE-NODE(INITIAL-STATE[problem]), fringe) fringe  INSERT(MAKE-NODE(INITIAL-STATE[problem]), fringe) loop do loop do if fringe is empty then return false if fringe is empty then return false node  REMOVE-FRONT(fringe) node  REMOVE-FRONT(fringe) if GOAL-TEST[problem] applied to STATE(node) succeeds return node if GOAL-TEST[problem] applied to STATE(node) succeeds return node fringe  INSERTALL(EXPAND(node, problem), fringe) fringe  INSERTALL(EXPAND(node, problem), fringe) function EXPAND (node, problem) returns a set of states successors  the empty set successors  the empty set for each action, result in SUCCESSOR-FN[problem](STATE[node]) do for each action, result in SUCCESSOR-FN[problem](STATE[node]) do s  a new NODE s  a new NODE PARENT-NODE[s]  node; ACTION[s]  action; STATE(s)  result PARENT-NODE[s]  node; ACTION[s]  action; STATE(s)  result PATH-COST[s]  PATH-COST[node] + STEP-COST(node, action, s) PATH-COST[s]  PATH-COST[node] + STEP-COST(node, action, s) DEPTH[s]  DEPTH[node] + 1 DEPTH[s]  DEPTH[node] + 1 add s to successors add s to successors return successors Find the error on this page! function TREE-SEARCH (problem, fringe) returns a solution, or failure fringe  INSERT(MAKE-NODE(INITIAL-STATE[problem]), fringe) fringe  INSERT(MAKE-NODE(INITIAL-STATE[problem]), fringe) loop do loop do if fringe is empty then return false if fringe is empty then return false node  REMOVE-FRONT(fringe) node  REMOVE-FRONT(fringe) if GOAL-TEST[problem] applied to STATE(node) succeeds return node if GOAL-TEST[problem] applied to STATE(node) succeeds return node fringe  INSERTALL(EXPAND(node, problem), fringe) fringe  INSERTALL(EXPAND(node, problem), fringe) function EXPAND (node, problem) returns a set of states successors  the empty set successors  the empty set for each action, result in SUCCESSOR-FN[problem](STATE[node]) do for each action, result in SUCCESSOR-FN[problem](STATE[node]) do s  a new NODE s  a new NODE PARENT-NODE[s]  node; ACTION[s]  action; STATE(s)  result PARENT-NODE[s]  node; ACTION[s]  action; STATE(s)  result PATH-COST[s]  PATH-COST[node] + STEP-COST(node, action, s) PATH-COST[s]  PATH-COST[node] + STEP-COST(node, action, s) DEPTH[s]  DEPTH[node] + 1 DEPTH[s]  DEPTH[node] + 1 add s to successors add s to successors return successors Find the error on this page!

Search strategies A strategy is defined by picking the order of node expansion Strategies are evaluated along the following dimensions: Completeness – does it always find a solution if one exists?Completeness – does it always find a solution if one exists? Time complexity – number of nodes generated/expandedTime complexity – number of nodes generated/expanded Space complexity – maximum nodes in memorySpace complexity – maximum nodes in memory Optimality – does it always find a least cost solution?Optimality – does it always find a least cost solution? Time and space complexity are measured in terms of: b – maximum branching factor of the search treeb – maximum branching factor of the search tree d – depth of the least-cost solutiond – depth of the least-cost solution m – maximum depth of the state space (may be infinite)m – maximum depth of the state space (may be infinite) A strategy is defined by picking the order of node expansion Strategies are evaluated along the following dimensions: Completeness – does it always find a solution if one exists?Completeness – does it always find a solution if one exists? Time complexity – number of nodes generated/expandedTime complexity – number of nodes generated/expanded Space complexity – maximum nodes in memorySpace complexity – maximum nodes in memory Optimality – does it always find a least cost solution?Optimality – does it always find a least cost solution? Time and space complexity are measured in terms of: b – maximum branching factor of the search treeb – maximum branching factor of the search tree d – depth of the least-cost solutiond – depth of the least-cost solution m – maximum depth of the state space (may be infinite)m – maximum depth of the state space (may be infinite)

Uninformed Search Strategies Uninformed strategies use only the information available in the problem definition Breadth-first searchBreadth-first search Uniform-cost searchUniform-cost search Depth-first searchDepth-first search Depth-limited searchDepth-limited search Iterative deepening searchIterative deepening search Uninformed strategies use only the information available in the problem definition Breadth-first searchBreadth-first search Uniform-cost searchUniform-cost search Depth-first searchDepth-first search Depth-limited searchDepth-limited search Iterative deepening searchIterative deepening search

Breadth-first search Expand shallowest unexpanded node Implementation: Fringe is a FIFO queue, i.e., new successors go at endFringe is a FIFO queue, i.e., new successors go at end Execute first few expansions of Arad to Bucharest using Breadth-first searchExecute first few expansions of Arad to Bucharest using Breadth-first search Expand shallowest unexpanded node Implementation: Fringe is a FIFO queue, i.e., new successors go at endFringe is a FIFO queue, i.e., new successors go at end Execute first few expansions of Arad to Bucharest using Breadth-first searchExecute first few expansions of Arad to Bucharest using Breadth-first search

Breadth-first Search Arad Zerind Arad ZerindTimisoaraSibiu Oradea ZerindSibiu Timisoara AradLugoj Sibiu DradeaFaragas Rimnicu Vilcea

Computation cost of BFS LevelNodes 0 1 b b2b2 b3b3

Computation cost of BFS If goal is in d = level 2 Cost = 1 + b + b 2 + b 3 – b = O (b d+1 ) If goal is in d = level 2 Cost = 1 + b + b 2 + b 3 – b = O (b d+1 ) LevelNodes 0 1 b b2b2 b3b3

Computation cost of BFS Cost = 1 + b + b 2 + b 3 – b = O (b d+1 ) Big Oh Notation There exist positive constants: c, b 0, d 0 such that for all b >= b 0 and d >= d 0There exist positive constants: c, b 0, d 0 such that for all b >= b 0 and d >= d 0 Cost = 1 + b + b 2 + b 3 – b = O (b d+1 ) Big Oh Notation There exist positive constants: c, b 0, d 0 such that for all b >= b 0 and d >= d 0There exist positive constants: c, b 0, d 0 such that for all b >= b 0 and d >= d 0 Figure 2.1 from Cormen, Leiserson, Rivest

Space cost of BFS Because you must be able to generate the path upon finding the goal state, all visited states must be stored

Properties of breadth-first search Complete?? Yes (if b (max branch factor) is finite) Time?? 1 + b + b 2 + … + b d + b(b d -1) = O(b d+1 ), i.e., exponential in d Space?? O(b d+1 ) (keeps every node in memory) Optimal?? Only if cost = 1 per step, otherwise not optimal in general Space is the big problem; can easily generate nodes at 10 MB/s, so 24hrs = 860GB! Complete?? Yes (if b (max branch factor) is finite) Time?? 1 + b + b 2 + … + b d + b(b d -1) = O(b d+1 ), i.e., exponential in d Space?? O(b d+1 ) (keeps every node in memory) Optimal?? Only if cost = 1 per step, otherwise not optimal in general Space is the big problem; can easily generate nodes at 10 MB/s, so 24hrs = 860GB!

Uniform-first search Expand least-cost unexpanded node Implementation: Fringe is a queue ordered by costFringe is a queue ordered by cost Execute first few expansions of Arad to Bucharest using Breadth-first searchExecute first few expansions of Arad to Bucharest using Breadth-first search Expand least-cost unexpanded node Implementation: Fringe is a queue ordered by costFringe is a queue ordered by cost Execute first few expansions of Arad to Bucharest using Breadth-first searchExecute first few expansions of Arad to Bucharest using Breadth-first search

Uniform-cost Search Arad Zerind (75) Arad (150)Oradea (146) Timisoara (118) Arad (193)Lugoj (229) Sibiu (140) Oradea (291)Faragas (139) Bucharest (350) Sibiu (238) Rimnicu (220) Vilcea

Uniform-cost search Complete?? If step cost ≥ ε Time?? If all costs are equal = O (b d )If all costs are equal = O (b d ) Space?? O(b C/ ε ) Optimal?? Yes–nodes expanded in increasing order of g(n) Complete?? If step cost ≥ ε Time?? If all costs are equal = O (b d )If all costs are equal = O (b d ) Space?? O(b C/ ε ) Optimal?? Yes–nodes expanded in increasing order of g(n)

Depth-first search Expand deepest unexpanded node Implementation: Fringe = LIFO queue, i.e., a stackFringe = LIFO queue, i.e., a stack Execute first few expansions of Arad to Bucharest using Depth-first searchExecute first few expansions of Arad to Bucharest using Depth-first search Expand deepest unexpanded node Implementation: Fringe = LIFO queue, i.e., a stackFringe = LIFO queue, i.e., a stack Execute first few expansions of Arad to Bucharest using Depth-first searchExecute first few expansions of Arad to Bucharest using Depth-first search

Depth-first search Complete??Time??Space??Optimal??Complete??Time??Space??Optimal??

Complete?? No: fails in infinite-depth spaces, spaces with loops.No: fails in infinite-depth spaces, spaces with loops. Can be modified to avoid repeated states along path  complete in finite spacesCan be modified to avoid repeated states along path  complete in finite spacesTime?? O(b m ) : terrible if m is much larger than d, but if solutions are dense, may be much faster than breadth-firstO(b m ) : terrible if m is much larger than d, but if solutions are dense, may be much faster than breadth-firstSpace?? O(bm), i.e., linear space!O(bm), i.e., linear space!Optimal?? NoNoComplete?? No: fails in infinite-depth spaces, spaces with loops.No: fails in infinite-depth spaces, spaces with loops. Can be modified to avoid repeated states along path  complete in finite spacesCan be modified to avoid repeated states along path  complete in finite spacesTime?? O(b m ) : terrible if m is much larger than d, but if solutions are dense, may be much faster than breadth-firstO(b m ) : terrible if m is much larger than d, but if solutions are dense, may be much faster than breadth-firstSpace?? O(bm), i.e., linear space!O(bm), i.e., linear space!Optimal?? NoNo

Depth-limited search Depth-first search with depth limit l i.e., nodes at depth l have no successorsi.e., nodes at depth l have no successors Depth-first search with depth limit l i.e., nodes at depth l have no successorsi.e., nodes at depth l have no successors

Iterative deepening search function ITERATIVE-DEEPENING-SEARCH(problem) returns a solution inputs: problem, a problem inputs: problem, a problem for depth  0 to ∞ do for depth  0 to ∞ do result  DEPTH-LIMITED-SEARCH(problem, depth) result  DEPTH-LIMITED-SEARCH(problem, depth) if result ≠ cutoff then return result if result ≠ cutoff then return result end end function ITERATIVE-DEEPENING-SEARCH(problem) returns a solution inputs: problem, a problem inputs: problem, a problem for depth  0 to ∞ do for depth  0 to ∞ do result  DEPTH-LIMITED-SEARCH(problem, depth) result  DEPTH-LIMITED-SEARCH(problem, depth) if result ≠ cutoff then return result if result ≠ cutoff then return result end end

Properties of iterative deepening Complete?? YesYesTime?? (d+1)b 0 + db 1 + (d-1)b 2 + … b d = O(b d )(d+1)b 0 + db 1 + (d-1)b 2 + … b d = O(b d )Space?? O(bd)O(bd)Optimal?? If step cost = 1If step cost = 1 Can be modified to explore uniform-cost treeCan be modified to explore uniform-cost treeComplete?? YesYesTime?? (d+1)b 0 + db 1 + (d-1)b 2 + … b d = O(b d )(d+1)b 0 + db 1 + (d-1)b 2 + … b d = O(b d )Space?? O(bd)O(bd)Optimal?? If step cost = 1If step cost = 1 Can be modified to explore uniform-cost treeCan be modified to explore uniform-cost tree

Summary All tree searching techniques are more alike than different Breadth-first has space issues, and possibly optimality issues Uniform-cost has space issues Depth-first has time and optimality issues, and possibly completeness issues Depth-limited search has optimality and completeness issues Iterative deepening is the best uninformed search we have explored Next class we study informed searches All tree searching techniques are more alike than different Breadth-first has space issues, and possibly optimality issues Uniform-cost has space issues Depth-first has time and optimality issues, and possibly completeness issues Depth-limited search has optimality and completeness issues Iterative deepening is the best uninformed search we have explored Next class we study informed searches