1 artificial intelligence cs 165a thursday, october 4, 2007 intelligent agents (ch. 2) blind...

33
1 Artificial Intelligence CS 165A Thursday, October 4, 2007 Intelligent agents (Ch. 2) Blind search (Ch. 3) 1

Upload: molly-lawson

Post on 05-Jan-2016

219 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

1

Artificial Intelligence

CS 165A

Thursday, October 4, 2007

Intelligent agents (Ch. 2) Blind search (Ch. 3)

1

Page 2: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

2

Notes

• New room!

Page 3: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

3

Review

• What is an agent?– An entity capable of combining cognition, perception and action in

behaving autonomously, purposively and flexibly in some environment

• What does an agent do?– An agent perceives its environment, reasons about its goals, and

acts upon the environment

• What does PEAS stand for (description of an agent)?– Performance measure, Environment, Actuators, Sensors

• What are we about to do right now?

Page 4: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

4

Thursday Quiz #1

Write your name, your perm #, and the date at the top of the page

1. Humans often solve NP-complete problems in times much shorter than the complexity limits. Does McCarthy consider this evidence that computers are intrinsically incapable of doing what people do?

2. Why or why not?

Page 5: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

5

Generic Agent Program

• Implementing f : P* A …or… f (P*) = A – Lookup table?

– Learning?

Knowledge, past percepts, past actions

Add percept to percepts

LUT [percepts, table]

NOP

Table-Driven-Agent

e.g.,

Page 6: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

6

Basic types of agent programs

• Simple reflex agent

• Model-based reflex agent

• Goal-based agent

• Utility-based agent

• Learning agent

Page 7: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

7

Simple Reflex Agent

• Input/output associations

• Condition-action rule: “If-then” rule (production rule)– If condition then action (if in a certain state, do this)– If antecedent then consequent

Page 8: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

8

Simple Reflex Agent

• Simple state-based agent – Classify the current percept into a known state, then apply the rule for that state

Page 9: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

9

Model-Based Reflex Agent

• Internal state – keeps track of the world, models the world

Page 10: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

10

Model-Based Reflex Agent

• State-based agent – Given the current state, classify the current percept into a known state, then apply the rule for that state

Page 11: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

11

Goal-Based Agent

• Goal: immediate, or long sequence of actions?– Search and planning – finding action sequences that achieve the agent’s

goals

Page 12: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

12

Utility-Based Agent

• “There are many ways to skin a cat”

• Utility function: Specifies degree of usefulness (happiness)

– Maps a state onto a real number cost

1U

Page 13: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

13

Learning Agent

Page 14: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

14

Environments

• Properties of environments– Fully vs. partially observable

– Deterministic vs. stochastic

– Episodic vs. sequential

– Friendly vs. hostile

– Static vs. dynamic

– Discrete vs. continuous

– Single agent vs. multiagent

• The environment types largely determine the agent design

• The real world is inaccessible, stochastic, nonepisodic, hostile, dynamic, and continuous– Bummer…

Page 15: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

15

Problem Solving and Search

Chapter 3

Page 16: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

16

Problem Solving Agents

• Task: Find a sequence of actions that leads to desirable (goal) states– Must define problem and solution

• Finding a solution is typically a search process in the problem space– Solution = A path through the state space from the initial state to a

goal state

– Optimal search find the least-cost solution

• Search algorithm– Input: Problem statement (incl. goal)

– Output: Sequence of actions that leads to a solution

• Formulate, search, execute (action)

Page 17: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

17

Search Strategies

• Uninformed (blind) search (Chap. 3)– Can only distinguish goal state from non-goal state

• Informed (heuristic) search (Chap. 4)– Can evaluate states

Page 18: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

18

Problem Formulation and Search

• Problem formulation– State-space description < {S}, S0, {SG}, {O}, {g} >

S: Possible states S0: Initial state of the agent

SG: Goal state(s)

– Or equivalently, a goal test G(S) O: Operators O: {S} => {S}

– Describes the possible actions of the agent g: Path cost function, assigns a cost to a path/action

• At any given time, which possible action Oi is best?

– Depends on the goal, the path cost function, the future sequence of actions….

• Agent’s strategy: Formulate, Search, and Execute– This is offline (or batch) problem solving

Page 19: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

19

Typical assumptions for simple PS agent

• Environment is observable

• Environment is static

• Environment is discrete

• Environment is deterministic

Page 20: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

20

State-Space Diagrams

• State-space description can be represented by a state-space diagram, which shows– States (incl. initial and goal)

– Operators/actions (state transitions)

– Path costs

Page 21: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

21

Example: Romania

You’re in Arad, Romania, and you need to get to Bucharest as quickly as possible to catch your flight.

• Formulate problem– States: Various cities

