7/28/2019 AI Lecture 3
1/23
Lecture 3 Problem-Solving(Search) Agents
Dr. Muhammad Adnan Hashmi
11 June 2013
7/28/2019 AI Lecture 3
2/23
1 June 2013 2
Problem-solving agents
Problem types
Problem formulation
Example problems Basic search algorithms
7/28/2019 AI Lecture 3
3/23
Suppose an agent can execute several actionsimmediately in a given state
It doesnt know the utility of these actions
Then, for each action, it can execute a sequenceof actions until it reaches the goal
The immediate action which has the bestsequence (according to the performancemeasure) is then the solution
Finding this sequence of actions is called search,
and the agent which does this is called theproblem-solver.
NB: Its possible that some sequence might fail,e.g., getting stuck in an infinite loop, or unableto find the goal at all.
1 June 2013 3
7/28/2019 AI Lecture 3
4/23
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
1 June 2013 4
7/28/2019 AI Lecture 3
5/23
1 June 2013 5
7/28/2019 AI Lecture 3
6/23
1 June 2013 6
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.
7/28/2019 AI Lecture 3
7/231 June 2013 7
7/28/2019 AI Lecture 3
8/231 June 2013 8
Static: The configuration of the graph (the city map)is unlikely to change during search
Observable: The agent knows the state (node)
completely, e.g., which city I am in currently
Discrete: Discrete number of cities and routesbetween them
Deterministic: Transiting from one city (node) onone route, can lead to only one possible city
Single-Agent: We assume only one agent searchesat one time, but multiple agents can also be used.
7/28/2019 AI Lecture 3
9/231 June 2013 9
A problem is defined by five items:
1. An Initial state, e.g., In Arad
2. Possible actions available, ACTIONS(s) returns the set ofactions that can be executed in s.
3. A successor functionS(x) = the set of all possible{ActionState} pairs from some state, e.g., Succ(Arad) ={, }
4. Goal test, can be explicit, e.g.,x= "In Bucharest implicit, e.g., Checkmate(x)
5. Path cost (additive) e.g., sum of distances, number of actions executed, etc. c(x,a,y) is the step cost, assumed to be 0
A solution is a sequence of actions leading from the initialstate to a goal state.
7/28/2019 AI Lecture 3
10/231 June 2013 10
States? Actions? Goal test? Path cost?
7/28/2019 AI Lecture 3
11/231 June 2013 11
States?dirt and robot location
Actions?Left, Right, Pick
Goal test?no dirt at all locations
Path cost?1 per action
7/28/2019 AI Lecture 3
12/231 June 2013 12
States?
Actions?
Goal test?
Path cost?
7/28/2019 AI Lecture 3
13/23
1 June 2013 13
States? locations of tiles Actions?move blank left, right, up, down Goal test?= goal state (given) Path cost? 1 per move
[Note: optimal solution ofn-Puzzle family is NP-hard]
7/28/2019 AI Lecture 3
14/23
1 June 2013 14
States?: real-valued coordinates of robotjoint angles, parts of the object to beassembled, current assembly
Actions?: continuous motions of robotjoints
Goal test?: complete assembly
Path cost?: time to execute
7/28/2019 AI Lecture 3
15/23
1 June 2013 15
Basic idea:
Offline (not dynamic), simulated exploration ofstate space by generating successors of already-explored states (a.k.a. expanding the states)
The expansion strategy defines the differentsearch algorithms.
7/28/2019 AI Lecture 3
16/23
1 June 2013 16
7/28/2019 AI Lecture 3
17/23
1 June 2013 17
7/28/2019 AI Lecture 3
18/23
1 June 2013 18
7/28/2019 AI Lecture 3
19/23
Fringe: The collection of nodes that have beengenerated 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
1 June 2013 19fringe fringe
7/28/2019 AI Lecture 3
20/23
The fringe is implemented as a queue
MAKE_QUEUE(element,): makes a queue withthe given elements
EMPTY?(queue): checks whether queue is empty FIRST(queue): returns 1st element of queue
REMOVE_FIRST(queue): returns FIRST(queue)and removes it from queue
INSERT(element, queue): add elementto queue INSERT_ALL(elements,queue): adds the set
elements to queue and return the resulting queue
1 June 2013 20
7/28/2019 AI Lecture 3
21/23
1 June 2013 21
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 costg(x), depth
The Expand function creates new nodes, filling in
the various fields and using the SuccessorFn ofthe problem to create the corresponding states.
7/28/2019 AI Lecture 3
22/23
1 June 2013 22
A search strategy is defined by picking the orderof node expansion
Strategies are evaluated along the followingdimensions: Completeness: Does it always find a solution if one
exists? Time complexity: Number of nodes generated
Space complexity: Maximum number of nodes inmemory
Optimality: Does it always find a least-cost solution?
Time and space complexity are measured interms 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.
7/28/2019 AI Lecture 3
23/23
231 June 2013