Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Search
Lectured by
Abdenour Hadid
Associate Professor, CMVS, University of Oulu
Environment
Sensors
Percepts
Agent
Actuators
Actions
An agent is an entity that perceives the environments and acts to maximize its (expected)
utility
The goal of the course is to learn how to design rational agents
Environment
Sensors
Percepts
Agent
Actuators
Actions
An agent is an entity that perceives the environments and acts to maximize its (expected)
utility
The goal of the course is to learn how to design rational agents
Environment
Sensors
Percepts
Agent
Actuators
Actions
An agent is an entity that perceives the environments and acts to maximize its (expected)
utility
The goal of the course is to learn how to design rational agents
Environment
Sensors
Percepts
Agent
Actuators
Actions
An agent is an entity that perceives the environments and acts to maximize its (expected)
utility
Search
Agent function can be
presented by tabulating all
combinations
of percepts and related
actions?
Computational limitations
make
perfect rationality
unachievable
For any given class of environments and tasks, we seek the
agent with the best performance
Search
# Environment types
Observable: Determines if the agents sensors give access to the complete state of the environment at each point in
time. In such case the environment is fully observable. Fully observable environments are convenient, since the agent
does not need memory to keep track of the changes in environment. Unfortunately, such environments are rare in
practice. In other cases, environments are called partially observable or nonbservable.
Deterministic: If the next state of the environment is completely determined by the current state and the action
performed by the agent, then it is called deterministic; otherwise it is stochastic. Most real world environments are
unfortunately stochastic.
Static: A static environment is not changing while the agent is deliberating (e.g. many board games). If this is not true
(e.g. driving a car), the environment is called dynamic.
Discrete: Discrete/continuous distinction applies to the way time is handled and to the percepts and actions of the
agent. For instance, chess game has a finite number of distinct states, percepts and actions. Hence it is discrete
environment. On the other hand, taxi driving is continuous-state and continuos-time problem.
Single-agent: This feature determines if the agent is acting alone in the environment, or if there are multiple agents
(called as multi-agent environment). E.g. crossword puzzle is a single agent environment.
Deterministic: If the next state of the environment is completely determined by the current state and the action
performed by the agent, then it is called deterministic; otherwise it is stochastic. Most real world environments are
unfortunately stochastic.
# Environment types
Static: A static environment is not changing while the agent is deliberating (e.g. many board games). If this is not true
(e.g. driving a car), the environment is called dynamic.
Discrete: Discrete/continuous distinction applies to the way time is handled and to the percepts and actions of the
agent. For instance, chess game has a finite number of distinct states, percepts and actions. Hence it is discrete
environment. On the other hand, taxi driving is continuous-state and continuos-time problem.
# Environment types
Single-agent: This feature determines if the agent is acting alone in the environment, or if there are multiple agents
(called as multi-agent environment). E.g. crossword puzzle is a single agent environment.
Decisions based on
(hypothesized) consequences
of actions
In addition to planning:
A state space
“N”, 1.0
A successor function
(with actions, costs)
“E”, 1.0
A start state and a goal test
Solution?
Sequence of cities, e.g., Arad, Sibiu, Fagaras,
Bucharest
What’s in a State Space?
The world state includes every last detail of the environment
A search state keeps only the details needed for planning (abstraction)
Problem: Pathing
States: (x,y) location
Actions: NSEW
Successor: update location
only
Goal test: is (x,y)=END
What’s in a State Space?
The world state includes every last detail of the environment
A search state keeps only the details needed for planning (abstraction)
Problem: Eat-All-Dots
States: {(x,y), dot booleans}
Actions: NSEW
Successor: update location
and possibly a dot boolean
Goal test: dots all false
State Space Sizes?
World state:
Agent positions: 120
Food count: 30
Ghost positions: 12
Agent facing: NSEW
How many
World states?
120x(230)x(122)x4
States for pathing?
120
States for eat-all-dots?
120x(230)
Quiz: Safe Passage
Possible futures
A search tree:
A “what if” tree of plans and their outcomes
The start state is the root node
Children correspond to successors
Nodes show states, but correspond to PLANS that achieve those states
For most problems, we can never actually build the whole tree
Tree Search
Search Example: Romania
General Tree Search
The simplest approach to problem solving using search
algorithms is a tree search.
Basic idea:
offline, simulated exploration of state space
by generating successors of already-explored states
(a.k.a. expanding states)
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
General Tree Search
The simplest approach to problem solving using search algorithms is a tree search.
Important ideas:
Fringe
Expansion
Exploration strategy
Fringe d e p
b c e h r q
a a h r p q f
p q f q c G
q c G a
a
Uninformed search strategies
b c1 b b
… … …
c2
c3
Implementation: e
d f
Fringe is a LIFO stack S h
p q r
i.e., put successors at front
d e p
b c e h r q
a a h r p q f
p q f q c G
q c G a
a
Depth-First Search (DFS) Properties
What nodes DFS expand?
Some left prefix of the tree.
1 node
Could process the whole tree! b
… b nodes
If m is finite, takes time O(bm)
b2 nodes
Is it optimal? Note that most cases (like Romania example) have infinite
No, it finds the “leftmost” solution, depth (in Romania example you can travel a circle).
regardless of depth or cost
Breadth-First Search
Breadth-First Search
Strategy: expand a shallowest node first a G
b c
Implementation:
e
Fringe is a FIFO queue (i.e., new d f
S h
successors go at end)
p q r
d e p
Search
b c e h r q
Tiers
a a h r p q f
p q f q c G
q c G a
a
Breadth-First Search (BFS) Properties
What nodes does BFS expand?
Processes all nodes above shallowest solution b
1 node
Let depth of shallowest solution be s … b nodes
s tiers
Search takes time O(bs) b2 nodes
Is it complete? bm nodes
s must be finite if a solution exists, so yes!
Is it optimal?
Yes (if cost = 1 per step); not optimal in general
Space is the big problem; can easily generate nodes at 100MB/sec, so 24hrs = 8640GB.
Iterative Deepening
Idea: get DFS’s space advantage with BFS’s
time / shallow-solution advantages b
Run a DFS with depth limit 1. If no solution… …
a GOAL
2 2
b c
3
2
1 8
2 e
3 d
f
9 8 2
START h
1 4 2
p 4 r
15
q
S 0
d 3 e 9 p 1
b 4 c e 5 h 17 r 11 q 16
11
Cost a 6 a h 13 r 7 p q f
contours
p q f 8 q c G
q 11 c G 10 a
a
Uniform Cost Search (UCS) Properties
What nodes does UCS expand?
Processes all nodes with cost less than cheapest solution!
b c1
If that solution costs C* and arcs cost at least , then the …
“effective depth” is roughly C*/ C*/ “tiers”
c2
Takes time O(b ) (exponential in effective depth)
C*/
c3
Is it complete?
Assuming best solution has a finite cost and minimum arc cost
is positive, yes!
Is it optimal?
Yes
Uniform Cost Issues
Remember: UCS explores increasing cost c1
…
contours c2
c3
The bad:
Explores options in every “direction”
No information about goal location Start Goal