Professional Documents
Culture Documents
AAI Intro Lec 5 6 (2)
AAI Intro Lec 5 6 (2)
AAI Intro Lec 5 6 (2)
What is search?
Problem-solving agents
Problem types
Problem formulation
Example problems
Uninformed search
Basic search algorithms
2
What is Search?
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.
Its possible that some sequence might fail, e.g., getting stuck in an infinite
loop, or unable to find the goal at all.
3
Linking Search to Trees
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
4
Example: Traveling in Romania
On holiday in Romania; currently in Arad.
Flight leaves tomorrow for 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.
5
Example: Traveling in Romania
6
Search Problem Types
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 routes between them
Deterministic: Transiting from one city (node) on one route, can
lead to only one possible city
Single-Agent: We assume only one agent searches at one time, but
multiple agents can also be used.
7
Problem-Solver Formulation
A problem is defined by five items:
1. An Initial state, e.g., “In Arad“
2. Possible actions available, ACTIONS(s) returns the set of actions that can be executed
in s.
3. A successor function S(x) = the set of all possible {Action–State} pairs from some
state, e.g., Succ(Arad) = {<Arad Zerind, In Zerind>, …}
4. Goal test, can be
▪ explicit, e.g., x = "In Bucharest”
▪ implicit, e.g., specifying any city
5. Path cost (additive): e.g., sum of distances, number of actions executed, etc. and
c(x,a,y) is the step cost, assumed to be ≥ 0
States? Actions?
Goal test? Path cost?
9
Vacuum World State Space Graph
States?
Actions?
Goal test?
11
Path cost?
Example: The 8-puzzle
13
Tree search example
14
Tree search example
15
Tree search example
16
Fringe
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
17
Implementation: States vs. Nodes
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.
18
Search Strategies
19
Uninformed Search Strategies
20
Breadth-first search
• Implementation:
– fringe is a FIFO queue, i.e., new successors go at end
21
Breadth-first search
22
Breadth-first search
23
Breadth-first search
• Algorithm
24
Properties of Breadth-first search
25
Preventing Loopy Paths
26
Uniform-Cost Search
fringe MAKE-EMPTY-QUEUE()
fringe INSERT( root_node ) // with g=0
loop {
if fringe is empty then return false // finished without goal
node REMOVE-SMALLEST-COST(fringe)
if node is a goal
1. print node and g
2. return true // that found a goal
Lg EXPAND(node) // Lg is set of neighbors with their g costs
// NOTE: do not check Lg for goals here!!
fringe INSERT-IF-NEW(Lg , fringe ) // ignore revisited nodes
// unless with a new and better g
}
27
Uniform-Cost Search
28
29
Uniform-Cost Search
30
Uniform-Cost Search
Expand least-cost unexpanded node
Implementation:
fringe = queue ordered by path cost
31
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe is a LIFO queue, i.e., put successors in the front
32
Depth-first search
33
Depth-first search
34
Depth-limited search
35
Depth-Limited Search
36
Iterative deepening search
37
Iterative deepening search l =0
38
Properties of Depth-first search
39
Iterative deepening search l =1
40
Iterative deepening search l =2
41
Iterative deepening search l =3
42
Properties of Iterative Deepening search
• Complete? Yes
• Time? (d+1)b0 + d b1 + (d-1) b2 + … + bd = O(bd)
• Space? O(bd)
43
Summary of Algorithms
44
Questions
45