Artificial Intelligence CS 165A Thursday, October 4, 2007 Intelligent agents (Ch. 2) Blind search (Ch.
Download ReportTranscript Artificial Intelligence CS 165A Thursday, October 4, 2007 Intelligent agents (Ch. 2) Blind search (Ch.
Artificial Intelligence
CS 165A Thursday, October 4, 2007 Intelligent agents (Ch. 2) Blind search (Ch. 3)
Notes
• New room!
2
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?
3
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?
4
Generic Agent Program • Implementing
f : P*
A
– Lookup table?
– Learning?
…or…
f (P*) = A
Knowledge, past percepts, past actions e.g.,
Table-Driven-Agent
Add
percept
to percepts LUT [percepts, table] NOP 5
Basic types of agent programs
• Simple reflex agent • Model-based reflex agent • Goal-based agent • Utility-based agent • Learning agent 6
Simple Reflex Agent
• Input/output associations • Condition-action rule: “If-then” rule (
production rule
) – If
condition
– If
antecedent
then
action
then (if in a certain state, do this)
consequent
7
Simple Reflex Agent
• Simple state-based agent – Classify the current percept into a known state, then apply the rule for that state 8
Model-Based Reflex Agent
• Internal state – keeps track of the world, models the world 9
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 10
Goal-Based Agent
• Goal: immediate, or long sequence of actions?
– Search and planning – finding action sequences that achieve the agent’s goals 11
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
U
1
Learning Agent
13
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… 14
Problem Solving and Search
Chapter 3 15
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) 16
Search Strategies
• Uninformed (blind) search (Chap. 3) – Can only distinguish goal state from non-goal state • Informed (heuristic) search (Chap. 4) – Can evaluate states 17
Problem Formulation and Search
• Problem formulation – State-space description
< {S}, S 0 , {S G }, {O}, {g} >
S
: Possible states
S 0
: Initial state of the agent
S G
: 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
O i
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 18
Typical assumptions for simple PS agent
• Environment is observable • Environment is static • Environment is discrete • Environment is deterministic 19
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 20
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 21
Romania (cont.)
22
Romania (cont.)
• • • Problem description
<{S}, S 0 , {S G }, {O}, {g}> {S} –
cities (c i )
S 0 –
Arad
S G –
Bucharest – G(S) – Is the current state (S) Bucharest?
• • {O}: { c i c j , for some
i
and
j
}
g ij
– Driving distance between c – Time to drive from c i – 1?
to c j ?
i and c j ?
23
Possible paths
Zerind Oradea Sibiu Arad Sibiu Fagaras Bucharest R. Vilcea Pitesti Bucharest
Which is best?
Timisoara Lugoj Mehadia Dobreta 24
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(
N M )
states have to be checked – – –
N
= 3,
M N N
= 5, = 8,
M M
= 5 = 10
N M N M =
243
=
9,765,625 = 15
N M =
35,184,372,088,832 • Ouch…. Combinatorial explosion!
25
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
26
Example Problem: 8-Puzzle
States:
Various configurations of the puzzle
Operators:
Movements of the blank
Goal test:
State matches goal state
Path cost:
Each move costs 1 How many states are there?
9! = 362,880 27
One way to represent the state
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
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 Action 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
28
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!
29
Example: MU-Puzzle
• • • • • • States: Strings comprising the letters M, I, and U Initial state: MI Goal state: MU Operators: (where
x
1.
2.
3.
4.
x
I
x
IU M
x x
I I I
x
M
x x x
U
x x
UU
x
xx
Try it stands for any string,
including the null string
) “Append U”
“
Replicate
x
” “Replace with U” “Drop UU” Each rule describes the whole string, not a subset Path cost: one per step – 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 … 30
• 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 31
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 32
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… 33