Multiagent Systems Problem Solving and Uninformed Search

Similar documents
Artificial Intelligence Problem Solving and Uninformed Search

Problem solving and search

Problem solving and search

Solving problems by searching

Outline. Solving problems by searching. Problem-solving agents. Example: Romania

Artificial Intelligence

Solving Problems by Searching. AIMA Sections , 3.6

Problem solving and search

CS 380: Artificial Intelligence Lecture #3

Chapter 2. Blind Search 8/19/2017

Solving problems by searching. Chapter 3

Solving problems by searching

Problem solving and search: Chapter 3, Sections 1 5

Problem solving and search: Chapter 3, Sections 1 5

ITCS 6150 Intelligent Systems. Lecture 3 Uninformed Searches

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

AI: problem solving and search

Solving Problem by Searching. Chapter 3

Reminders. Problem solving and search. Problem-solving agents. Outline. Assignment 0 due 5pm today

Problem-solving agents. Problem solving and search. Example: Romania. Reminders. Example: Romania. Outline. Chapter 3

Problem solving and search

Problem solving and search

Outline. Problem solving and search. Problem-solving agents. Example: Romania. Example: Romania. Problem types. Problem-solving agents.

CS 8520: Artificial Intelligence

Problem solving by search

Solving problems by searching

KI-Programmierung. Basic Search Algorithms

Problem solving and search

Artificial Intelligence, CS, Nanjing University Spring, 2018, Yang Yu. Lecture 2: Search 1.

Problem solving and search

Artificial Intelligence Uninformed search

Artificial Intelligence: Search Part 1: Uninformed graph search

Problem solving and search

Problem Solving and Search. Chapter 3

Uninformed Search. Problem-solving agents. Tree search algorithms. Single-State Problems

Problem Solving by Searching

Planning and search. Lecture 1: Introduction and Revision of Search. Lecture 1: Introduction and Revision of Search 1

Solving problems by searching

Outline. Solving problems by searching. Prologue. Example: Romania. Uninformed search

Solving problems by searching

Artificial Intelligence

Chapter 3 Solving problems by searching

Pengju XJTU 2016

Solving Problems: Blind Search

Uninformed Search strategies. AIMA sections 3.4,3.5

Problem Solving and Search

Robot Programming with Lisp

ARTIFICIAL INTELLIGENCE (CSC9YE ) LECTURES 2 AND 3: PROBLEM SOLVING

4. Solving Problems by Searching

A2 Uninformed Search

Example: The 8-puzzle. A2 Uninformed Search. It can be generalized to 15-puzzle, 24-puzzle, or. (n 2 1)-puzzle for n 6. Department of Computer Science

Week 3: Path Search. COMP9414/ 9814/ 3411: Artificial Intelligence. Motivation. Example: Romania. Romania Street Map. Russell & Norvig, Chapter 3.

Pengju

CS 151: Intelligent Agents, Problem Formulation and Search

Goal-Based Agents Problem solving as search. Outline

CS:4420 Artificial Intelligence

Set 2: State-spaces and Uninformed Search. ICS 271 Fall 2015 Kalev Kask

Problem-solving agents. Solving Problems by Searching. Outline. Example: Romania. Chapter 3

Solving Problems by Searching

Chapter3. Problem-Solving Agents. Problem Solving Agents (cont.) Well-defined Problems and Solutions. Example Problems.

Search I. slides from: Padhraic Smyth, Bryan Low, S. Russell and P. Norvig

Search EECS 395/495 Intro to Artificial Intelligence

Solving Problems by Searching (Blindly)

Search EECS 348 Intro to Artificial Intelligence

CS 4700: Foundations of Artificial Intelligence. Bart Selman. Search Techniques R&N: Chapter 3

ARTIFICIAL INTELLIGENCE SOLVING PROBLEMS BY SEARCHING. Chapter 3

CS 771 Artificial Intelligence. Problem Solving by Searching Uninformed search

