agents and uninformed search ece457 applied artificial intelligence spring 2007 lecture #2.5

39
Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

Upload: opal-gaines

Post on 17-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

Agents and Uninformed Search

ECE457 Applied Artificial IntelligenceSpring 2007 Lecture #2.5

Page 2: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Rational Agents Simple reflex

agent Model-based

agent Goal-based

agent Utility-based

agent Learning agent

Environment

Perce

pts A

ction

s

Sensors

Actuators

Agent Progra

m

Page 3: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Simple Reflex Agent

EnvironmentPercepts

Actions

Sensors

Actuators

Selected

Action

Current State

If-then Rules

Page 4: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Simple Reflex Agent Dune II (1992) units were

simple reflex agents Harvester rules:

IF at refinery AND not empty THEN empty

IF at refinery AND empty THEN go harvest

IF harvesting AND not full THEN continue harvesting

IF harvesting AND full THEN go to refinery

IF under attack by infantry THEN squash them

Page 5: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Model-Based Agent

EnvironmentPercepts

Actions

Sensors

Actuators

Selected

Action

Current State

Previous perceptio

nsImpact of actions

World changes

If-then Rules

Page 6: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Goal-Based Agent

EnvironmentPercepts

Actions

Sensors

Actuators

Selected

Action

Current State

GoalPrevious perceptio

nsImpact of actions

World changes

State if I do action

X

Page 7: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Utility-Based Agent

EnvironmentPercepts

Actions

Sensors

Actuators

Selected

Action

Current State

UtilityPrevious perceptio

nsImpact of actions

World changes

State if I do action

X

Happiness in that state

Page 8: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Learning Agent

EnvironmentPercepts

Actions

Sensors

Actuators

Problem Generat

or

Learning

Element

Feedback

Performance standard

ChangesKnowledge

Learning Goals

Performance Element

Critic

Page 9: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Properties of the Environment Fully observable vs. partially observable

See everything vs. hidden information Deterministic vs. stochastic vs. strategic

Controlled by agent vs. randomness vs. multiagents

Episodic vs. sequential Independent episodes vs. series of events

Static vs. dynamic vs. semi-dynamic Waits for agent vs. goes on without agent vs.

timer Discrete vs. continuous

Finite distinct states vs. uninterrupted sequence Single agent vs. cooperative vs. competitive

Alone vs. team-mates vs. opponents

Page 10: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Crossword Puzzle Fully observable, deterministic, sequential,

static, discrete, single-agent Monopoly

Fully observable, stochastic, sequential, static, discrete, competitive multi-agent

Driving a car Partially observable, stochastic, sequential,

dynamic, continuous, cooperative multi-agent Assembly-line inspection robot

Fully observable, deterministic, episodic, dynamic, continuous, single-agent

Properties of the Environment

Fully observable, deterministic, sequential, static, discrete, single-agent

Fully observable, stochastic, sequential, static, discrete, competitive multi-agent

Fully observable, deterministic, episodic, dynamic, continuous, single-agent

Partially observable, stochastic, sequential, dynamic, continuous, cooperative multi-agent

Page 11: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Well-Defined Problems Initial state Set of actions

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? Concept of cost

Each action costs 1 Path cost is the sum of

actions

Page 12: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Well-Defined Problems Travelling salesman problem

Find the shortest round trip to visit each city exactly once

Initial state

Set of actions

Goal test

Concept of cost

Any city

Move to an unvisited city

Am I in the initial city after having visited every city?

Action cost: distance between citiesPath cost: total distance travelled

Page 13: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

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 14: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Breath-First Search Explores each node of each level in

order Complete if b finite & optimal if cost

constant

Page 15: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Breath-First Search Worst 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: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Uniform-Cost Search Explore the node with the

cheapest path cost first Condition: No zero-cost or

negative-cost edges. Minimum cost of an action is є

Complete and optimal

Page 17: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

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

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

C* є

є є

є є

є є є є

є є

є є є є

Page 18: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Depth-First Search Explores an entire branch first

Removes branch from memory after exploration Complete if m finite & not optimal

Page 19: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Depth-First Search Worst 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 20: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Depth-First Search Worst 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 21: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

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 = Complete, if l > d Not optimal

Page 22: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Depth-Limited Search Worst 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 23: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Depth-Limited Search Worst 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 24: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

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 Complete , if b is finite Optimal, if path cost is equal to depth

Guaranteed to return the shallowest goal

Page 25: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Depth-Limited Search Worst 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 26: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Depth-Limited Search Worst 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 27: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

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 28: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

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

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

Space O(bd+1) O(bC*/є)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 29: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Summary / Example Going from Arad to Bucharest

Page 30: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

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 31: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Summary / Example Breath-First Search

Page 32: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Summary / Example Uniform-Cost Search

Page 33: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Summary / Example Depth-First Search

Page 34: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Summary / Example Depth-Limited Search, l = 4

Page 35: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Summary / Example Iterative Deepening Search

Page 36: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

Repeated States

left down

leftright

down downleftup

Example: 8-puzzle

Page 37: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

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 38: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

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 39: Agents and Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.5

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

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