43
Uninformed Search ECE457 Applied Artificial Intelligence Spring 2008 Lecture #2

Uninformed Search

  • Upload
    regis

  • View
    41

  • Download
    5

Embed Size (px)

DESCRIPTION

Uninformed Search. ECE457 Applied Artificial Intelligence Spring 2008 Lecture #2. Outline. Problem-solving by searching Uninformed search techniques Russell & Norvig, chapter 3. Problem-solving by searching. An agent needs to perform actions to get from its current state to a goal . - PowerPoint PPT Presentation

Citation preview

Page 1: Uninformed Search

Uninformed Search

ECE457 Applied Artificial IntelligenceSpring 2008Lecture #2

Page 2: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 2

Outline Problem-solving by searching Uninformed search techniques

Russell & Norvig, chapter 3

Page 3: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 3

Problem-solving by searching An agent needs to perform actions

to get from its current state to a goal.

This process is called searching. Central in many AI systems

Theorem proving, VLSI layout, game playing, navigation, scheduling, etc.

Page 4: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 4

Requirements for searching Define the problem

Represent the search space by states Define the actions the agent can

perform and their cost Define a goal

What is the agent searching for? Define the solution

The goal itself? The path (i.e. sequence of actions) to

get to the goal?

Page 5: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 5

Assumptions Goal-based agent Environment

Fully observable Deterministic Sequential Static Discrete Single agent

Page 6: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 6

Formulating problems A well-defined problem has:

An initial state A set of actions A goal test A concept of cost

Page 7: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 7

Well-Defined Problem Example Initial state Action

Move blank left, right, up or down, provided it does not get out of the game

Goal test Are the tiles in the “goal

state” order? Cost

Each move costs 1 Path cost is the sum of

moves

Page 8: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 8

Well-Defined Problem Example

Travelling salesman problem Find the shortest round trip to

visit each city exactly once Initial state

Any city Set of actions

Move to an unvisited city Goal test

Is the agent in the initial city after having visited every city?

Concept of cost Action cost: distance between

cities Path cost: total distance

travelled

Page 9: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 9

Example: 8-puzzle

left down

leftright

down downleftup

Page 10: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 10

Search TreeParent

Child

Edge (action)

Node (state)

Expanding a node

Root

Leaf

Fringe

Branching factor (b)

Maximum depth (m)

Page 11: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 11

Properties of Search Algos. Completeness

Is the algorithm guaranteed to find a goal node, if one exists?

Optimality Is the algorithm guaranteed to find the best

goal node, i.e. the one with the cheapest path cost?

Time complexity How many nodes are generated?

Space complexity What’s the maximum number of nodes

stored in memory?

Page 12: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 12

Types of Search Uninformed Search

Only has the information provided by the problem formulation (initial state, set of actions, goal test, cost)

Informed Search Has additional information that allows

it to judge the promise of an action, i.e. the estimated cost from a state to a goal

Page 13: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 13

Breath-First Search

Page 14: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 14

Breath-First Search Complete, if b is finite Optimal, if path cost is equal to

depth Guaranteed to return the shallowest

goal (depth d) Time complexity = O(bd+1) Space complexity = O(bd+1)

Page 15: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 15

Breath-First Search Upper-bound case: goal is last node of depth d

Number of generated nodes:b+b²+b³+…+bd+(bd+1-b) = O(bd+1)

Space & time complexity: all generated nodes

Page 16: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 16

Uniform-Cost Search Expansion of Breath-First Search Explore the cheapest node first (in

terms of path cost) Condition: No zero-cost or

negative-cost edges. Minimum cost is є

Breath-First Search is Uniform-Cost Search with constant-cost edges

Page 17: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 17

Uniform-Cost Search Complete given a finite tree Optimal Time complexity = O(bC*/є+1) ≥

O(bd+1) Space complexity = O(bC*/є+1) ≥

O(bd+1)

Page 18: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 18

Uniform-Cost Search Upper-bound case: goal has path cost C*, all other

actions have minimum cost of є Depth explored before taking action C*: C*/є Depth of fringe nodes: C*/є + 1 Space & time complexity: all generated nodes: O(bC*/є+1)

C* є

є є

є є

є є є є

є є

є є є є

Page 19: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 19

Depth-First Search

Page 20: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 20

Depth-First Search Complete, if m is finite Not optimal Time complexity = O(bm) Space complexity = bm+1 =

O(bm) Can be reduced to O(m) with

recursive algorithm

Page 21: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 21

Depth-First Search Upper-bound case for space: goal is last node of

first branch After that, we start deleting nodes Number of generated nodes: b nodes at each of m levels Space complexity: all generated nodes = O(bm)

Page 22: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 22

Depth-First Search Upper-bound case for time: goal is last node of

last branch Number of nodes generated:

b nodes for each node of m levels (entire tree) Time complexity: all generated nodes O(bm)

Page 23: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 23

Depth-Limited Search Depth-First Search with depth limit

l Avoids problems of Depth-First

Search when trees are unbounded Depth-First Search is Depth-

Limited Search with l =

Page 24: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 24

Depth-Limited Search Complete, if l > d Not optimal Time complexity = O(bl) Space complexity = O(bl)

Page 25: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 25

Depth-Limited Search Upper-bound case for space: goal is last node of

first branch After that, we start deleting nodes Number of generated nodes: b nodes at each of l levels Space complexity: all generated nodes = O(bl)

Page 26: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 26

Depth-Limited Search Upper-bound case for time: goal is last node of