Chapter 3. A problem-solving agent is a kind of goal-based agent. It decide what to do by finding sequences of actions that lead to desirable states.

Solving Problems by Searching

ARTIFICIAL INTELLIGENCE. Pathfinding and search

CS486/686 Lecture Slides (c) 2015 P.Poupart

CS486/686 Lecture Slides (c) 2014 P.Poupart

Problem solving Basic search. Example: Romania. Example: Romania. Problem types. Intelligent Systems and HCI D7023E. Single-state problem formulation

521495A: Artificial Intelligence

AGENTS AND ENVIRONMENTS. What is AI in reality?

AGENTS AND ENVIRONMENTS. What is AI in reality?

Artificial Intelligence

Uninformed Search. Chapter 3. (Based on slides by Stuart Russell, Subbarao Kambhampati, Dan Weld, Oren Etzioni, Henry Kautz, and other UW-AI faculty)

Basic Search. Fall Xin Yao. Artificial Intelligence: Basic Search

Uninformed Search Strategies AIMA

HW#1 due today. HW#2 due Monday, 9/09/13, in class Continue reading Chapter 3

Uninformed Search. Reading: Chapter 4 (Tuesday, 2/5) HW#1 due next Tuesday

Ar#ficial)Intelligence!!

Solving Problems by Searching

Solving Problems by Searching

Artificial Intelligence

Solving problems by searching

Solving problems by searching

Uninformed Search. Chapter 3

Graph Search. Chris Amato Northeastern University. Some images and slides are used from: Rob Platt, CS188 UC Berkeley, AIMA

Search Algorithms. Uninformed Blind search. Informed Heuristic search. Important concepts:

Problem Solving as Search. CMPSCI 383 September 15, 2011

Uninformed Search Methods

Solving Problems by Searching

Solving Problems by Searching

S A E RC R H C I H NG N G IN N S T S A T T A E E G R G A R PH P S

Problem Solving. Russell and Norvig: Chapter 3

Vorlesung Grundlagen der Künstlichen Intelligenz

Uninformed search strategies (Section 3.4) Source: Fotolia

Why Search. Things to consider. Example, a holiday in Jamaica. CSE 3401: Intro to Artificial Intelligence Uninformed Search

Transcription:

Multiagent Systems Problem Solving and Uninformed Search Viviana Mascardi viviana.mascardi@unige.it MAS, University of Genoa, DIBRIS Classical AI 1 / 36

Disclaimer This presentation may contain material protected by copyright laws. In particular, many lessons are based on the material that Russel and Norvig made available on the Web, as part of their book Artificial Intelligence: A Modern Approach We made this material available on the Web only to ensure timely dissemination among the students of the INTS Course at the University of Genova, and is meant only for students personal use. Any use different from the students personal use is prohibited. M. Martelli and V. Mascardi thank Professor Schachte for the courtesy of sharing his teaching material on Prolog MAS, University of Genoa, DIBRIS Classical AI 2 / 36

Outline 1 Problem-solving agents 2 Problem types Example: vacuum world 3 Problem formulation 4 Example problems Vacuum world state space graph The 8-puzzle 5 Breadth-first search Uniform-cost search Depth-first search Depth-limited search Iterative deepening search Summary of algorithms MAS, University of Genoa, DIBRIS Classical AI 3 / 36

Contents Problem-solving agents 1 Problem-solving agents 2 Problem types Example: vacuum world 3 Problem formulation 4 Example problems Vacuum world state space graph The 8-puzzle 5 Breadth-first search Uniform-cost search Depth-first search Depth-limited search Iterative deepening search Summary of algorithms MAS, University of Genoa, DIBRIS Classical AI 4 / 36

