1. 14 Jan 2004 CSE-IUT 1
Solving problems by
searching
Chapter 3
2. 14 Jan 2004 CS 3243 - Blind Search 2
Outline
Introduction to state space search
Problem types
Problem formulation
Example problems
Basic search algorithms
3. Objective: State space search
State space representation
How problems are formulated as state space
search problems
How implicit state spaces can be unfolded
during search.
14 Jan 2004 CS 3243 - Blind Search 3
7. Problem formulation: it means choosing a
relevant set of states to consider and a
feasible set of operators for moving from one
state to another.
Search is the process of imagining
sequences of operators applied to the initial
state and checking which sequence reaches
a goal state.
14 Jan 2004 CSE-IUT 7
21. 14 Jan 2004 CS 3243 - Blind Search 21
Example: The 8-puzzle
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]
22. 14 Jan 2004 CS 3243 - Blind Search 22
Problem types
Deterministic, fully observable single-state problem
Agent knows exactly which state it will be in; solution is a sequence
Non-observable sensorless problem (conformant
problem)
Agent may have no idea where it is; solution is a sequence
Each action might therefore lead to one of several possible
successor states.
it could be one of several possible initial
states
23. Nondeterministic and/or partially observable contingency
problem
The actions are uncertain
Agent’s percepts provide new information after each action
Unknown state space exploration problem
When the states and actions of the environment are unknown, the
agent must act to discover them.
14 Jan 2004 CS 3243 - Blind Search 23
26. 14 Jan 2004 CS 3243 - Blind Search 26
Search strategies
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 branching factor of the search tree
d: depth of the least-cost solution
m: maximum depth of the state space (may be ∞)
27. 14 Jan 2004 CS 3243 - Blind Search 27
Uninformed search strategies
Uninformed search strategies use only the
information available in the problem
definition
Breadth-first search
Uniform-cost search
Depth-first search
Depth-limited search
Iterative deepening search
36. 14 Jan 2004 CS 3243 - Blind Search 36
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
37. 14 Jan 2004 CS 3243 - Blind Search 37
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
38. 14 Jan 2004 CS 3243 - Blind Search 38
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
39. 14 Jan 2004 CS 3243 - Blind Search 39
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
40. 14 Jan 2004 CS 3243 - Blind Search 40
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
41. 14 Jan 2004 CS 3243 - Blind Search 41
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
42. 14 Jan 2004 CS 3243 - Blind Search 42
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
43. 14 Jan 2004 CS 3243 - Blind Search 43
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
44. 14 Jan 2004 CS 3243 - Blind Search 44
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
45. 14 Jan 2004 CS 3243 - Blind Search 45
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
46. 14 Jan 2004 CS 3243 - Blind Search 46
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
47. 14 Jan 2004 CS 3243 - Blind Search 47
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
48. Drawbacks of DFS
It can make wrong choice and get stuck
going down a very long(even infinite) path
when a different choice would lead to a
solution near the root of a search tree.
DFS is not optimal
14 Jan 2004 CS 3243 - Blind Search 48
49. 14 Jan 2004 CS 3243 - Blind Search 49
Properties of depth-first search
Complete? No: fails in infinite-depth spaces,
spaces with loops
Modify to avoid repeated states along path
complete in finite spaces
Time? O(bm
): terrible if m is much larger than d
but if solutions are dense, may be much faster than
breadth-first
Space? O(bm), i.e., linear space!
Optimal? No
66. Uniform Cost search (Algorithm)
Insert the root into the queue
While the queue is not empty
Dequeue the maximum priority element from the queue
If priorities are same, alphabetically smaller path is
chosen
If the path is ending in the goal state, print the path and
exit
Else
Insert all the children of the dequeued element, with
the cumulative costs as priority
14 Jan 2004 CS 3243 - Blind Search 66
67. Uniform Cost search
Full Details: https://algorithmicthoughts.wordpress.com/2012/12/15/artificial-
intelligence-uniform-cost-searchucs/
14 Jan 2004 CS 3243 - Blind Search 67
68. Suggestion for good exam
Read books, internet tutorial and video
tutorials available on Youtube for clear
understanding and better performance in
exam.
14 Jan 2004 CS 3243 - Blind Search 68