last branch Number of nodes generated:

b nodes for each node of l levels (entire tree to depth l) Time complexity: all generated nodes O(bl)

Page 27: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 27

Iterative Deepening Search Depth-First Search with increasing

depth limit l Repeat depth-limited search over and

over, with l = l + 1 Avoids problems of Depth-First

Search when trees are unbounded Avoids problem of Depth-Limited

Search when goal depth d > l

Page 28: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 28

Iterative Deepening Search Complete , if b is finite Optimal, if path cost is equal to

depth Guaranteed to return the shallowest

goal Time complexity = O(bd) Space complexity = O(bd) Nodes on levels above d are

generated multiple times

Page 29: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 29

Iterative Deepening Search Upper-bound case for space: goal is last node of

first branch After that, we start deleting nodes Number of generated nodes: b nodes at each of d levels Space complexity: all generated nodes = O(bd)

Page 30: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 30

Iterative Deepening Search Upper-bound case for time: goal is last node of

last branch Number of nodes generated:

b nodes for each node of d levels (entire tree to depth d)

Time complexity: all generated nodes O(bd)

Page 31: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 31

Depth Searches

Depth-first search

Depth-limited search

Iterative deepening search

Depth limit

m l d

Time complexity

O(bm) O(bl) O(bd)

Space complexity

O(bm) O(bl) O(bd)

Page 32: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 32

Summary of Searches

Breath-first

Uniform Cost

Depth-first

Depth-limited

Iterative deepening

Complete

Yes1 Yes1 No4 No5 Yes1

Optimal Yes2 Yes3 No No Yes2

TimeO(bd+1

)O(bC*/є+1) O(bm) O(bl) O(bd)

SpaceO(bd+1

)O(bC*/є+1)

O(bm)

O(bl) O(bd)

1: Assuming b finite (common in trees)2: Assuming equal action costs3: Assuming all costs є

4: Unless m finite (uncommon in trees)5: Unless l precisely selected

Page 33: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 33

Summary / Example Going from Arad to Bucharest

Page 34: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 34

Summary / Example Initial state

Being in Arad Action

Move to a neighbouring city, if a road exists.

Goal test Are we in Bucharest?

Cost Move cost = distance between cities Path cost = distance travelled since

Arad

Page 35: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 35

Summary / Example Breath-First Search

Page 36: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 36

Summary / Example Uniform-Cost Search

Arad 0Arad 0Zerind 75Sibiu 140 Timisoara 118

Arad 0Zerind 75Sibiu 140Timisoara 118Oradea 146

Arad 0Zerind 75Sibiu 140Timisoara 118Oradea 146Lugoj 229

Arad 0Zerind 75Sibiu 140Timisoara 118Oradea 146Lugoj 229Fagaras 239Rimnicu 220

Arad 0Zerind 75Sibiu 140Timisoara 118Oradea 146Lugoj 229Fagaras 239Rimnicu 220

Arad 0Zerind 75Sibiu 140Timisoara 118Oradea 146Lugoj 229Fagaras 239Rimnicu 220Craiova 366Pietsti 317

Arad 0Zerind 75Sibiu 140Timisoara 118Oradea 146Lugoj 229Fagaras 239Rimnicu 220Craiova 366Pietsti 317Mehadia 299

Arad 0Zerind 75Sibiu 140Timisoara 118Oradea 146Lugoj 229Fagaras 239Rimnicu 220Craiova 366Pietsti 317Mehadia 299Bucharest 450

Arad 0Zerind 75Sibiu 140Timisoara 118Oradea 146Lugoj 229Fagaras 239Rimnicu 220Craiova 366Pietsti 317Mehadia 299Bucharest 450Dobreta 374

Arad 0Zerind 75Sibiu 140Timisoara 118Oradea 146Lugoj 229Fagaras 239Rimnicu 220Craiova 366Pietsti 317Mehadia 299Bucharest 418Dobreta 374

Arad 0Zerind 75Sibiu 140Timisoara 118Oradea 146Lugoj 229Fagaras 239Rimnicu 220Craiova 366Pietsti 317Mehadia 299Bucharest 418Dobreta 374

Arad 0Zerind 75Sibiu 140Timisoara 118Oradea 146Lugoj 229Fagaras 239Rimnicu 220Craiova 366Pietsti 317Mehadia 299Bucharest 418Dobreta 374

Arad 0Zerind 75Sibiu 140Timisoara 118Oradea 146Lugoj 229Fagaras 239Rimnicu 220Craiova 366Pietsti 317Mehadia 299Bucharest 418Dobreta 374

Page 37: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 37

Summary / Example Depth-First Search

Page 38: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 38

Summary / Example Depth-Limited Search, l = 4

Page 39: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 39

Summary / Example Iterative Deepening Search

Page 40: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 40

Repeated States

left down

leftright

down downleftup

Example: 8-puzzle

Page 41: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 41

Repeated States Unavoidable in problems where

Actions are reversible Multiple paths to the same state are

possible Can greatly increase the number of

nodes in a tree Or even make a finite tree infinite!

Page 42: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 42

Repeated States Each state

generates a single child twice

26 different states

225 leaves (i.e. state Z)

Over 67M nodes in the tree

A

B

C

D

E

A

B B

C C C C

D D D D D D D D

EEEEEEEE EEEEEEEE

Page 43: Uninformed Search

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 43

Repeated States Maintain a closed list of visited

states Closed list (for expanded nodes) vs.

open list (for fringe nodes) Detect and discard repeated states

upon generation Increases space complexity