Problem-solving agents Problem-solving agents Restricted form of general agent: function SIMPLE-PROBLEM-SOLVING-AGENT (percept) returns an action static seq, an action sequence, initially empty state, some description of the current world state goal, a goal, initially null problem, a problem formulation state UPDATE_STATE(state,percept) if seq is empty then goal FORMULATE_GOAL(state) problem FORMULATE_PROBLEM(state, goal) seq SEARCH(problem) action RECCOMENDATION(seq,state) seq REMAINDER(seq,state) return action This is offline problem solving; solution executed eyes closed. Online problem solving involves acting without complete knowledge. MAS, University of Genoa, DIBRIS Classical AI 5 / 36

Problem-solving agents Example: Romania On holiday in Romania; currently in Arad. Flight leaves tomorrow from Bucharest Formulate goal: be in Bucharest Formulate problem: states : various cities actions : drive between cities Find solution: sequence of cities, e.g., Arad, Sibiu, Fagaras, Bucharest MAS, University of Genoa, DIBRIS Classical AI 6 / 36

Example: Romania Problem-solving agents MAS, University of Genoa, DIBRIS Classical AI 7 / 36

Contents Problem types 1 Problem-solving agents 2 Problem types Example: vacuum world 3 Problem formulation 4 Example problems Vacuum world state space graph The 8-puzzle 5 Breadth-first search Uniform-cost search Depth-first search Depth-limited search Iterative deepening search Summary of algorithms MAS, University of Genoa, DIBRIS Classical AI 8 / 36

Problem types Problem types Deterministic, fully observable = single-state problem Agent knows exactly which state it will be in; solution is a sequence Non-observable = conformant problem Agent may have no idea where it is; solution (if any) is a sequence Nondeterministic = contingency problem percepts provide new information about current state solution is a contingent plan or a policy often interleave search, execution Unknown state space = exploration problem ( online ) MAS, University of Genoa, DIBRIS Classical AI 9 / 36

Problem types Example: vacuum world Example: vacuum world Single-state: start in #5 Solution?? MAS, University of Genoa, DIBRIS Classical AI 10 / 36

Problem types Example: vacuum world Example: vacuum world Single-state: start in #5 Solution?? [Right, Suck] MAS, University of Genoa, DIBRIS Classical AI 10 / 36

Problem types Example: vacuum world Example: vacuum world Single-state: start in #5 Solution?? [Right, Suck] Conformant: start in {1, 2, 3, 4, 5, 6, 7, 8} e.g., Right goes to {2, 4, 6, 8} Solution?? MAS, University of Genoa, DIBRIS Classical AI 10 / 36

Problem types Example: vacuum world Example: vacuum world Single-state: start in #5 Solution?? [Right, Suck] Conformant: start in {1, 2, 3, 4, 5, 6, 7, 8} e.g., Right goes to {2, 4, 6, 8} Solution?? [Right, Suck, Left, Suck] MAS, University of Genoa, DIBRIS Classical AI 10 / 36

Problem types Example: vacuum world Example: vacuum world Single-state: start in #5 Solution?? [Right, Suck] Conformant: start in {1, 2, 3, 4, 5, 6, 7, 8} e.g., Right goes to {2, 4, 6, 8} Solution?? [Right, Suck, Left, Suck] Contingency: start in #5 Murphy s Law: Suck can dirty a clean carpet Local Sensing: dirt, location only Solution?? MAS, University of Genoa, DIBRIS Classical AI 10 / 36

Problem types Example: vacuum world Example: vacuum world Single-state: start in #5 Solution?? [Right, Suck] Conformant: start in {1, 2, 3, 4, 5, 6, 7, 8} e.g., Right goes to {2, 4, 6, 8} Solution?? [Right, Suck, Left, Suck] Contingency: start in #5 Murphy s Law: Suck can dirty a clean carpet Local Sensing: dirt, location only Solution?? [Right,if dirt then Suck] MAS, University of Genoa, DIBRIS Classical AI 10 / 36

Contents Problem formulation 1 Problem-solving agents 2 Problem types Example: vacuum world 3 Problem formulation 4 Example problems Vacuum world state space graph The 8-puzzle 5 Breadth-first search Uniform-cost search Depth-first search Depth-limited search Iterative deepening search Summary of algorithms MAS, University of Genoa, DIBRIS Classical AI 11 / 36

