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

Similar documents
CSC 2114: Artificial Intelligence Search

CSE 473: Ar+ficial Intelligence

CS 188: Ar)ficial Intelligence

Announcements. Project 0: Python Tutorial Due last night

CS 4100 // artificial intelligence

CS 8520: Artificial Intelligence

521495A: Artificial Intelligence

Solving problems by searching

CS 380: Artificial Intelligence Lecture #3

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

PEAS: Medical diagnosis system

Solving Problem by Searching. Chapter 3

Chapter 2. Blind Search 8/19/2017

KI-Programmierung. Basic Search Algorithms

Solving problems by searching

Solving problems by searching

CS 5522: Artificial Intelligence II

Graphs vs trees up front; use grid too; discuss for BFS, DFS, IDS, UCS Cut back on A* optimality detail; a bit more on importance of heuristics,

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

ARTIFICIAL INTELLIGENCE. Pathfinding and search

Artificial Intelligence Problem Solving and Uninformed Search

Warm- up. IteraAve version, not recursive. class TreeNode TreeNode[] children() boolean isgoal() DFS(TreeNode start)

Multiagent Systems Problem Solving and Uninformed Search

Solving Problems: Blind Search

AI: problem solving and search

CS 771 Artificial Intelligence. Problem Solving by Searching Uninformed search

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

521495A: Artificial Intelligence

Search EECS 395/495 Intro to Artificial Intelligence

Search EECS 348 Intro to Artificial Intelligence

Problem Solving and Search

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 and search

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

Solving problems by searching

Solving Problems by Searching

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

Artificial Intelligence

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

Artificial Intelligence

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

Chapter 3 Solving problems by searching

Problem solving and search

CAP 4630 Artificial Intelligence

Solving Problems by Searching (Blindly)

Goal-Based Agents Problem solving as search. Outline

ARTIFICIAL INTELLIGENCE SOLVING PROBLEMS BY SEARCHING. Chapter 3

Solving problems by searching. Chapter 3

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

Solving Problems by Searching. AIMA Sections , 3.6

Uninformed Search. Chapter 3

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

Problem solving and search

Heuristic Search. Rob Platt Northeastern University. Some images and slides are used from: AIMA

Problem solving and search

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

AGENTS AND ENVIRONMENTS. What is AI in reality?

Heuristic Search. Robert Platt Northeastern University. Some images and slides are used from: 1. CS188 UC Berkeley 2. RN, AIMA

COMP219: Artificial Intelligence. Lecture 7: Search Strategies

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

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

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

4. Solving Problems by Searching

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

Solving Problems by Searching

Problem solving and search

AGENTS AND ENVIRONMENTS. What is AI in reality?

Ar#ficial)Intelligence!!

CS510 \ Lecture Ariel Stolerman

ITCS 6150 Intelligent Systems. Lecture 3 Uninformed Searches

Solving problems by searching

Solving problems by searching

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

Artificial Intelligence

Introduction to Artificial Intelligence (G51IAI) Dr Rong Qu. Blind Searches

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

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

Informed Search (Ch )

Solving Problems by Searching

Solving Problems by Searching

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

Artificial Intelligence Uninformed search

CMU-Q Lecture 2: Search problems Uninformed search. Teacher: Gianni A. Di Caro

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.

CSE 40171: Artificial Intelligence. Uninformed Search: Search Spaces

9/7/2015. Outline for today s lecture. Problem Solving Agents & Problem Formulation. Task environments

Problem solving and search: Chapter 3, Sections 1 5

Problem solving and search: Chapter 3, Sections 1 5

CSE 473. Chapter 4 Informed Search. CSE AI Faculty. Last Time. Blind Search BFS UC-BFS DFS DLS Iterative Deepening Bidirectional Search

Lecture 4: Search 3. Victor R. Lesser. CMPSCI 683 Fall 2010

Problem Solving by Searching

Lecture 2: Fun with Search. Rachel Greenstadt CS 510, October 5, 2017

UNINFORMED SEARCH. What to do if teammates drop? Still have 3 or more? No problem keep going. Have two or fewer and want to be merged?

Informed Search and Exploration

Uninformed search strategies (Section 3.4) Source: Fotolia

Uninformed search strategies

Uninformed Search Strategies AIMA 3.4

Robot Programming with Lisp

Chapter 3: Solving Problems by Searching

Problem Solving and Search. Chapter 3

Transcription:

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

What is graph search? Start state Goal state Graph search: find a path from start to goal what are the states? what are the actions (transitions)? how is this a graph?

What is graph search? Start state Goal state Graph search: find a path from start to goal what are the states? what are the actions (transitions)? how is this a graph?

What is graph search? Start state Goal state Graph search: find a path from start to goal what are the states? what are the actions (transitions)? how is this a graph?

