CSE 473: Artificial Intelligence Autumn 2018 Problem Spaces & - - PowerPoint PPT Presentation

cse 473 artificial intelligence
SMART_READER_LITE
LIVE PREVIEW

CSE 473: Artificial Intelligence Autumn 2018 Problem Spaces & - - PowerPoint PPT Presentation

CSE 473: Artificial Intelligence Autumn 2018 Problem Spaces & Search Steve Tanimoto With slides from : Dieter Fox, Dan Weld, Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Outline Search Problems Uninformed Search


slide-1
SLIDE 1

CSE 473: Artificial Intelligence

Autumn 2018

Problem Spaces & Search

Steve Tanimoto

With slides from : Dieter Fox, Dan Weld, Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer

slide-2
SLIDE 2

Outline

  • Search Problems
  • Uninformed Search Methods
  • Depth-First Search
  • Breadth-First Search
  • Uniform-Cost Search
  • Heuristic Search Methods
  • Best-First, Greedy Search
  • A*
slide-3
SLIDE 3

Agent vs. Environment

  • An agent is an entity that

perceives and acts.

  • A rational agent selects

actions that maximize its utility function.

  • Characteristics of the

percepts, environment, and action space dictate techniques for selecting rational actions.

Agent Sensors ? Actuators Environment

Percepts Actions

slide-4
SLIDE 4

Types of Agents

  • Reflex
  • Goal oriented
  • Utility-based

4

slide-5
SLIDE 5

Goal Based Agents

  • Plan ahead
  • Ask “what if”
  • Decisions based on

(hypothesized) consequences of actions

  • Must have a model of how

the world evolves in response to actions

  • Act on how the world

WOULD BE

slide-6
SLIDE 6

Types of Environments

  • Fully observable vs. partially observable
  • Single agent vs. multiagent
  • Deterministic vs. stochastic
  • Episodic vs. sequential
  • Discrete vs. continuous
slide-7
SLIDE 7

Search thru a

  • Set of states
  • Operators [and costs]
  • Start state
  • Goal state [test]
  • Path: start a state satisfying goal test

[May require shortest path] [Sometimes just need a state that passes test]

  • Input:
  • Output:

Problem Space (aka State Space) Problem Space (aka State Space)

slide-8
SLIDE 8

Example: Traveling in Romania

  • State space:
  • Cities
  • Successor function:
  • Roads: Go to adjacent city

with cost = distance

  • Start state:
  • Arad
  • Goal test:
  • Is state == Bucharest?
  • Solution?
slide-9
SLIDE 9

Example: Simplified Pac-Man

  • Input:
  • A state space
  • A successor function
  • A start state
  • A goal test
  • Output:

“N”, 1.0 “E”, 1.0

slide-10
SLIDE 10

State Space Sizes?

  • Search Problem:

Eat all of the food

  • Pacman positions:

10 x 12 = 120

  • Pacman facing:

up, down, left, right

  • Food configurations: 230
  • Ghost1 positions: 12
  • Ghost 2 positions: 11

10 x 12 = 120 up, down, left, right 230 12 11 120 x 4 x 230 x 12 x 11 = 6.8 x 1013

slide-11
SLIDE 11

State Space Graphs

  • State space graph:
  • Each node is a state
  • The successor function is

represented by arcs

  • Edges may be labeled with

costs

  • In a search graph, each state
  • ccurs only once!
  • We can rarely build this graph

in memory (so we don’t)

S

G d b p q c e h a f r Ridiculously tiny search graph for a tiny search problem

slide-12
SLIDE 12

Search Trees

  • A search tree:
  • Start state at the root node
  • Children correspond to successors
  • Nodes contain states, correspond to PLANS to those states
  • Edges are labeled with actions and costs
  • For most problems, we can never actually build the whole tree

“E”, 1.0 “N”, 1.0

This is now / start Possible futures

slide-13
SLIDE 13

State Space Graphs vs. Search Trees

S

a b d p a c e p h f r q q c