Problem formulation Single-state problem formulations A problem is defined by four items: initial state e.g., at Arad successor function S(x) = set of action state pairs e.g., S(Arad) = { Arad Zerind, Zerind,...} goal test can be: explicit e.g., x = at Bucharest implicit e.g., NoDirt(x) path cost (additive) e.g., sum of distances, number of actions executed, etc. c(x, a, y) is the step cost, assumed to be 0 A solution is a sequence of actions leading from the initial state to a goal state MAS, University of Genoa, DIBRIS Classical AI 12 / 36

Problem formulation Selecting a state space Real world is absurdly complex state space must be abstracted for problem solving (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. For guaranteed realizability, any real state in Arad must get to some real state in Zerind (Abstract) solution = set of real paths that are solutions in the real world Each abstract action should be easier than the original problem! MAS, University of Genoa, DIBRIS Classical AI 13 / 36

Contents Example problems 1 Problem-solving agents 2 Problem types Example: vacuum world 3 Problem formulation 4 Example problems Vacuum world state space graph The 8-puzzle 5 Breadth-first search Uniform-cost search Depth-first search Depth-limited search Iterative deepening search Summary of algorithms MAS, University of Genoa, DIBRIS Classical AI 14 / 36

Example problems Vacuum world state space graph Example: vacuum world state space graph MAS, University of Genoa, DIBRIS Classical AI 15 / 36

Example problems Vacuum world state space graph Example: vacuum world state space graph States??: MAS, University of Genoa, DIBRIS Classical AI 15 / 36

Example problems Vacuum world state space graph Example: vacuum world state space graph States??: integer dirt and robot location (ignore dirt amounts etc.) MAS, University of Genoa, DIBRIS Classical AI 15 / 36

Example problems Vacuum world state space graph Example: vacuum world state space graph States??: integer dirt and robot location (ignore dirt amounts etc.) Actions??: MAS, University of Genoa, DIBRIS Classical AI 15 / 36

Example problems Vacuum world state space graph Example: vacuum world state space graph States??: integer dirt and robot location (ignore dirt amounts etc.) Actions??: Letf, Right, Suck, NoOp MAS, University of Genoa, DIBRIS Classical AI 15 / 36

Example problems Vacuum world state space graph Example: vacuum world state space graph States??: integer dirt and robot location (ignore dirt amounts etc.) Actions??: Letf, Right, Suck, NoOp Goal Test??: MAS, University of Genoa, DIBRIS Classical AI 15 / 36

Example problems Vacuum world state space graph Example: vacuum world state space graph States??: integer dirt and robot location (ignore dirt amounts etc.) Actions??: Letf, Right, Suck, NoOp Goal Test??: no dirt MAS, University of Genoa, DIBRIS Classical AI 15 / 36

Example problems Vacuum world state space graph Example: vacuum world state space graph States??: integer dirt and robot location (ignore dirt amounts etc.) Actions??: Letf, Right, Suck, NoOp Goal Test??: no dirt Path Cost??: MAS, University of Genoa, DIBRIS Classical AI 15 / 36

Example problems Vacuum world state space graph Example: vacuum world state space graph States??: integer dirt and robot location (ignore dirt amounts etc.) Actions??: Letf, Right, Suck, NoOp Goal Test??: no dirt Path Cost??: 1 per action (0 for NoOp) MAS, University of Genoa, DIBRIS Classical AI 15 / 36

Example problems Example: The 8-puzzle The 8-puzzle MAS, University of Genoa, DIBRIS Classical AI 16 / 36

Example problems Example: The 8-puzzle The 8-puzzle States??: MAS, University of Genoa, DIBRIS Classical AI 16 / 36

Example problems Example: The 8-puzzle The 8-puzzle States??: integer locations of tiles (ignore intermediate positions.) MAS, University of Genoa, DIBRIS Classical AI 16 / 36

Example problems Example: The 8-puzzle The 8-puzzle States??: integer locations of tiles (ignore intermediate positions.) Actions??: MAS, University of Genoa, DIBRIS Classical AI 16 / 36

Example problems Example: The 8-puzzle The 8-puzzle States??: integer locations of tiles (ignore intermediate positions.) Actions??: move blank left, right, up, down (ignore unjamming etc.) MAS, University of Genoa, DIBRIS Classical AI 16 / 36

Example problems Example: The 8-puzzle The 8-puzzle States??: integer locations of tiles (ignore intermediate positions.) Actions??: move blank left, right, up, down (ignore unjamming etc.) Goal Test??: MAS, University of Genoa, DIBRIS Classical AI 16 / 36

Example problems Example: The 8-puzzle The 8-puzzle States??: integer locations of tiles (ignore intermediate positions.) Actions??: move blank left, right, up, down (ignore unjamming etc.) Goal Test??: goal state (given) MAS, University of Genoa, DIBRIS Classical AI 16 / 36

Example problems Example: The 8-puzzle The 8-puzzle States??: integer locations of tiles (ignore intermediate positions.) Actions??: move blank left, right, up, down (ignore unjamming etc.) Goal Test??: goal state (given) Path Cost??: MAS, University of Genoa, DIBRIS Classical AI 16 / 36

Example problems Example: The 8-puzzle The 8-puzzle States??: integer locations of tiles (ignore intermediate positions.) Actions??: move blank left, right, up, down (ignore unjamming etc.) Goal Test??: goal state (given) Path Cost??: 1 per move MAS, University of Genoa, DIBRIS Classical AI 16 / 36

Example problems Example: The 8-puzzle The 8-puzzle States??: integer locations of tiles (ignore intermediate positions.) Actions??: move blank left, right, up, down (ignore unjamming etc.) Goal Test??: goal state (given) Path Cost??: 1 per move Note: optimal solution of n-puzzle is NP-hard MAS, University of Genoa, DIBRIS Classical AI 16 / 36

Contents 1 Problem-solving agents 2 Problem types Example: vacuum world 3 Problem formulation 4 Example problems Vacuum world state space graph The 8-puzzle 5 Breadth-first search Uniform-cost search Depth-first search Depth-limited search Iterative deepening search Summary of algorithms MAS, University of Genoa, DIBRIS Classical AI 17 / 36

Tree search algorithms Basic idea: offline, simulated exploration of state space by generating successors of already-explored states (a.k.a. expanding states) function TREE-SEARCH(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 MAS, University of Genoa, DIBRIS Classical AI 18 / 36

Problem types MAS, University of Genoa, DIBRIS Classical AI 19 / 36

Problem types MAS, University of Genoa, DIBRIS Classical AI 19 / 36

Problem types MAS, University of Genoa, DIBRIS Classical AI 19 / 36

Implementation: states vs. nodes A state is a (representation of) a physical configuration A node is a data 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! The Expand function creates new nodes, filling in the various fields and using the Successor of the problem to create the corresponding states. MAS, University of Genoa, DIBRIS Classical AI 20 / 36

Implementation: general tree search function TREE-SEARCH(problem,strategy) returns a solution, or failure fringe INSERT(MAKE-NODE(INITIAL-STATE[problem]),fringe) loop do if fringe is empty then return failure node REMOVE-FRONT(fringe) if GOAL-TEST(problem,STATE(node)) then return node fringe INSERTALL(EXPAND(node,problem),fringe) end function EXPAND(node,problem) returns a set of nodes successors the empty set foreach action, result in SUCCESSOR-FN(problem, STATE[node]) do s new NODE PARENT-NODE[s] node; ACTION[s] action; STATE[s] result PATH-COST[s] PATH-COST[node] + STEP-COST(node,action,s) DEPTH[s] DEPTH[node] + 1 add s to successors return successors MAS, University of Genoa, DIBRIS Classical AI 21 / 36

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? time complexity number of nodes generated/expanded space complexity maximum number of nodes in memory 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 tree d depth of the least-cost solution m maximum depth of the state space (may be ) MAS, University of Genoa, DIBRIS Classical AI 22 / 36

Uninformed search strategies Uninformed strategies use only the information available in the problem definition Breadth-first search Uniform-cost search Depth-first search Depth-limited search Iterative deepening search MAS, University of Genoa, DIBRIS Classical AI 23 / 36

Breadth-first search Breadth-first search Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end MAS, University of Genoa, DIBRIS Classical AI 24 / 36

Breadth-first search Breadth-first search Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end MAS, University of Genoa, DIBRIS Classical AI 24 / 36

Breadth-first search Breadth-first search Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end MAS, University of Genoa, DIBRIS Classical AI 24 / 36

Breadth-first search Breadth-first search Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end MAS, University of Genoa, DIBRIS Classical AI 24 / 36

Breadth-first search Properties of breadth-first search Complete?? MAS, University of Genoa, DIBRIS Classical AI 25 / 36

Breadth-first search Properties of breadth-first search Complete - Yes (if b is finite) MAS, University of Genoa, DIBRIS Classical AI 25 / 36

Breadth-first search Properties of breadth-first search Complete - Yes (if b is finite) Time?? MAS, University of Genoa, DIBRIS Classical AI 25 / 36

Breadth-first search Properties of breadth-first search Complete - Yes (if b is finite) Time - 1 + b + b 2 + b 3 +... + b d + b(b d 1) = O(b d+1 ), i.e., exp. in d Space?? MAS, University of Genoa, DIBRIS Classical AI 25 / 36

Breadth-first search Properties of breadth-first search Complete - Yes (if b is finite) Time - 1 + b + b 2 + b 3 +... + b d + b(b d 1) = O(b d+1 ), i.e., exp. in d Space - O(b d+1 ) (keeps every node in memory) MAS, University of Genoa, DIBRIS Classical AI 25 / 36

Breadth-first search Properties of breadth-first search Complete - Yes (if b is finite) Time - 1 + b + b 2 + b 3 +... + b d + b(b d 1) = O(b d+1 ), i.e., exp. in d Space - O(b d+1 ) (keeps every node in memory) Optimal?? MAS, University of Genoa, DIBRIS Classical AI 25 / 36

Breadth-first search Properties of breadth-first search Complete - Yes (if b is finite) Time - 1 + b + b 2 + b 3 +... + b d + b(b d 1) = O(b d+1 ), i.e., exp. in d Space - O(b d+1 ) (keeps every node in memory) Optimal - Yes (if cost = 1 per step); not optimal in general MAS, University of Genoa, DIBRIS Classical AI 25 / 36

Breadth-first search Properties of breadth-first search Complete - Yes (if b is finite) Time - 1 + b + b 2 + b 3 +... + b d + b(b d 1) = O(b d+1 ), i.e., exp. in d Space - O(b d+1 ) (keeps every node in memory) Optimal - Yes (if cost = 1 per step); not optimal in general Space is the big problem; can easily generate nodes at 100MB/sec so 24hrs = 8640GB. MAS, University of Genoa, DIBRIS Classical AI 25 / 36

Uniform-cost search Uniform-cost search Expand least-cost unexpanded node Implementation: fringe = queue ordered by path cost, lowest first Equivalent to breadth-first if step costs all equal Complete Yes, if step cost ɛ Time # of nodes with g cost of optimal solution, O(b C /ɛ ) where C is the cost of the optimal solution Space # of nodes with g cost of optimal solution, O(b C /ɛ ) Optimal Yes nodes expanded in increasing order of g(n) MAS, University of Genoa, DIBRIS Classical AI 26 / 36

Depth-first search Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front MAS, University of Genoa, DIBRIS Classical AI 27 / 36

Depth-first search Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front MAS, University of Genoa, DIBRIS Classical AI 27 / 36

Depth-first search Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front MAS, University of Genoa, DIBRIS Classical AI 27 / 36

Depth-first search Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front MAS, University of Genoa, DIBRIS Classical AI 27 / 36

Depth-first search Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front MAS, University of Genoa, DIBRIS Classical AI 27 / 36

Depth-first search Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front MAS, University of Genoa, DIBRIS Classical AI 27 / 36

Depth-first search Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front MAS, University of Genoa, DIBRIS Classical AI 27 / 36

Depth-first search Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front MAS, University of Genoa, DIBRIS Classical AI 27 / 36

Depth-first search Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front MAS, University of Genoa, DIBRIS Classical AI 27 / 36

Depth-first search Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front MAS, University of Genoa, DIBRIS Classical AI 27 / 36

Depth-first search Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front MAS, University of Genoa, DIBRIS Classical AI 27 / 36

Depth-first search Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front MAS, University of Genoa, DIBRIS Classical AI 27 / 36

Properties of depth-first search Depth-first search Complete?? MAS, University of Genoa, DIBRIS Classical AI 28 / 36

Properties of depth-first search Depth-first search Complete - No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path complete in finite spaces MAS, University of Genoa, DIBRIS Classical AI 28 / 36

Depth-first search Properties of depth-first search Complete - No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path complete in finite spaces Time?? MAS, University of Genoa, DIBRIS Classical AI 28 / 36

Depth-first search Properties of depth-first search Complete - No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path complete in finite spaces Time - O(b m ): terrible if m is much larger than d but if solutions are dense, may be much faster than breadth-first Space?? MAS, University of Genoa, DIBRIS Classical AI 28 / 36

Depth-first search Properties of depth-first search Complete - No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path complete in finite spaces Time - O(b m ): terrible if m is much larger than d but if solutions are dense, may be much faster than breadth-first Space - O(bm), i.e., linear space! MAS, University of Genoa, DIBRIS Classical AI 28 / 36

Depth-first search Properties of depth-first search Complete - No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path complete in finite spaces Time - O(b m ): terrible if m is much larger than d but if solutions are dense, may be much faster than breadth-first Space - O(bm), i.e., linear space! Optimal?? MAS, University of Genoa, DIBRIS Classical AI 28 / 36

Depth-first search Properties of depth-first search Complete - No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path complete in finite spaces Time - O(b m ): terrible if m is much larger than d but if solutions are dense, may be much faster than breadth-first Space - O(bm), i.e., linear space! Optimal - No MAS, University of Genoa, DIBRIS Classical AI 28 / 36

Depth-limited search Depth-limited search = depth-first search with depth limit l, i.e., nodes at depth l have no successors Recursive implementation: function DEPTH-LIMITED-SEARCH(problem,limit) returns soln/fail/cutoff RECURSIVE-DLS(MAKE-NODE(INITIAL-STATE[problem]),problem, limit) function RECURSIVE-DLS(node,problem,limit) returns soln/fail/cutoff cutoff-occured? false if GOAL-TEST(problem, STATE[node]) then return node else if DEPTH[node] = limit then return cutoff else foreach successor in EXPAND(node,problem) do result RECURSIVE-DLS(successor,problem,limit) if result = cutoff then cutoff-occurred? true else if result failure then return result if cutoff-occurred? then return cutoff else return failure MAS, University of Genoa, DIBRIS Classical AI 29 / 36

Iterative deepening search Iterative deepening search function ITERATIVE-DEEPENING-SEARCH(problem) returns a solution inputs problem, a problem for depth 0 to do result DEPTH-LIMITED-SEARCH(problem, depth) if result cutoff then return result MAS, University of Genoa, DIBRIS Classical AI 30 / 36

Iterative deepening search Iterative deepening search MAS, University of Genoa, DIBRIS Classical AI 31 / 36

Iterative deepening search Iterative deepening search MAS, University of Genoa, DIBRIS Classical AI 31 / 36

Iterative deepening search Iterative deepening search MAS, University of Genoa, DIBRIS Classical AI 31 / 36

Iterative deepening search Iterative deepening search MAS, University of Genoa, DIBRIS Classical AI 31 / 36

Iterative deepening search Properties of iterative deepening search Complete?? MAS, University of Genoa, DIBRIS Classical AI 32 / 36

Iterative deepening search Properties of iterative deepening search Complete - Yes MAS, University of Genoa, DIBRIS Classical AI 32 / 36

Iterative deepening search Properties of iterative deepening search Complete - Yes Time?? MAS, University of Genoa, DIBRIS Classical AI 32 / 36

Iterative deepening search Properties of iterative deepening search Complete - Yes Time - (d + 1)b 0 + db 1 + (d 1)b 2 +... + b d = O(b d ) Space?? MAS, University of Genoa, DIBRIS Classical AI 32 / 36

Iterative deepening search Properties of iterative deepening search Complete - Yes Time - (d + 1)b 0 + db 1 + (d 1)b 2 +... + b d = O(b d ) Space - O(bd) MAS, University of Genoa, DIBRIS Classical AI 32 / 36

Iterative deepening search Properties of iterative deepening search Complete - Yes Time - (d + 1)b 0 + db 1 + (d 1)b 2 +... + b d = O(b d ) Space - O(bd) Optimal?? MAS, University of Genoa, DIBRIS Classical AI 32 / 36

Iterative deepening search Properties of iterative deepening search Complete - Yes Time - (d + 1)b 0 + db 1 + (d 1)b 2 +... + b d = O(b d ) Space - O(bd) Optimal - Yes, if step cost = 1. Can be modified to explore uniform-cost tree MAS, University of Genoa, DIBRIS Classical AI 32 / 36

Iterative deepening search Properties of iterative deepening search Complete - Yes Time - (d + 1)b 0 + db 1 + (d 1)b 2 +... + b d = O(b d ) Space - O(bd) Optimal - Yes, if step cost = 1. Can be modified to explore uniform-cost tree Numerical comparison for b = 10 and d = 5, solution at far right leaf: N(IDS) = 50 + 400 + 3, 000 + 20, 000 + 100, 000 = 123, 450 N(BFS) = 10 + 100 + 1, 000 + 10, 000 + 100, 000 + 999, 990 = 1, 111, 100 IDS does better because other nodes at depth d are not expanded BFS can be modified to apply goal test when a node is generated MAS, University of Genoa, DIBRIS Classical AI 32 / 36

Summary of algorithms Summary of algorithms Criterion Breath- Uniform- Depth- Depth- Iterative First Cost First Lmited Deeping Complete Yes Yes No Yes, if l d Yes Time b d+1 b C /ɛ b m b l b d Space b d+1 b C /ɛ bm bl bd Optimal Yes Yes No No Yes MAS, University of Genoa, DIBRIS Classical AI 33 / 36

Repeated states Summary of algorithms Failure to detect repeated states can turn a linear problem into an exponential one! MAS, University of Genoa, DIBRIS Classical AI 34 / 36

Graph search Summary of algorithms function GRAPH-SEARCH(problem,fringe) returns a solution, or failure closed an empty set fringe INSERT(MAKE-NODE(INITIAL-STATE[problem]),fringe) loop do if fringe is empty then return failure node REMOVE-FRONT(fringe) if GOAL-TEST(problem,STATE(node)) then return node if STATE(node) is not closed then add STATE[node] to closed fringe INSERTALL(EXPAND(node,problem),fringe) end MAS, University of Genoa, DIBRIS Classical AI 35 / 36

Summary Summary of algorithms Problem formulation usually requires abstracting away real-world details to define a state space that can feasibly be explored Variety of uninformed search strategies Iterative deepening search uses only linear space and not much more time than other uninformed algorithms Graph search can be exponentially more efficient than tree search MAS, University of Genoa, DIBRIS Classical AI 36 / 36