What is graph search? Start state Graph search: find a path from start to goal what are the states? what are the actions (transitions)? Goal state how is this a graph?

What is a graph? Graph: Vertices: Edges: Directed graph

What is a graph? Graph: Vertices: Edges: Undirected graph

What is a graph? Graph: Vertices: Edges: Also called states Also called transitions

Defining a graph: example

Defining a graph: example How many states?

Defining a graph: example

Defining a graph: example Pairs of states that are connected by one turn of the cube.

Example: Romania l On holiday in Romania; currently in Arad. Flight leaves tomorrow from Bucharest l Formulate goal: Be in Bucharest l Formulate problem: l states: various cities l actions: drive between cities l Find solution: l sequence of cities, e.g., Arad, Sibiu, Fagaras, Bucharest

Graph search Given: a graph, G Problem: find a path from A to B A: start state B: goal state

Graph search How? Given: a graph, G Problem: find a path from A to B A: start state B: goal state

Problem formulation A problem is defined by four items: l l initial state e.g., at Arad successor function S(x) = set of action state pairs e.g., S(Arad) = { Arad Zerind, Zerind,...} l l 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 l A solution is a sequence of actions leading from the initial state to a goal state

A search tree Start at A

A search tree Successors of A

A search tree Successors of A parent children

A search tree Let's expand S next

A search tree Successors of S

A search tree A was already visited!

A search tree A was already So, prune visited! it!

A search tree In what order should we expand states? here, we expanded S, but we could also have expanded Z or T different search algorithms expand in different orders

Breadth first search (BFS)

Breadth first search (BFS)

Breadth first search (BFS) Start node

Breadth first search (BFS)

Breadth first search (BFS)

Breadth first search (BFS)

Breadth first search (BFS) Fringe We're going to maintain a queue called the fringe initialize the fringe as an empty queue

Breadth first search (BFS) Fringe A fringe add A to the fringe

Breadth first search (BFS) Fringe B C fringe -- remove A from the fringe -- add successors of A to the fringe

Breadth first search (BFS) Fringe C D E fringe -- remove B from the fringe -- add successors of B to the fringe

Breadth first search (BFS) Fringe D E F G fringe -- remove C from the fringe -- add successors of C to the fringe

Breadth first search (BFS) Fringe D E F G fringe Which state gets removed next from the fringe?

Breadth first search (BFS) Fringe D E F G fringe Which state gets removed next from the fringe? What kind of a queue is this?

Breadth first search (BFS) Fringe D E F G fringe Which state gets removed next from the fringe? What kind of a queue is this? FIFO Queue! (first in first out)

Breadth first search (BFS)

Breadth first search (BFS) What is the purpose of the explored set?

BFS Properties Is BFS complete? is it guaranteed to find a solution if one exists?

BFS Properties Is BFS complete? is it guaranteed to find a solution if one exists? What is the time complexity of BFS? how many states are expanded before finding a sol'n? b: branching factor d: depth of shallowest solution complexity =???

BFS Properties Is BFS complete? is it guaranteed to find a solution if one exists? What is the time complexity of BFS? how many states are expanded before finding a solution? b: branching factor d: depth of shallowest solution complexity =

BFS Properties Is BFS complete? is it guaranteed to find a solution if one exists? What is the time complexity of BFS? how many states are expanded before finding a solution? b: branching factor d: depth of shallowest solution complexity = What is the space complexity of BFS? how much memory is required? complexity =???

BFS Properties Is BFS complete? is it guaranteed to find a solution if one exists? What is the time complexity of BFS? how many states are expanded before finding a solution? b: branching factor d: depth of shallowest solution complexity = What is the space complexity of BFS? how much memory is required? complexity =

BFS Properties Is BFS complete? is it guaranteed to find a solution if one exists? What is the time complexity of BFS? how many states are expanded before finding a solution? b: branching factor d: depth of shallowest solution complexity = What is the space complexity of BFS? how much memory is required? complexity = Is BFS optimal? is it guaranteed to find the best solution (shortest path)?

Uniform Cost Search (UCS)

Uniform Cost Search (UCS) Notice the distances between cities

Uniform Cost Search (UCS) Notice the distances between cities does BFS take these distances into account?

Uniform Cost Search (UCS) Notice the distances between cities does BFS take these distances into account? does BFS find the path w/ shortest milage?

Uniform Cost Search (UCS) Notice the distances between cities does BFS take these distances into account? does BFS find the path w/ shortest milage? compare S-F-B with S-R-P-B. Which costs less?

Uniform Cost Search (UCS) How do we fix this? Notice the distances between cities does BFS take these distances into account? does BFS find the path w/ shortest milage? compare S-F-B with S-R-P-B. Which costs less?