G

a q e p h f r q q c G a

S G

d b p q c e h a f r

We construct both on demand – and we construct as little as possible. Each NODE in in the search tree is an entire PATH in the state space graph.

Search Tree State Space Graph

slide-14
SLIDE 14

State Space Graphs vs. Search Trees

S

G b a

Consider this 4-state graph:

Important: Lots of repeated structure in the search tree!

How big is its search tree (from S)?

slide-15
SLIDE 15

Tree Search

slide-16
SLIDE 16

Search Example: Romania

slide-17
SLIDE 17

Searching with a Search Tree

  • Search:
  • Expand out potential plans (tree nodes)
  • Maintain a fringe of partial plans under

consideration

  • Try to expand as few tree nodes as possible
slide-18
SLIDE 18

General Tree Search

  • Important ideas:
  • Fringe
  • Expansion
  • Exploration strategy
  • Main question: which fringe nodes to explore?
slide-19
SLIDE 19

Tree Search Example

S G

d b p q c e h a f r

slide-20
SLIDE 20

Depth-First Search

slide-21
SLIDE 21

Depth-First Search

Strategy: expand a deepest node first Implementation: Fringe is a LIFO stack S G

d b p q c e h a f r

slide-22
SLIDE 22

Depth-First Search

S

a b d p a c e p h f r q q c

G

a q e p h f r q q c

G

a S G

d b p q c e h a f r q p h f d b a c e r

Strategy: expand a deepest node first Implementation: Fringe is a LIFO stack

slide-23
SLIDE 23

Search Algorithm Properties

slide-24
SLIDE 24

Search Algorithm Properties

  • Complete: Guaranteed to find a solution if one exists?
  • Optimal: Guaranteed to find the least cost path?
  • Time complexity?
  • Space complexity?
  • Cartoon of search tree:
  • b is the branching factor
  • m is the maximum depth
  • solutions at various depths
  • Number of nodes in entire tree?
  • 1 + b + b2 + …. bm = O(bm)

… b 1 node b nodes b2 nodes bm nodes m tiers

slide-25
SLIDE 25

Depth-First Search (DFS) Properties

… b 1 node b nodes b2 nodes bm nodes m tiers

  • What nodes does DFS expand?
  • Some left prefix of the tree.
  • Could process the whole tree!
  • If m is finite, takes time O(bm)
  • How much space does the fringe take?
  • Only has siblings on path to root, so O(bm)
  • Is it complete?
  • m could be infinite, so only if we prevent cycles
  • Is it optimal?
  • No, it finds the “leftmost” solution, regardless of

depth or cost

slide-26
SLIDE 26

Breadth-First Search

slide-27
SLIDE 27

Breadth-First Search

S

a b d p a c e p h f r q q c

G

a q e p h f r q q c

G

a

S

G d b p q c e h a f r Search Tiers Strategy: expand a shallowest node first Implementation: Fringe is a FIFO queue

slide-28
SLIDE 28

Breadth-First Search (BFS) Properties

  • What nodes does BFS expand?
  • Processes all nodes above shallowest solution
  • Let depth of shallowest solution be d
  • Search takes time O(bd)
  • How much space does the fringe take?
  • Has roughly the last tier, so O(bd)
  • Is it complete?
  • d must be finite if a solution exists, so yes!
  • Is it optimal?
  • Only if costs are all 1 (more on costs later)

… b 1 node b nodes b2 nodes bm nodes d tiers bd nodes

slide-29
SLIDE 29

DFS vs BFS

Algorithm Complete Optimal Time Space DFS

w/ Path Checking

BFS N unless

finite

N O(bm) O(bm) Y Y O(bd) O(bd)

slide-30
SLIDE 30

Memory a Limitation?

  • Suppose:
  • 4 GHz CPU
  • 32 GB main memory
  • 100 instructions / expansion
  • 5 bytes / node
  • 40 M expansions / sec
  • Memory filled in 160 sec … 3 min