– Operators: Drive between cities

• Formulate goal– Be in Bucharest before flight leaves

• Find solution– Actual sequence of cities from Arad to Bucharest

– Minimize driving distance/time

Page 22: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

22

Romania (cont.)

Page 23: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

23

Romania (cont.)

Problem description <{S}, S0, {SG}, {O}, {g}>

• {S} – cities (ci)

• S0 – Arad

• SG – Bucharest– G(S) – Is the current state (S) Bucharest?

• {O}: { ci cj, for some i and j }

• gij

– Driving distance between ci and cj?

– Time to drive from ci to cj?

– 1?

Page 24: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

24

Possible paths

Sibiu

Oradea

Zerind

Bucharest

PitestiBucharest

Fagaras R. Vilcea

Sibiu

Dobreta

Mehadia

Lugoj

Timisoara

Arad

Which is best?

Page 25: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

25

Branching Factor

• If there are N possible choices at each state, then the branching factor is N

• If it takes M steps (state transitions) to get to the goal state, then it may be the case that O(NM) states have to be checked– N = 3, M = 5 NM = 243

– N = 5, M = 10 NM = 9,765,625

– N = 8, M = 15 NM = 35,184,372,088,832

• Ouch…. Combinatorial explosion!

Page 26: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

26

Abstraction

• The real world is highly complex!– The state space must be abstracted for problem-solving

Simplify and aggregate

– Can’t represent all the details

• Choosing a good abstraction– Remove as much detail as possible while retaining validity

Page 27: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

27

Example Problem: 8-Puzzle

States: Various configurations of the puzzleOperators: Movements of the blankGoal test: State matches goal statePath cost: Each move costs 1

How many states are there?

9! = 362,880

Page 28: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

28

One way to represent the stateAction State====== ===== 091150500 > 086898972 ^ 110781012 ^ 110826876 > 110826300 V 110590428 V 024615084 < 215933844 ^ 249368700 < 249403692 V 248872980 > 219112284 ^ 247770732 ^ 247823148 < 247823172 V 247822444 > 247775788 > 247670812 ^ 247906684 < 247906900 V 247893796

Goal State:

1*9^0 + 2*9^1 + 3*9^2

+ 8*9^3 + 0*9^4 + 4*9^5

+ 7*9^6 + 6*9^7 + 5*9^8

= 247893796

Start State:

5*9^0 + 4*9^1 + 0*9^2

+ 6*9^3 + 1*9^4 + 8*9^5

+ 7*9^6 + 3*9^7 + 2*9^8

= 104645804

Page 29: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

29

8-Puzzle is hard (by definition)!

• Optimal solution of the N-puzzle family of problems is NP-complete– Exponential increase in computation with N

– Uninformed search will do very poorly

• Ditto for the Traveling Salesman Problem (TSP)– Start and end in Bucharest, visit every city at least once

– Find the shortest tour

• Ditto for lots of interesting problems!

Page 30: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

30

Example: MU-Puzzle

• States: Strings comprising the letters M, I, and U

• Initial state: MI

• Goal state: MU

• Operators: (where x stands for any string, including the null string)1. x I x IU “Append U”2. M x M x x “Replicate x”3. xI I Ix xUx “Replace with U”4. xUUx xx “Drop UU”Each rule describes the whole string, not a subset

• Path cost: one per step

• Try it– Can you draw the state-space diagram?– Are you guaranteed a solution?

M I

M I I

M I I I I

M U I

M U I U

M U I U U I U

M U I U U I U U I U U I U

M U I I I I U

M U U I U

M I U

M I

M I I

M I I I I

M U I

M U I U

M U I U U I U

M U I U U I U U I U U I U

M U I I I I U

M U U I U

M I U

Page 31: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

31

• Clarification of the MU-puzzle rules:1. If the string ends with I you may add U; for example, MI

becomes MIU

2. If the string is Mx then you may create Mxx; for example, MI becomes MII; MIU becomes MIUIU

3. If the string contains III you may replace those three characters with U

4. If the string contains UU you may eliminate both characters

Page 32: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

32

Example: The Vacuum World

• Simplified world: 2 grids

States: Location of vacuum, dirt in grids

Operators: Move left, move right, suck dirt

Goal test: Grids free of dirt

Path cost: Each action costs 1

Page 33: 1 Artificial Intelligence CS 165A Thursday, October 4, 2007  Intelligent agents (Ch. 2)  Blind search (Ch. 3) 1

33

The Vacuum World (cont.)

• How to reach the goal?– If starting at top left state: S, R, S

– If starting at middle far right state: L, S

• What if agent doesn’t know its initial state?– You probably need to redraw the state diagram!

– Represent initial uncertainty as one “meta-state” For example…