AI Lecture 3
AI Lecture 3
(Search) Agents
March 6, 2023 2
Suppose an agent can execute several actions
immediately in a given state
It doesn’t know the utility of these actions
Then, for each action, it can execute a sequence
of actions until it reaches the goal
The immediate action which has the best
sequence (according to the performance
measure) is then the solution
Finding this sequence of actions is called
search, and the agent which does this is called
the problem-solver.
NB: Its possible that some sequence might fail,
e.g., getting stuck in an infinite loop, or unable
to find the goal at all.
March 6, 2023 3
You can begin to visualize the concept of a
graph
Searching along different paths of the graph
until you reach the solution
The nodes can be considered congruous to the
states
The whole graph can be the state space
The links can be congruous to the actions……
March 6, 2023 4
On holiday in Romania; currently in Arad.
Flight leaves tomorrow from Bucharest
Formulate goal: Be in Bucharest
Formulate problem:
States: various cities
Actions: drive between cities
Find solution:
Sequence of cities, e.g., Arad, Sibiu, Fagaras,
Bucharest.
March 6, 2023 5
March 6, 2023 6
Static: The configuration of the graph (the city map)
is unlikely to change during search
March 6, 2023 11
States? locations of tiles
Actions? move blank left, right, up, down
Goal test? = goal state (given)
Path cost? 1 per move
[Note: optimal solution of n-Puzzle family is NP-hard]
March 6, 2023 12
States?: real-valued coordinates of robot
joint angles, parts of the object to be
assembled, current assembly
Actions?: continuous motions of robot
joints
Goal test?: complete assembly
Path cost?: time to execute
March 6, 2023 13
Basic idea:
Offline (not dynamic), simulated exploration of
state space by generating successors of already-
explored states (a.k.a. expanding the states)
The expansion strategy defines the different
search algorithms.
March 6, 2023 14
March 6, 2023 15
March 6, 2023 16
March 6, 2023 17
Fringe: The collection of nodes that have been
generated but not yet expanded
Each element of the fringe is a leaf node, with
(currently) no successors in the tree
The search strategy defines which element to
choose from the fringe
fringe
March 6, 2023
fringe 18
A state is a representation of a physical
configuration
A node is a data structure constituting part of a
search tree includes state, parent node, action,
path cost g(x), depth
The Expand function creates new nodes, filling in
the various fields and using the SuccessorFn of
the problem to create the corresponding states.
March 6, 2023 19
A search strategy is defined by picking the
order of node expansion
Strategies are evaluated along the following
dimensions:
Completeness: Does it always find a solution if one
exists?
Time complexity: Number of nodes generated
Space complexity: Maximum number of nodes in
memory
Optimality: Does it always find a least-cost solution?
Time and space complexity are measured in
terms of
b: maximum no. of successors of any node
d: depth of the shallowest goal node
m: maximum length of any path in the state space.
March 6, 2023 20
March 6, 2023 21