Uniform Cost Search (UCS) How do we fix this? Notice the distances UCS! between cities does BFS take these distances into account? does BFS find the path w/ shortest milage? compare S-F-B with S-R-P-B. Which costs less?

Uniform Cost Search (UCS) Same as BFS except: expand node w/ smallest path cost Length of path

Uniform Cost Search (UCS) Same as BFS except: expand node w/ smallest path cost Length of path Cost of going from state A to B: Minimum cost of path going from start state to B:

Uniform Cost Search (UCS) Same as BFS except: expand node w/ smallest path cost Length of path Cost of going from state A to B: Minimum cost of path going from start state to B: BFS: expands states in order of hops from start UCS: expands states in order of

Uniform Cost Search (UCS) Same as BFS except: expand node w/ smallest path cost Length of path Cost of going from state A to B: Minimum cost of path going from start state to B: BFS: expands states in order of hops from start UCS: expands states in order How? of

Uniform Cost Search (UCS) Simple answer: change the FIFO to a priority queue the priority of each element in the queue is its path cost.

Uniform Cost Search (UCS)

UCS Fringe A Path Cost 0 Explored set:

UCS Fringe A S T Z Path Cost 0 140 118 75 140 118 75 Explored set: A

UCS Fringe A S T Z T Path Cost 0 140 118 75 146 140 118 75 146 Explored set: A, Z

UCS Fringe A S T Z T L Path Cost 0 140 118 75 146 229 140 118 229 75 146 Explored set: A, Z, T

UCS Fringe A S T Z T L F R Path Cost 0 140 118 75 146 229 239 220 140 239 220 118 229 75 146 Explored set: A, Z, T, S

UCS Fringe A S T Z T L F R Path Cost 0 140 118 75 146 229 239 220 140 239 220 118 229 75 146 Explored set: A, Z, T, S

UCS Fringe A S T Z T L F R C P Path Cost 0 140 118 75 146 229 239 220 336 317 140 239 220 118 229 75 146 336 317 Explored set: A, Z, T, S, R

UCS Fringe A S T Z T L F R C P M Path Cost 0 140 118 75 146 229 239 220 336 317 299 140 239 220 336 317 118 229 299 75 146 Explored set: A, Z, T, S, R, L

UCS Fringe A S T Z T L F R C P M Path Cost 0 140 118 75 146 229 239 220 336 317 299 140 239 220 When does this end? 336 317 118 229 299 75 146 Explored set: A, Z, T, S, R, L

UCS Fringe A S T Z T L F R C P M Path Cost 0 140 118 75 146 229 239 220 336 317 299 140 336 317 118 239 When does 220 this end? 229 when the goal state is removed from the queue 299 75 146 Explored set: A, Z, T, S, R, L

UCS Fringe A S T Z T L F R C P M Path Cost 0 140 118 75 146 229 239 220 336 317 299 140 336 317 118 239 When does 220 this end? 229 when the goal state is removed from the queue NOT when the goal state is expanded 299 75 146 Explored set: A, Z, T, S, R, L

UCS

UCS Properties Is UCS complete? is it guaranteed to find a solution if one exists? What is the time complexity of UCS? how many states are expanded before finding a solution? b: branching factor C*: cost of optimal solution e: min one-step cost complexity = What is the space complexity of BFS? how much memory is required? complexity = Is BFS optimal? is it guaranteed to find the best solution (shortest path)?

UCS vs BFS Strategy: expand cheapest node first: Fringe is a priority queue (priority: cumulative cost) S 0 d 3 e 9 p 1 Cost contours b a 4 6 c a 11 h p e 13 q 5 r f 7 8 h p 17 r 11 q f q c G q 16 q 11 c G 10 a a

UCS vs BFS Strategy: expand a shallowest node first Implementa6on: Fringe is a FIFO queue S Search Tiers b d c e h e r p q a a h r p q f p q f q c G q c G a a

UCS vs BFS Remember: UCS explores increasing cost contours The good: UCS is complete and optimal! c1 c2 c3 The bad: Explores options in every direction No information about goal location Start Goal We ll fix that soon!

Depth First Search (DFS)

DFS Fringe A fringe

DFS Fringe A B C fringe

DFS Fringe A B C F G fringe

Fringe A B C F G H I DFS

DFS Fringe A B C F G H I Which state gets removed next from the fringe?

DFS Fringe A B C F G H I Which state gets removed next from the fringe? What kind of a queue is this?

DFS Fringe A B C F G H I Which state gets removed next from the fringe? What kind of a queue is this? LIFO Queue! (last in first out)

Deep/Shallow Water --- DFS, BFS, or UCS? (part 1)

Deep/Shallow Water --- DFS, BFS, or UCS? (part 2)

Deep/Shallow Water --- DFS, BFS, or UCS? (part 3)