slide-31
SLIDE 31

Iterative Deepening

Iterative deepening uses DFS as a subroutine:

  • 1. Do a DFS which only searches for paths of

length 1 or less.

  • 2. If “1” failed, do a DFS which only searches paths
  • f length 2 or less.
  • 3. If “2” failed, do a DFS which only searches paths
  • f length 3 or less.

….and so on.

Algorithm Complete Optimal Time Space DFS

w/ Path Checking

BFS ID Y N O(bm) O(bm) Y Y O(bd) O(bd) Y Y O(bd) O(bd)

… b

slide-32
SLIDE 32

BFS vs. Iterative Deepening

  • For b = 10, d = 5:
  • BFS = 1 + 10 + 100 + 1,000 + 10,000 + 100,000 =

111,111

  • IDS = 6 + 50 + 400 + 3,000 + 20,000 + 100,000 =

123,456

  • Overhead = (123,456 - 111,111) / 111,111 = 11%
  • Memory BFS: 100,000; IDS: 50

32

slide-33
SLIDE 33

Costs on Actions

Notice that BFS finds the shortest path in terms of number of

  • transitions. It does not find the least-cost path.

START

GOAL

d b p q c e h a f r 2 9 2 8 1 8 2 3 1 4 4 15 1 3 2 2

slide-34
SLIDE 34

Uniform Cost Search

START

GOAL

d b p q c e h a f r 2 9 2 8 1 8 2 3 1 4 4 15 1 3 2 2

Expand cheapest node first: Fringe is a priority queue

slide-35
SLIDE 35

Uniform Cost Search

S

a b d p a c e p h f r q q c

G

a q e p h f r q q c

G

a Strategy: expand a cheapest node first: Fringe is a priority queue (priority: cumulative cost) S G

d b p q c e h a f r

3 9 1 16 4 11 5 7 13 8 10 11 17 11 6 3 9 1 1 2 8 8 2 15 1 2 Cost contours 2

slide-36
SLIDE 36

Uniform Cost Search (UCS) Properties

  • What nodes does UCS expand?
  • Processes all nodes with cost less than cheapest solution!
  • If that solution costs C* and arcs cost at least ε , then the “effective

depth” is roughly C*/ε

  • Takes time O(bC*/ε) (exponential in effective depth)
  • How much space does the fringe take?
  • Has roughly the last tier, so O(bC*/ε)
  • Is it complete?
  • Assuming best solution has a finite cost and minimum arc cost is

positive, yes!

  • Is it optimal?
  • Yes!

b C*/ε “tiers” C ≤ 3 C ≤ 2 C ≤ 1

slide-37
SLIDE 37

Uniform Cost Search

  • Strategy: expand lowest

path cost

  • The good: UCS is

complete and optimal!

  • The bad:
  • Explores options in every

“direction”

  • No information about goal

location

Start Goal … c  3 c  2 c  1

slide-38
SLIDE 38

Uniform Cost Search

Algorithm Complete Optimal Time Space DFS

w/ Path Checking

BFS UCS Y N O(bm) O(bm) Y Y O(bd) O(bd) Y* Y O(bC*/ε) O(bC*/ε)

… b

C*/ε tiers

slide-39
SLIDE 39

Uniform Cost: Pac-Man

  • Cost of 1 for each action
  • Explores all of the states, but one
slide-40
SLIDE 40

The One Queue

  • All these search algorithms

are the same except for fringe strategies

  • Conceptually, all fringes are

priority queues (i.e. collections

  • f nodes with attached

priorities)

  • Practically, for DFS and BFS,

you can avoid the log(n)

  • verhead from an actual

priority queue, by using stacks and queues

  • Can even code one

implementation that takes a variable queuing object

slide-41
SLIDE 41

To Do:

  • Look at the course website:
  • http://http://courses.cs.washington.edu/courses/cse473/18au/
  • Do the readings (Ch 3)
  • Do Project 0, especially if new to Python
  • Start Project 1.