DFS Properties: Graph search version This is the graph search version of the algorithm Is DFS complete? only if you track the explored set in memory What is the time complexity of DFS (graph version)? how many states are expanded before finding a solution? complexity = number of states in the graph What is the space complexity of DFS (graph version)? how much memory is required? complexity = number of states in the graph Is DFS optimal? is it guaranteed to find the best solution (shortest path)?

DFS Properties: Graph search version This is the graph search version of the algorithm Is DFS complete? only if you track the explored set in memory What is the time complexity of DFS (graph version)? how many states are expanded before finding a solution? complexity = number of states in the graph What is the space complexity of DFS (graph version)? how much memory is required? complexity = number of states in the graph Is DFS optimal? is it guaranteed to find the best solution (shortest path)? So why would we ever use this algorithm?

DFS: Tree search version This is the tree search version of the algorithm Suppose you don't track the explored set. why wouldn't you want to do that?

DFS: Tree search version This is the tree search version of the algorithm Suppose you don't track the explored set. why wouldn't you want to do that? What is the space complexity of DFS (tree version)? how much memory is required? b: branching factor m: maximum depth of any node complexity =

DFS: Tree search version This is the tree search version of the algorithm Suppose you don't track the explored set. why wouldn't you want to do that? What is the space complexity of DFS (tree version)? how much memory is required? b: branching factor m: maximum depth of any node complexity = This is why we might want to use DFS

DFS: Tree search version This is the tree search version of the algorithm Suppose you don't track the explored set. why wouldn't you want to do that? What is the space complexity of DFS (tree version)? how much memory is required? b: branching factor m: maximum depth of any node complexity = What is the time complexity of DFS (tree version)? how many states are expanded before finding a solution? complexity =

DFS: Tree search version This is the tree search version of the algorithm Suppose you don't track the explored set. why wouldn't you want to do that? What is the space complexity of DFS (tree version)? how much memory is required? b: branching factor m: maximum depth of any node complexity = What is the time complexity of DFS (tree version)? how many states are expanded before finding a solution? complexity = Is it complete?

DFS: Tree search version This is the tree search version of the algorithm Suppose you don't track the explored set. why wouldn't you want to do that? What is the space complexity of DFS (tree version)? how much memory is required? b: branching factor m: maximum depth of any node complexity = What is the time complexity of DFS (tree version)? how many states are expanded before finding a solution? complexity = Is it complete? NO!

DFS: Tree search version This is the tree search version of the algorithm Suppose you don't track the explored set. why wouldn't you want to do that? What is the space complexity of DFS (tree version)? how much memory is required? b: branching factor m: maximum depth of any node complexity = What is the time complexity of DFS (tree version)? how many states are expanded before finding a solution? complexity = Is it complete? NO! What do we do???

IDS: Iterative deepening search What is IDS? do depth-limited DFS in stages, increasing the maximum depth at each stage

IDS: Iterative deepening search What is IDS? do depth-limited DFS in stages, increasing the maximum depth at each stage What is depth limited search? any guesses?

IDS: Iterative deepening search What is IDS? do depth-limited DFS in stages, increasing the maximum depth at each stage What is depth limited search? do DFS up to a certain pre-specified depth

IDS: Iterative deepening search Idea: get DFS s space advantage with BFS s 6me / shallow-solu6on advantages Run a DFS with depth limit 1. If no solu6on Run a DFS with depth limit 2. If no solu6on Run a DFS with depth limit 3... Isn t that wastefully redundant? Generally most work happens in the lowest level searched, so not so bad!

IDS

IDS What is the space complexity of IDS (tree version)? how much memory is required? b: branching factor m: maximum depth of any node complexity = What is the time complexity of DFS (tree version)? how many states are expanded before finding a solution? complexity = Is it complete?

IDS What is the space complexity of IDS (tree version)? how much memory is required? b: branching factor m: maximum depth of any node complexity = What is the time complexity of DFS (tree version)? how many states are expanded before finding a solution? complexity = Is it complete? YES!!! Is it optimal?

IDS What is the space complexity of IDS (tree version)? how much memory is required? b: branching factor m: maximum depth of any node complexity = What is the time complexity of DFS (tree version)? how many states are expanded before finding a solution? complexity = Is it complete? YES!!! Is it optimal? YES!!!

The One Queue All these search algorithms are the same except for fringe strategies Conceptually, all fringes are priority queues (i.e. collec6ons of nodes with atached priori6es) Prac6cally, for DFS and BFS, you can avoid the log(n) overhead from an actual priority queue, by using stacks and queues Can even code one implementa6on that takes a variable queuing object

Search and Models Search operates over models of the world The agent doesn t actually try all the plans out in the real world! Planning is all in simula6on Your search is only as good as your models

Search Gone Wrong?