SlideShare a Scribd company logo
Jarrar © 2014 1
Chapter 3
Un-Informed Search
Dr. Mustafa Jarrar
Sina Institute, University of Birzeit
mjarrar@birzeit.edu
www.jarrar.info
Artificial Intelligence
Lecture Notes on Uninformed Search
Birzeit University, Palestine
Fall Semester, 2014
Jarrar © 2014 2
Watch this lecture and download the slides from
http://jarrar-courses.blogspot.com/2011/11/artificial-intelligence-fall-2011.html
Most material is based on chapter 3 of [1]
Jarrar © 2014 3
Lecture Outline
 Achieve intelligence by (Searching) a solution!
 Problem Formulation
 Search Strategies
– breadth-first
– uniform-cost search
– depth-first
– depth-limited search
– iterative deepening
– bi-directional search
– constraint satisfaction
Jarrar © 2014 4
Example: Romania
You are in Arad and want to go to Bucharest
 How to design an intelligent agent to find the way between 2 cities?
Jarrar © 2014 5
Example: The 8-puzzle
 How can we design an intelligent agent to solve the 8-puzzel?
Jarrar © 2014 8
Motivation
• Solve a problem by searching for a solution. Search
strategies are important methods for many approaches to
problem-solving[2].
• Problem formulation. The use of search requires an
abstract formulation of the problem and the available steps
to construct solutions.
• Optimizing Search. Search algorithms are the basis for
many optimization and planning methods.
Jarrar © 2014 9
Problem Formulation
To solve a problem by search, we need to first formulate the
problem.
HOW?
Our textbook suggest the following schema to help us
formulate problems
1. State
2. Initial state
3. Actions or Successor Function
4. Goal Test
5. Path Cost
6. Solution
Jarrar © 2014 10
Problem Formulation (The Romania Example)
State: We regard a problem as state space
here a state is a City
Initial State: the state to start from
In(Arad)
Successor Function: description of the possible actions, give state x, S(X)
returns a set of <action, successor> ordered pairs.
S(x)= { <Go(Sibiu), In(Sibiu)>, <Go(Timisoara), In(Timisoara)>,
<Go(Zerind),In(Zerind)> }
Goal Test: determine a given state is a goal state.
In(Sibiu) No. In(Zerind) No.…. In(Bucharest)Yes!
Path Cost: a function that assigns a numeric cost to each path.
– e.g., sum of distances, number of actions executed, etc.
– c(x,a,y) is the step cost, assumed to be ≥ 0
Solution: a sequence of actions leading from the initial state to a goal state
{Arad Sibiu  Rimnicu Vilcea  Pitesti  Bucharest}
Jarrar © 2014 11
Problem Formulation (The 8- Puzzle Example)
State: The location of the eight tiles, and the blank
Initial State: {(7,0), (2,1), (4,2), (5,3), (_,4), (6,5), (8,6), (3,7), (1,8)}
Successor Function: one of the four actions (blank moves Left, Right, Up,
Down).
Goal Test: determine a given state is a goal state.
Path Cost: each step costs 1
Solution: {(_,0),(1,1),(2,2) ,(3,3) ,(4,4) ,(5,5) ,(6,6) ,(7,7) ,(8,8)}
Jarrar © 2014 12
Problem Formulation (Real-life Applications)
Route Finding Problem
• States
– locations
• Initial state
– starting point
• Successor function (operators)
– move from one location to another
• Goal test
– arrive at a certain location
• Path cost
– may be quite complex
• money, time, travel comfort,
scenery,
Car
Navigation
Routing in Computer
networks
Military operation
planning
Airline travel
planning
Jarrar © 2014 13
Problem Formulation (Real-life Applications)
Routing Problem
 What is the state space for each of them?
A set of places with links between them, which have been visited
Jarrar © 2014 14
Problem Formulation (Real-life Applications)
Travel Salesperson Problem
• States
– locations / cities
– illegal states
• each city may be visited only once
• visited cities must be kept as state information
• Initial state
– starting point
– no cities visited
• Successor function (operators)
– move from one location to another one
• Goal test
– all locations visited
– agent at the initial location
• Path cost
– distance between locations
Based on [2]
Jarrar © 2014 15
Problem Formulation (Real-life Applications)
VLSI layout Problem
• States
– positions of components, wires on a chip
• Initial state
– incremental: no components placed
– complete-state: all components placed (e.g.
randomly, manually)
• Successor function (operators)
– incremental: place components, route wire
– complete-state: move component, move wire
• Goal test
– all components placed
– components connected as specified
• Path cost
– maybe complex
• distance, capacity, number of connections per
component
Jarrar © 2014 16
Problem Formulation (Real-life Applications)
Robot Navigation
• States
– locations
– position of actuators
• Initial state
– start position (dependent on the task)
• Successor function (operators)
– movement, actions of actuators
• Goal test
– task-dependent
• Path cost
– maybe very complex
• distance, energy consumption
Jarrar © 2014 17
Problem Formulation (Real-life Applications)
Automatic Assembly Sequencing
• States
– location of components
• Initial state
– no components assembled
• Successor function (operators)
– place component
• Goal test
– system fully assembled
• Path cost
– number of moves
Jarrar © 2014 18
Searching for Solutions
• Traversal of the search space
– From the initial state to a goal state.
– Legal sequence of actions as defined by successor function.
• General procedure
– Check for goal state
– Expand the current state
• Determine the set of reachable states
• Return “failure” if the set is empty
– Select one from the set of reachable states
– Move to the selected state
• A search tree is generated
– Nodes are added as more states are visited
Jarrar © 2014 19
Search Terminology
Search Tree
– Generated as the search space is traversed
• The search space itself is not necessarily a tree, frequently it is a
graph
• The tree specifies possible paths through the search space
– Expansion of nodes
• As states are explored, the corresponding nodes are expanded by
applying the successor function
– this generates a new set of (child) nodes
• The fringe (frontier/queue) is the set of nodes not yet visited
– newly generated nodes are added to the fringe
– Search strategy
• Determines the selection of the next node to be expanded
• Can be achieved by ordering the nodes in the fringe
– e.g. queue (FIFO), stack (LIFO), “best” node w.r.t. some measure (cost)
Jarrar © 2014 20
Example: Graph Search
• The graph describes the search (state) space
– Each node in the graph represents one state in the search space
• e.g. a city to be visited in a routing or touring problem
• This graph has additional information
– Names and properties for the states (e.g. S3)
– Links between nodes, specified by the successor function
• properties for links (distance, cost, name, ...)
S3
A4
C2
D3
E1B2
G0
1
1 1
3
1
3 3
4
5
1
2
Jarrar © 2014 21
Traversing a Graph as Tree
S3
5
A4
D3
1
1
33
4
2
C2
D3G0
G0
G0 E1
G0
1
1
3
3
4
2
C2
D3
G0
G0 E1
G0
1
3
B2
1
3
C2
D3
G0
G0 E1
G0
1
3
4 E1
G0
2 4
3 2
4
S3
A4
C2
D3
E1B2
G0
1
1 1
3
1
3 3
4
5
1
2
 A tree is generated by
traversing the graph.
 The same node in the
graph may appear
repeatedly in the tree.
 the arrangement of the
tree depends on the
traversal strategy
(search method)
 The initial state
becomes the root node
of the tree
 In the fully expanded
tree, the goal states
are the leaf nodes.
 Cycles in graphs may
result in infinite
branches.
2
Jarrar © 2014 22
Searching Strategies
Most of the effort is often spent on the selection of an appropriate search
strategy for a given problem:
– Uninformed Search (blind search)
• number of steps, path cost unknown
• agent knows when it reaches a goal
– Informed Search (heuristic search)
• agent has background information about the problem
– map, costs of actions
Uninformed Search
– breadth-first
– uniform-cost search
– depth-first
– depth-limited search
– iterative deepening
– bi-directional search
– constraint satisfaction
Informed Search
– best-first search
– search with heuristics
– memory-bounded search
– iterative improvement search
Jarrar © 2014 23
Evaluation of Search Strategies
• A search strategy is defined by picking the order of node
expansion
• Strategies are evaluated along the following dimensions:
• Completeness: if there is a solution, will it be found
• Time complexity: How long does it takes to find the solution
• Space complexity: memory required for the search
• Optimality: will the best solution be found
• 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 ∞)
Jarrar © 2014 24
1: Breadth-First Search
Jarrar © 2014 25
Breadth-First Search
All the nodes reachable from the current node are explored
first (shallow nodes are expanded before deep nodes).
Algorithm (Informal)
1. Enqueue the root/initial node.
2. Dequeue a node and examine it.
1. If the element sought is found in this node, quit the search and return a
result.
2. Otherwise enqueue any successors (the direct child nodes) that have not
yet been discovered.
3. If the queue is empty, every node on the graph has been examined –
quit the search and return "not found".
4. Repeat from Step 2.
Based on [3]
Jarrar © 2014 26
Breadth-First Snapshot 1
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
Fringe: [] + [2,3]
Jarrar © 2014 27
Breadth-First Snapshot 2
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5
Fringe: [3] + [4,5]
Jarrar © 2014 28
Breadth-First Snapshot 3
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5 6 7
Fringe: [4,5] + [6,7]
Jarrar © 2014 29
Breadth-First Snapshot 4
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5 6 7
8 9
Fringe: [5,6,7] + [8,9]
Jarrar © 2014 30
Breadth-First Snapshot 5
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5 6 7
8 9 10 11
Fringe: [6,7,8,9] + [10,11]
Jarrar © 2014 31
Breadth-First Snapshot 6
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5 6 7
8 9 10 11 12 13
Fringe: [7,8,9,10,11] + [12,13]
Jarrar © 2014 32
Breadth-First Snapshot 7
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
Fringe: [8,9.10,11,12,13] + [14,15]
Jarrar © 2014 33
Breadth-First Snapshot 8
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16 17
Fringe: [9,10,11,12,13,14,15] + [16,17]
Jarrar © 2014 34
Breadth-First Snapshot 9
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19
Fringe: [10,11,12,13,14,15,16,17] + [18,19]
Jarrar © 2014 35
Breadth-First Snapshot 10
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21
Fringe: [11,12,13,14,15,16,17,18,19] + [20,21]
Jarrar © 2014 36
Breadth-First Snapshot 11
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23
Fringe: [12, 13, 14, 15, 16, 17, 18, 19, 20, 21] + [22,23]
Jarrar © 2014 37
Breadth-First Snapshot 12
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23 24 25
Fringe: [13,14,15,16,17,18,19,20,21] + [22,23]
Note:
The goal node is
“visible” here, but
we can not
perform the goal
test yet.
Jarrar © 2014 38
Breadth-First Snapshot 13
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23 24 25 26 27
Fringe: [14,15,16,17,18,19,20,21,22,23,24,25] + [26,27]
Jarrar © 2014 39
Breadth-First Snapshot 14
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23 24 25 26 27 28 29
Fringe: [15,16,17,18,19,20,21,22,23,24,25,26,27] + [28,29]
Jarrar © 2014 40
Breadth-First Snapshot 15
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Fringe: [15,16,17,18,19,20,21,22,23,24,25,26,27,28,29] + [30,31]
Jarrar © 2014 41
Breadth-First Snapshot 16
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Fringe: [17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]
Jarrar © 2014 42
Breadth-First Snapshot 17
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Fringe: [18,19,20,21,22,23,24,25,26,27,28,29,30,31]
Jarrar © 2014 43
Breadth-First Snapshot 18
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Fringe: [19,20,21,22,23,24,25,26,27,28,29,30,31]
Jarrar © 2014 44
Breadth-First Snapshot 19
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Fringe: [20,21,22,23,24,25,26,27,28,29,30,31]
Jarrar © 2014 45
Breadth-First Snapshot 20
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Fringe: [21,22,23,24,25,26,27,28,29,30,31]
Jarrar © 2014 46
Breadth-First Snapshot 21
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Fringe: [22,23,24,25,26,27,28,29,30,31]
Jarrar © 2014 47
Breadth-First Snapshot 22
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Fringe: [23,24,25,26,27,28,29,30,31]
Jarrar © 2014 48
Breadth-First Snapshot 23
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Fringe: [24,25,26,27,28,29,30,31]
Jarrar © 2014 49
Breadth-First Snapshot 24
Initial
Visited
Fringe
Current
Visible
Goal
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Fringe: [25,26,27,28,29,30,31]
Note:
The goal test
is positive for
this node, and
a solution is
found in 24
steps.
Jarrar © 2014 50
Properties of Breadth-First Search (BFS)
• Completeness: Yes (if b is finite), a solution will be found if exists.
• Time Complexity: 1+b+b2+b3+… +bd + (bd+1- b) = bd+1
(nodes until the solution)
• Space Complexity: bd+1 (keeps every generated node in memory)
• Optimality: Yes (if cost = 1 per step)
• Suppose the branching factor b=10, and the goal is at depth
d=12:
– Then we need O1012 time to finish. If O is 0.001 second, then we need 1
billion seconds (31 year). And if each O costs 10 bytes to store, then we
also need 1 terabytes.
Not suitable for searching large graphs
b Branching Factor
d The depth of the goal
Jarrar © 2014 51
2- Uniform-Cost -First
Jarrar © 2014 52
Uniform-Cost -First
Visits the next node which has the least total cost
from the root, until a goal state is reached.
– Similar to BREADTH-FIRST, but with an evaluation of
the cost for each reachable node.
– g(n) = path cost(n) = sum of individual edge costs to
reach the current node.
Jarrar © 2014 53
Uniform-Cost Search (UCS)
Jarrar © 2014 54
Uniform-Cost Search (UCS)
Jarrar © 2014 55
Uniform-Cost Search (UCS)
Jarrar © 2014 56
Uniform-Cost Search (UCS)
Jarrar © 2014 57
Uniform-Cost Search (UCS)
Jarrar © 2014 58
Uniform-Cost Search (UCS)
Jarrar © 2014 59
Uniform-Cost Search (UCS)
Jarrar © 2014 60
Uniform-Cost Search (UCS)
Jarrar © 2014 61
Properties of Uniform-cost Search (UCS)
• Completeness Yes (if b is finite, and step cost is positive)
• Time Complexity much larger than bd, and just bd if all steps have the
same cost.
• Space Complexity: as above
• Optimality: Yes
Requires that the goal test being applied when a node is removed from the
nodes list rather than when the node is first generated while its parent node
is expanded.
b Branching Factor
d Depth of the goal/tree
Jarrar © 2014 62
Breadth-First vs. Uniform-Cost
• Breadth-first search (BFS) is a special case of uniform-cost
search when all edge costs are positive and identical.
• Breadth-first always expands the shallowest node
– Only optimal if all step-costs are equal
• Uniform-cost considers the overall path cost
– Optimal for any (reasonable) cost function
• non-zero, positive
– Gets stuck down in trees with many fruitless, short branches
• low path cost, but no goal node
• Both are complete for non-extreme problems
– Finite number of branches
– Strictly positive search function
Jarrar © 2014 63
3- Depth-First Search
Jarrar © 2014 64
Depth-First Search
• A depth-first search (DFS)
explores a path all the way to
a leaf before backtracking and
exploring another path.
• For example, after searching
A, then B, then D, the search
backtracks and tries another
path from B.
• Node are explored in the order
A B D E H L M N I O P C F
G J K Q
L M N O P
G
Q
H JI K
FED
B C
A
Based on [4]
Jarrar © 2014 65
Depth-First Search
• Put the root node on a stack;
while (stack is not empty) {
remove a node from the stack;
if (node is a goal node) return success;
put all children of node onto the stack;
}
return failure;
• At each step, the stack contains some nodes from each of
a number of levels
– The size of stack that is required depends on the branching factor b
– While searching level n, the stack contains approximately (b-1)*n
nodes
• When this method succeeds, it doesn’t give the path
Based on [4]
Jarrar © 2014 66
Recursive Depth-First Search
• Search(node):
if node is a goal, return success;
for each child c of node {
if search(c) is successful, return success;
}
return failure;
• The (implicit) stack contains only the nodes on a path from
the root to a goal
– The stack only needs to be large enough to hold the deepest
search path
– When a solution is found, the path is on the (implicit) stack, and
can be extracted as the recursion “unwinds”
print node and
print c and
Jarrar © 2014 67
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
b: maximum branching factor of the search tree
d: depth of the least-cost solution
m: maximum depth of the state space (may be ∞)
Jarrar © 2014 68
Depth-First vs. Breadth-First
• Depth-first goes off into one branch until it reaches a leaf
node
– Not good if the goal is on another branch
– Neither complete nor optimal
– Uses much less space than breadth-first
• Much fewer visited nodes to keep track, smaller fringe
• Breadth-first is more careful by checking all alternatives
– Complete and optimal (Under most circumstances)
– Very memory-intensive
• For a large tree, breadth-first search memory requirements maybe
excessive
• For a large tree, a depth-first search may take an excessively long time
to find even a very nearby goal node.
 How can we combine the advantages (and avoid the disadvantages) of
these two search techniques?
Jarrar © 2014 69
4- Depth-Limited Search
Similar to depth-first, but with a limit
– i.e., nodes at depth l have no successors
– Overcomes problems with infinite paths
– Sometimes a depth limit can be inferred or estimated from the
problem description
• In other cases, a good depth limit is only known when the problem is
solved
– must keep track of the depth
b branching factor
l depth limit
• Complete? no (if goal beyond l (l<d), or infinite branch length)
• Time? bl
• Space? B*l
• Optimal? No (if l < d)
Jarrar © 2014 70
5- Iterative Deepening Depth-First Search
Jarrar © 2014 71
Iterative Deepening Depth-First Search
• Applies LIMITED-DEPTH with increasing depth limits
• Combines advantages of BREADTH-FIRST and DEPTH-FIRST
• It searches to depth 0 (root only), then if that fails it searches to
depth 1, then depth 2, etc.
Jarrar © 2014 72
Iterative deepening search l =0
Jarrar © 2014 73
Iterative deepening search l =1
Jarrar © 2014 74
Iterative deepening search l =2
Jarrar © 2014 75
Iterative deepening search l =3
Jarrar © 2014 76
Iterative Deepening Depth-First Search
• If a goal node is found, it is a nearest node and the path to it is on the
stack.
• Required stack size is limit of search depth (plus 1).
• Many states are expanded multiple times
• doesn’t really matter because the number of those nodes is small
• In practice, one of the best uninformed search methods
• for large search spaces, unknown depth
Jarrar © 2014 77
Properties of Iterative Deepening Search
• Complete: Yes (if the b is finite)
• Time: (d+1)b0 + d b1 + (d-1)b2 + … + bd = O(bd)
• Space: O(bd)
• Optimal: Yes, if step cost = 1
b branching factor
d Tree/goal depth
Jarrar © 2014 78
Iterative Deepening Search
• The nodes in the bottom level (level d) are generated once, those on
the next bottom level are generated twice, and so on:
NIDS = (d)b + (d-1)b2 + … + (1) bd
Time complexity = bd
• Compared with BFS:
NBFS = b + b2 … + bd + (bd+1 –b)
• Suppose b = 10, d = 5,
NIDS = 50 + 400 + 3,000 + 20,000 + 100,000 = 123,456
NBFS = 1 + 10 + 100 + 1,000 + 10,000 + 100,000 = 111,111
 IDS behaves better in case the search space is large and the depth of goal is
unknown.
Jarrar © 2014 79
Iterative Deepening Search
• When searching a binary tree to depth 7:
– DFS requires searching 255 nodes
– Iterative deepening requires searching 502 nodes
– Iterative deepening takes only about twice as long
• When searching a tree with branching factor of 4 (each
node may have four children):
– DFS requires searching 21845 nodes
– Iterative deepening requires searching 29124 nodes
– Iterative deepening takes about 4/3 = 1.33 times as long
• The higher the branching factor, the lower the relative
cost of iterative deepening depth first search
Based on [4]
Jarrar © 2014 80
6- Bi-directional Search
• Search simultaneously from two directions
– Forward from the initial and backward from the goal state, until they
meet in the middle (i.e., if a node exists in the fringe of the other).
– The idea is to have (bd/2 + bd/2) instead of bd, which much less
• May lead to substantial savings (if it is applicable), but is
has several limitations
– Predecessors must be generated, which is not always possible
– Search must be coordinated between the two searches
– One search must keep all nodes in memory
b branching factor
d tree depth
Time Complexity bd/2
Space Complexity bd/2
Completeness yes (b finite, breadth-first for both directions)
Optimality yes (all step costs identical, breadth-first for
both directions)
Jarrar © 2014 81
Summary
• Problem formulation usually requires abstracting away real-world
details to define a state space that can feasibly be explored.
• Variety of uninformed search strategies
Iterative deepening search uses only linear space and not
much more time than other uninformed algorithms
Jarrar © 2014 82
Summary
• Breadth-first search (BFS) and depth-first search (DFS) are the
foundation for all other search techniques.
• We might have a weighted tree, in which the edges connecting a node
to its children have differing “weights”
– We might therefore look for a “least cost” goal
• The searches we have been doing are blind searches, in which we
have no prior information to help guide the search
Jarrar © 2014 83
Summary (When to use what)
• Breadth-First Search:
– Some solutions are known to be shallow
• Uniform-Cost Search:
– Actions have varying costs
– Least cost solution is the required
This is the only uninformed search that worries about costs.
• Depth-First Search:
– Many solutions exist
– Know (or have a good estimate of) the depth of solution
• Iterative-Deepening Search:
– Space is limited and the shortest solution path is required
Jarrar © 2014 84
Improving Search Methods
• Make algorithms more efficient
– avoiding repeated states
• Use additional knowledge about the problem
– properties (“shape”) of the search space
• more interesting areas are investigated first
– pruning of irrelevant areas
• areas that are guaranteed not to contain a solution can be discarded
Jarrar © 2014 85
Project (Car Navigator)
Develop a simulation program that takes as input (map, current town, goal
town), and returns the path to the goal, as well as the whether the algorithm
used is complete, its time and space complexities, and whether it is optimal.
The simulator should
implement all searching
strategies described
earlier.
Please develop a map
(an area in Palestine) to
test your program. The
size of the map should
be: the branching factor
(b) is >3, and the depth
>10
Jarrar © 2014 86
References
[1] S. Russell and P. Norvig: Artificial Intelligence: A Modern
Approach Prentice Hall, 2003, Second Edition
[2] Franz Kurfess: Notes on Artificial Intelligence
http://users.csc.calpoly.edu/~fkurfess/Courses/480/F03/Slides/3-Search.pdf
[3] "Breadth-first Search." Wikipedia. Wikimedia Foundation.
Web. 3 Feb. 2015. <http://en.wikipedia.org/wiki/Breadth-f
irst_search>.
[4] David Lee Matuszek: Lecture Notes on Tree Searches
http://www.cs.nyu.edu/courses/fall06/V22.0102-001/lectures/treeSearching.ppt

More Related Content

PPT
Uninformed search
Bablu Shofi
 
PPT
Jarrar: Games
Mustafa Jarrar
 
PPT
Uniformed tree searching
Ayaelshiwi
 
PPT
Chapter3 Search
Khiem Ho
 
PPTX
Lecture 08 uninformed search techniques
Hema Kashyap
 
PPTX
Uninformed Search technique
Kapil Dahal
 
PPTX
Lecture 10 Uninformed Search Techniques conti..
Hema Kashyap
 
PPT
Artificial Intelligence -- Search Algorithms
Syed Ahmed
 
Uninformed search
Bablu Shofi
 
Jarrar: Games
Mustafa Jarrar
 
Uniformed tree searching
Ayaelshiwi
 
Chapter3 Search
Khiem Ho
 
Lecture 08 uninformed search techniques
Hema Kashyap
 
Uninformed Search technique
Kapil Dahal
 
Lecture 10 Uninformed Search Techniques conti..
Hema Kashyap
 
Artificial Intelligence -- Search Algorithms
Syed Ahmed
 

What's hot (19)

PPTX
Lecture 12 Heuristic Searches
Hema Kashyap
 
PPTX
Searching Algorithm
Sagacious IT Solution
 
PPT
M3 search
Yasir Khan
 
PPTX
Jarrar: Informed Search
Mustafa Jarrar
 
PPT
Solving problems by searching Informed (heuristics) Search
matele41
 
PDF
2 lectures 16 17-informed search algorithms ch 4.3
Ravi Balout
 
PDF
AI Lesson 05
Assistant Professor
 
PPTX
Control Strategies in AI
Amey Kerkar
 
DOCX
Adsa u2 ver 1.0.
Dr. C.V. Suresh Babu
 
PPT
Iterative deepening search
Ashis Kumar Chanda
 
PPT
Solving problems by searching
Luigi Ceccaroni
 
PPT
Informed search (heuristics)
Bablu Shofi
 
PDF
AI Lesson 06
Assistant Professor
 
PDF
Uninformed search
Amit Kumar Rathi
 
PPT
Lecture 11 Informed Search
Hema Kashyap
 
PPTX
ARTIFICIAL INTELLIGENCE UNIT 2(2)
Dr. SURBHI SAROHA
 
PPT
M4 heuristics
Yasir Khan
 
PDF
Heuristic search
Soheil Khodayari
 
PPT
Searching methodologies
jyoti_lakhani
 
Lecture 12 Heuristic Searches
Hema Kashyap
 
Searching Algorithm
Sagacious IT Solution
 
M3 search
Yasir Khan
 
Jarrar: Informed Search
Mustafa Jarrar
 
Solving problems by searching Informed (heuristics) Search
matele41
 
2 lectures 16 17-informed search algorithms ch 4.3
Ravi Balout
 
AI Lesson 05
Assistant Professor
 
Control Strategies in AI
Amey Kerkar
 
Adsa u2 ver 1.0.
Dr. C.V. Suresh Babu
 
Iterative deepening search
Ashis Kumar Chanda
 
Solving problems by searching
Luigi Ceccaroni
 
Informed search (heuristics)
Bablu Shofi
 
AI Lesson 06
Assistant Professor
 
Uninformed search
Amit Kumar Rathi
 
Lecture 11 Informed Search
Hema Kashyap
 
ARTIFICIAL INTELLIGENCE UNIT 2(2)
Dr. SURBHI SAROHA
 
M4 heuristics
Yasir Khan
 
Heuristic search
Soheil Khodayari
 
Searching methodologies
jyoti_lakhani
 
Ad

Similar to Jarrar: Un-informed Search (20)

PPT
Jarrar.lecture notes.aai.2011s.ch3.uniformedsearch
PalGov
 
PPT
state-spaces29Sep06.ppt
PerumalPitchandi
 
PPTX
AI_03_Solving Problems by Searching.pptx
Yousef Aburawi
 
PDF
Lecture 3 problem solving
Vajira Thambawita
 
PPTX
AI UNIT 2 PPT AI UNIT 2 PPT AI UNIT 2 PPT.pptx
pank011
 
PPT
AI Lecture 3 (solving problems by searching)
Tajim Md. Niamat Ullah Akhund
 
PPTX
Chapter 3.pptx
ashetuterefa
 
PPTX
chapter 3 Problem Solving using searching.pptx
gadisaAdamu
 
PPTX
Lecture 3 Problem Solving.pptx
AndrewKuziwakwasheMu
 
PDF
problem solving in Artificial intelligence .pdf
ElectricalTech3
 
PPTX
Lec#2
Ali Shah
 
PPT
chapter3part1.ppt
ssuser99ca78
 
PPTX
3. ArtificialSolving problems by searching.pptx
NAZMUSSAKIBMDADIL200
 
PPTX
Moduleanaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaad-II.pptx
Baseemkhan3
 
PPT
02-solving-problems-by-searching-(us).ppt
forf7627
 
PPTX
Artificial intelligence(04)
Nazir Ahmed
 
PPSX
Week 2 a - Search.ppsx this is used to search things
laraibjamal1
 
PPTX
l2.pptx
AnujaBeatriceB
 
PPT
Artificial intelligent Lec 3-ai chapter3-search
Taymoor Nazmy
 
Jarrar.lecture notes.aai.2011s.ch3.uniformedsearch
PalGov
 
state-spaces29Sep06.ppt
PerumalPitchandi
 
AI_03_Solving Problems by Searching.pptx
Yousef Aburawi
 
Lecture 3 problem solving
Vajira Thambawita
 
AI UNIT 2 PPT AI UNIT 2 PPT AI UNIT 2 PPT.pptx
pank011
 
AI Lecture 3 (solving problems by searching)
Tajim Md. Niamat Ullah Akhund
 
Chapter 3.pptx
ashetuterefa
 
chapter 3 Problem Solving using searching.pptx
gadisaAdamu
 
Lecture 3 Problem Solving.pptx
AndrewKuziwakwasheMu
 
problem solving in Artificial intelligence .pdf
ElectricalTech3
 
Lec#2
Ali Shah
 
chapter3part1.ppt
ssuser99ca78
 
3. ArtificialSolving problems by searching.pptx
NAZMUSSAKIBMDADIL200
 
Moduleanaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaad-II.pptx
Baseemkhan3
 
02-solving-problems-by-searching-(us).ppt
forf7627
 
Artificial intelligence(04)
Nazir Ahmed
 
Week 2 a - Search.ppsx this is used to search things
laraibjamal1
 
Artificial intelligent Lec 3-ai chapter3-search
Taymoor Nazmy
 
Ad

More from Mustafa Jarrar (20)

PPTX
Clustering Arabic Tweets for Sentiment Analysis
Mustafa Jarrar
 
PPTX
Classifying Processes and Basic Formal Ontology
Mustafa Jarrar
 
PPTX
Discrete Mathematics Course Outline
Mustafa Jarrar
 
PPTX
Business Process Implementation
Mustafa Jarrar
 
PPTX
Business Process Design and Re-engineering
Mustafa Jarrar
 
PPTX
BPMN 2.0 Analytical Constructs
Mustafa Jarrar
 
PPTX
BPMN 2.0 Descriptive Constructs
Mustafa Jarrar
 
PPTX
Introduction to Business Process Management
Mustafa Jarrar
 
PDF
Customer Complaint Ontology
Mustafa Jarrar
 
PPTX
Subset, Equality, and Exclusion Rules
Mustafa Jarrar
 
PPTX
Schema Modularization in ORM
Mustafa Jarrar
 
PPTX
On Computer Science Trends and Priorities in Palestine
Mustafa Jarrar
 
PPTX
Lessons from Class Recording & Publishing of Eight Online Courses
Mustafa Jarrar
 
PPTX
Presentation curras paper-emnlp2014-final
Mustafa Jarrar
 
PPTX
Jarrar: Future Internet in Horizon 2020 Calls
Mustafa Jarrar
 
PPT
Habash: Arabic Natural Language Processing
Mustafa Jarrar
 
PDF
Adnan: Introduction to Natural Language Processing
Mustafa Jarrar
 
PPTX
Riestra: How to Design and engineer Competitive Horizon 2020 Proposals
Mustafa Jarrar
 
PPTX
Bouquet: SIERA Workshop on The Pillars of Horizon2020
Mustafa Jarrar
 
PPTX
Jarrar: Sparql Project
Mustafa Jarrar
 
Clustering Arabic Tweets for Sentiment Analysis
Mustafa Jarrar
 
Classifying Processes and Basic Formal Ontology
Mustafa Jarrar
 
Discrete Mathematics Course Outline
Mustafa Jarrar
 
Business Process Implementation
Mustafa Jarrar
 
Business Process Design and Re-engineering
Mustafa Jarrar
 
BPMN 2.0 Analytical Constructs
Mustafa Jarrar
 
BPMN 2.0 Descriptive Constructs
Mustafa Jarrar
 
Introduction to Business Process Management
Mustafa Jarrar
 
Customer Complaint Ontology
Mustafa Jarrar
 
Subset, Equality, and Exclusion Rules
Mustafa Jarrar
 
Schema Modularization in ORM
Mustafa Jarrar
 
On Computer Science Trends and Priorities in Palestine
Mustafa Jarrar
 
Lessons from Class Recording & Publishing of Eight Online Courses
Mustafa Jarrar
 
Presentation curras paper-emnlp2014-final
Mustafa Jarrar
 
Jarrar: Future Internet in Horizon 2020 Calls
Mustafa Jarrar
 
Habash: Arabic Natural Language Processing
Mustafa Jarrar
 
Adnan: Introduction to Natural Language Processing
Mustafa Jarrar
 
Riestra: How to Design and engineer Competitive Horizon 2020 Proposals
Mustafa Jarrar
 
Bouquet: SIERA Workshop on The Pillars of Horizon2020
Mustafa Jarrar
 
Jarrar: Sparql Project
Mustafa Jarrar
 

Recently uploaded (20)

PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 

Jarrar: Un-informed Search

  • 1. Jarrar © 2014 1 Chapter 3 Un-Informed Search Dr. Mustafa Jarrar Sina Institute, University of Birzeit [email protected] www.jarrar.info Artificial Intelligence Lecture Notes on Uninformed Search Birzeit University, Palestine Fall Semester, 2014
  • 2. Jarrar © 2014 2 Watch this lecture and download the slides from http://jarrar-courses.blogspot.com/2011/11/artificial-intelligence-fall-2011.html Most material is based on chapter 3 of [1]
  • 3. Jarrar © 2014 3 Lecture Outline  Achieve intelligence by (Searching) a solution!  Problem Formulation  Search Strategies – breadth-first – uniform-cost search – depth-first – depth-limited search – iterative deepening – bi-directional search – constraint satisfaction
  • 4. Jarrar © 2014 4 Example: Romania You are in Arad and want to go to Bucharest  How to design an intelligent agent to find the way between 2 cities?
  • 5. Jarrar © 2014 5 Example: The 8-puzzle  How can we design an intelligent agent to solve the 8-puzzel?
  • 6. Jarrar © 2014 8 Motivation • Solve a problem by searching for a solution. Search strategies are important methods for many approaches to problem-solving[2]. • Problem formulation. The use of search requires an abstract formulation of the problem and the available steps to construct solutions. • Optimizing Search. Search algorithms are the basis for many optimization and planning methods.
  • 7. Jarrar © 2014 9 Problem Formulation To solve a problem by search, we need to first formulate the problem. HOW? Our textbook suggest the following schema to help us formulate problems 1. State 2. Initial state 3. Actions or Successor Function 4. Goal Test 5. Path Cost 6. Solution
  • 8. Jarrar © 2014 10 Problem Formulation (The Romania Example) State: We regard a problem as state space here a state is a City Initial State: the state to start from In(Arad) Successor Function: description of the possible actions, give state x, S(X) returns a set of <action, successor> ordered pairs. S(x)= { <Go(Sibiu), In(Sibiu)>, <Go(Timisoara), In(Timisoara)>, <Go(Zerind),In(Zerind)> } Goal Test: determine a given state is a goal state. In(Sibiu) No. In(Zerind) No.…. In(Bucharest)Yes! Path Cost: a function that assigns a numeric cost to each path. – e.g., sum of distances, number of actions executed, etc. – c(x,a,y) is the step cost, assumed to be ≥ 0 Solution: a sequence of actions leading from the initial state to a goal state {Arad Sibiu  Rimnicu Vilcea  Pitesti  Bucharest}
  • 9. Jarrar © 2014 11 Problem Formulation (The 8- Puzzle Example) State: The location of the eight tiles, and the blank Initial State: {(7,0), (2,1), (4,2), (5,3), (_,4), (6,5), (8,6), (3,7), (1,8)} Successor Function: one of the four actions (blank moves Left, Right, Up, Down). Goal Test: determine a given state is a goal state. Path Cost: each step costs 1 Solution: {(_,0),(1,1),(2,2) ,(3,3) ,(4,4) ,(5,5) ,(6,6) ,(7,7) ,(8,8)}
  • 10. Jarrar © 2014 12 Problem Formulation (Real-life Applications) Route Finding Problem • States – locations • Initial state – starting point • Successor function (operators) – move from one location to another • Goal test – arrive at a certain location • Path cost – may be quite complex • money, time, travel comfort, scenery, Car Navigation Routing in Computer networks Military operation planning Airline travel planning
  • 11. Jarrar © 2014 13 Problem Formulation (Real-life Applications) Routing Problem  What is the state space for each of them? A set of places with links between them, which have been visited
  • 12. Jarrar © 2014 14 Problem Formulation (Real-life Applications) Travel Salesperson Problem • States – locations / cities – illegal states • each city may be visited only once • visited cities must be kept as state information • Initial state – starting point – no cities visited • Successor function (operators) – move from one location to another one • Goal test – all locations visited – agent at the initial location • Path cost – distance between locations Based on [2]
  • 13. Jarrar © 2014 15 Problem Formulation (Real-life Applications) VLSI layout Problem • States – positions of components, wires on a chip • Initial state – incremental: no components placed – complete-state: all components placed (e.g. randomly, manually) • Successor function (operators) – incremental: place components, route wire – complete-state: move component, move wire • Goal test – all components placed – components connected as specified • Path cost – maybe complex • distance, capacity, number of connections per component
  • 14. Jarrar © 2014 16 Problem Formulation (Real-life Applications) Robot Navigation • States – locations – position of actuators • Initial state – start position (dependent on the task) • Successor function (operators) – movement, actions of actuators • Goal test – task-dependent • Path cost – maybe very complex • distance, energy consumption
  • 15. Jarrar © 2014 17 Problem Formulation (Real-life Applications) Automatic Assembly Sequencing • States – location of components • Initial state – no components assembled • Successor function (operators) – place component • Goal test – system fully assembled • Path cost – number of moves
  • 16. Jarrar © 2014 18 Searching for Solutions • Traversal of the search space – From the initial state to a goal state. – Legal sequence of actions as defined by successor function. • General procedure – Check for goal state – Expand the current state • Determine the set of reachable states • Return “failure” if the set is empty – Select one from the set of reachable states – Move to the selected state • A search tree is generated – Nodes are added as more states are visited
  • 17. Jarrar © 2014 19 Search Terminology Search Tree – Generated as the search space is traversed • The search space itself is not necessarily a tree, frequently it is a graph • The tree specifies possible paths through the search space – Expansion of nodes • As states are explored, the corresponding nodes are expanded by applying the successor function – this generates a new set of (child) nodes • The fringe (frontier/queue) is the set of nodes not yet visited – newly generated nodes are added to the fringe – Search strategy • Determines the selection of the next node to be expanded • Can be achieved by ordering the nodes in the fringe – e.g. queue (FIFO), stack (LIFO), “best” node w.r.t. some measure (cost)
  • 18. Jarrar © 2014 20 Example: Graph Search • The graph describes the search (state) space – Each node in the graph represents one state in the search space • e.g. a city to be visited in a routing or touring problem • This graph has additional information – Names and properties for the states (e.g. S3) – Links between nodes, specified by the successor function • properties for links (distance, cost, name, ...) S3 A4 C2 D3 E1B2 G0 1 1 1 3 1 3 3 4 5 1 2
  • 19. Jarrar © 2014 21 Traversing a Graph as Tree S3 5 A4 D3 1 1 33 4 2 C2 D3G0 G0 G0 E1 G0 1 1 3 3 4 2 C2 D3 G0 G0 E1 G0 1 3 B2 1 3 C2 D3 G0 G0 E1 G0 1 3 4 E1 G0 2 4 3 2 4 S3 A4 C2 D3 E1B2 G0 1 1 1 3 1 3 3 4 5 1 2  A tree is generated by traversing the graph.  The same node in the graph may appear repeatedly in the tree.  the arrangement of the tree depends on the traversal strategy (search method)  The initial state becomes the root node of the tree  In the fully expanded tree, the goal states are the leaf nodes.  Cycles in graphs may result in infinite branches. 2
  • 20. Jarrar © 2014 22 Searching Strategies Most of the effort is often spent on the selection of an appropriate search strategy for a given problem: – Uninformed Search (blind search) • number of steps, path cost unknown • agent knows when it reaches a goal – Informed Search (heuristic search) • agent has background information about the problem – map, costs of actions Uninformed Search – breadth-first – uniform-cost search – depth-first – depth-limited search – iterative deepening – bi-directional search – constraint satisfaction Informed Search – best-first search – search with heuristics – memory-bounded search – iterative improvement search
  • 21. Jarrar © 2014 23 Evaluation of Search Strategies • A search strategy is defined by picking the order of node expansion • Strategies are evaluated along the following dimensions: • Completeness: if there is a solution, will it be found • Time complexity: How long does it takes to find the solution • Space complexity: memory required for the search • Optimality: will the best solution be found • 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 ∞)
  • 22. Jarrar © 2014 24 1: Breadth-First Search
  • 23. Jarrar © 2014 25 Breadth-First Search All the nodes reachable from the current node are explored first (shallow nodes are expanded before deep nodes). Algorithm (Informal) 1. Enqueue the root/initial node. 2. Dequeue a node and examine it. 1. If the element sought is found in this node, quit the search and return a result. 2. Otherwise enqueue any successors (the direct child nodes) that have not yet been discovered. 3. If the queue is empty, every node on the graph has been examined – quit the search and return "not found". 4. Repeat from Step 2. Based on [3]
  • 24. Jarrar © 2014 26 Breadth-First Snapshot 1 Initial Visited Fringe Current Visible Goal 1 2 3 Fringe: [] + [2,3]
  • 25. Jarrar © 2014 27 Breadth-First Snapshot 2 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 Fringe: [3] + [4,5]
  • 26. Jarrar © 2014 28 Breadth-First Snapshot 3 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 6 7 Fringe: [4,5] + [6,7]
  • 27. Jarrar © 2014 29 Breadth-First Snapshot 4 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 6 7 8 9 Fringe: [5,6,7] + [8,9]
  • 28. Jarrar © 2014 30 Breadth-First Snapshot 5 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 6 7 8 9 10 11 Fringe: [6,7,8,9] + [10,11]
  • 29. Jarrar © 2014 31 Breadth-First Snapshot 6 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 6 7 8 9 10 11 12 13 Fringe: [7,8,9,10,11] + [12,13]
  • 30. Jarrar © 2014 32 Breadth-First Snapshot 7 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Fringe: [8,9.10,11,12,13] + [14,15]
  • 31. Jarrar © 2014 33 Breadth-First Snapshot 8 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Fringe: [9,10,11,12,13,14,15] + [16,17]
  • 32. Jarrar © 2014 34 Breadth-First Snapshot 9 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Fringe: [10,11,12,13,14,15,16,17] + [18,19]
  • 33. Jarrar © 2014 35 Breadth-First Snapshot 10 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 Fringe: [11,12,13,14,15,16,17,18,19] + [20,21]
  • 34. Jarrar © 2014 36 Breadth-First Snapshot 11 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 Fringe: [12, 13, 14, 15, 16, 17, 18, 19, 20, 21] + [22,23]
  • 35. Jarrar © 2014 37 Breadth-First Snapshot 12 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Fringe: [13,14,15,16,17,18,19,20,21] + [22,23] Note: The goal node is “visible” here, but we can not perform the goal test yet.
  • 36. Jarrar © 2014 38 Breadth-First Snapshot 13 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 Fringe: [14,15,16,17,18,19,20,21,22,23,24,25] + [26,27]
  • 37. Jarrar © 2014 39 Breadth-First Snapshot 14 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Fringe: [15,16,17,18,19,20,21,22,23,24,25,26,27] + [28,29]
  • 38. Jarrar © 2014 40 Breadth-First Snapshot 15 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Fringe: [15,16,17,18,19,20,21,22,23,24,25,26,27,28,29] + [30,31]
  • 39. Jarrar © 2014 41 Breadth-First Snapshot 16 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Fringe: [17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]
  • 40. Jarrar © 2014 42 Breadth-First Snapshot 17 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Fringe: [18,19,20,21,22,23,24,25,26,27,28,29,30,31]
  • 41. Jarrar © 2014 43 Breadth-First Snapshot 18 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Fringe: [19,20,21,22,23,24,25,26,27,28,29,30,31]
  • 42. Jarrar © 2014 44 Breadth-First Snapshot 19 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Fringe: [20,21,22,23,24,25,26,27,28,29,30,31]
  • 43. Jarrar © 2014 45 Breadth-First Snapshot 20 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Fringe: [21,22,23,24,25,26,27,28,29,30,31]
  • 44. Jarrar © 2014 46 Breadth-First Snapshot 21 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Fringe: [22,23,24,25,26,27,28,29,30,31]
  • 45. Jarrar © 2014 47 Breadth-First Snapshot 22 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Fringe: [23,24,25,26,27,28,29,30,31]
  • 46. Jarrar © 2014 48 Breadth-First Snapshot 23 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Fringe: [24,25,26,27,28,29,30,31]
  • 47. Jarrar © 2014 49 Breadth-First Snapshot 24 Initial Visited Fringe Current Visible Goal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Fringe: [25,26,27,28,29,30,31] Note: The goal test is positive for this node, and a solution is found in 24 steps.
  • 48. Jarrar © 2014 50 Properties of Breadth-First Search (BFS) • Completeness: Yes (if b is finite), a solution will be found if exists. • Time Complexity: 1+b+b2+b3+… +bd + (bd+1- b) = bd+1 (nodes until the solution) • Space Complexity: bd+1 (keeps every generated node in memory) • Optimality: Yes (if cost = 1 per step) • Suppose the branching factor b=10, and the goal is at depth d=12: – Then we need O1012 time to finish. If O is 0.001 second, then we need 1 billion seconds (31 year). And if each O costs 10 bytes to store, then we also need 1 terabytes. Not suitable for searching large graphs b Branching Factor d The depth of the goal
  • 49. Jarrar © 2014 51 2- Uniform-Cost -First
  • 50. Jarrar © 2014 52 Uniform-Cost -First Visits the next node which has the least total cost from the root, until a goal state is reached. – Similar to BREADTH-FIRST, but with an evaluation of the cost for each reachable node. – g(n) = path cost(n) = sum of individual edge costs to reach the current node.
  • 51. Jarrar © 2014 53 Uniform-Cost Search (UCS)
  • 52. Jarrar © 2014 54 Uniform-Cost Search (UCS)
  • 53. Jarrar © 2014 55 Uniform-Cost Search (UCS)
  • 54. Jarrar © 2014 56 Uniform-Cost Search (UCS)
  • 55. Jarrar © 2014 57 Uniform-Cost Search (UCS)
  • 56. Jarrar © 2014 58 Uniform-Cost Search (UCS)
  • 57. Jarrar © 2014 59 Uniform-Cost Search (UCS)
  • 58. Jarrar © 2014 60 Uniform-Cost Search (UCS)
  • 59. Jarrar © 2014 61 Properties of Uniform-cost Search (UCS) • Completeness Yes (if b is finite, and step cost is positive) • Time Complexity much larger than bd, and just bd if all steps have the same cost. • Space Complexity: as above • Optimality: Yes Requires that the goal test being applied when a node is removed from the nodes list rather than when the node is first generated while its parent node is expanded. b Branching Factor d Depth of the goal/tree
  • 60. Jarrar © 2014 62 Breadth-First vs. Uniform-Cost • Breadth-first search (BFS) is a special case of uniform-cost search when all edge costs are positive and identical. • Breadth-first always expands the shallowest node – Only optimal if all step-costs are equal • Uniform-cost considers the overall path cost – Optimal for any (reasonable) cost function • non-zero, positive – Gets stuck down in trees with many fruitless, short branches • low path cost, but no goal node • Both are complete for non-extreme problems – Finite number of branches – Strictly positive search function
  • 61. Jarrar © 2014 63 3- Depth-First Search
  • 62. Jarrar © 2014 64 Depth-First Search • A depth-first search (DFS) explores a path all the way to a leaf before backtracking and exploring another path. • For example, after searching A, then B, then D, the search backtracks and tries another path from B. • Node are explored in the order A B D E H L M N I O P C F G J K Q L M N O P G Q H JI K FED B C A Based on [4]
  • 63. Jarrar © 2014 65 Depth-First Search • Put the root node on a stack; while (stack is not empty) { remove a node from the stack; if (node is a goal node) return success; put all children of node onto the stack; } return failure; • At each step, the stack contains some nodes from each of a number of levels – The size of stack that is required depends on the branching factor b – While searching level n, the stack contains approximately (b-1)*n nodes • When this method succeeds, it doesn’t give the path Based on [4]
  • 64. Jarrar © 2014 66 Recursive Depth-First Search • Search(node): if node is a goal, return success; for each child c of node { if search(c) is successful, return success; } return failure; • The (implicit) stack contains only the nodes on a path from the root to a goal – The stack only needs to be large enough to hold the deepest search path – When a solution is found, the path is on the (implicit) stack, and can be extracted as the recursion “unwinds” print node and print c and
  • 65. Jarrar © 2014 67 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 b: maximum branching factor of the search tree d: depth of the least-cost solution m: maximum depth of the state space (may be ∞)
  • 66. Jarrar © 2014 68 Depth-First vs. Breadth-First • Depth-first goes off into one branch until it reaches a leaf node – Not good if the goal is on another branch – Neither complete nor optimal – Uses much less space than breadth-first • Much fewer visited nodes to keep track, smaller fringe • Breadth-first is more careful by checking all alternatives – Complete and optimal (Under most circumstances) – Very memory-intensive • For a large tree, breadth-first search memory requirements maybe excessive • For a large tree, a depth-first search may take an excessively long time to find even a very nearby goal node.  How can we combine the advantages (and avoid the disadvantages) of these two search techniques?
  • 67. Jarrar © 2014 69 4- Depth-Limited Search Similar to depth-first, but with a limit – i.e., nodes at depth l have no successors – Overcomes problems with infinite paths – Sometimes a depth limit can be inferred or estimated from the problem description • In other cases, a good depth limit is only known when the problem is solved – must keep track of the depth b branching factor l depth limit • Complete? no (if goal beyond l (l<d), or infinite branch length) • Time? bl • Space? B*l • Optimal? No (if l < d)
  • 68. Jarrar © 2014 70 5- Iterative Deepening Depth-First Search
  • 69. Jarrar © 2014 71 Iterative Deepening Depth-First Search • Applies LIMITED-DEPTH with increasing depth limits • Combines advantages of BREADTH-FIRST and DEPTH-FIRST • It searches to depth 0 (root only), then if that fails it searches to depth 1, then depth 2, etc.
  • 70. Jarrar © 2014 72 Iterative deepening search l =0
  • 71. Jarrar © 2014 73 Iterative deepening search l =1
  • 72. Jarrar © 2014 74 Iterative deepening search l =2
  • 73. Jarrar © 2014 75 Iterative deepening search l =3
  • 74. Jarrar © 2014 76 Iterative Deepening Depth-First Search • If a goal node is found, it is a nearest node and the path to it is on the stack. • Required stack size is limit of search depth (plus 1). • Many states are expanded multiple times • doesn’t really matter because the number of those nodes is small • In practice, one of the best uninformed search methods • for large search spaces, unknown depth
  • 75. Jarrar © 2014 77 Properties of Iterative Deepening Search • Complete: Yes (if the b is finite) • Time: (d+1)b0 + d b1 + (d-1)b2 + … + bd = O(bd) • Space: O(bd) • Optimal: Yes, if step cost = 1 b branching factor d Tree/goal depth
  • 76. Jarrar © 2014 78 Iterative Deepening Search • The nodes in the bottom level (level d) are generated once, those on the next bottom level are generated twice, and so on: NIDS = (d)b + (d-1)b2 + … + (1) bd Time complexity = bd • Compared with BFS: NBFS = b + b2 … + bd + (bd+1 –b) • Suppose b = 10, d = 5, NIDS = 50 + 400 + 3,000 + 20,000 + 100,000 = 123,456 NBFS = 1 + 10 + 100 + 1,000 + 10,000 + 100,000 = 111,111  IDS behaves better in case the search space is large and the depth of goal is unknown.
  • 77. Jarrar © 2014 79 Iterative Deepening Search • When searching a binary tree to depth 7: – DFS requires searching 255 nodes – Iterative deepening requires searching 502 nodes – Iterative deepening takes only about twice as long • When searching a tree with branching factor of 4 (each node may have four children): – DFS requires searching 21845 nodes – Iterative deepening requires searching 29124 nodes – Iterative deepening takes about 4/3 = 1.33 times as long • The higher the branching factor, the lower the relative cost of iterative deepening depth first search Based on [4]
  • 78. Jarrar © 2014 80 6- Bi-directional Search • Search simultaneously from two directions – Forward from the initial and backward from the goal state, until they meet in the middle (i.e., if a node exists in the fringe of the other). – The idea is to have (bd/2 + bd/2) instead of bd, which much less • May lead to substantial savings (if it is applicable), but is has several limitations – Predecessors must be generated, which is not always possible – Search must be coordinated between the two searches – One search must keep all nodes in memory b branching factor d tree depth Time Complexity bd/2 Space Complexity bd/2 Completeness yes (b finite, breadth-first for both directions) Optimality yes (all step costs identical, breadth-first for both directions)
  • 79. Jarrar © 2014 81 Summary • Problem formulation usually requires abstracting away real-world details to define a state space that can feasibly be explored. • Variety of uninformed search strategies Iterative deepening search uses only linear space and not much more time than other uninformed algorithms
  • 80. Jarrar © 2014 82 Summary • Breadth-first search (BFS) and depth-first search (DFS) are the foundation for all other search techniques. • We might have a weighted tree, in which the edges connecting a node to its children have differing “weights” – We might therefore look for a “least cost” goal • The searches we have been doing are blind searches, in which we have no prior information to help guide the search
  • 81. Jarrar © 2014 83 Summary (When to use what) • Breadth-First Search: – Some solutions are known to be shallow • Uniform-Cost Search: – Actions have varying costs – Least cost solution is the required This is the only uninformed search that worries about costs. • Depth-First Search: – Many solutions exist – Know (or have a good estimate of) the depth of solution • Iterative-Deepening Search: – Space is limited and the shortest solution path is required
  • 82. Jarrar © 2014 84 Improving Search Methods • Make algorithms more efficient – avoiding repeated states • Use additional knowledge about the problem – properties (“shape”) of the search space • more interesting areas are investigated first – pruning of irrelevant areas • areas that are guaranteed not to contain a solution can be discarded
  • 83. Jarrar © 2014 85 Project (Car Navigator) Develop a simulation program that takes as input (map, current town, goal town), and returns the path to the goal, as well as the whether the algorithm used is complete, its time and space complexities, and whether it is optimal. The simulator should implement all searching strategies described earlier. Please develop a map (an area in Palestine) to test your program. The size of the map should be: the branching factor (b) is >3, and the depth >10
  • 84. Jarrar © 2014 86 References [1] S. Russell and P. Norvig: Artificial Intelligence: A Modern Approach Prentice Hall, 2003, Second Edition [2] Franz Kurfess: Notes on Artificial Intelligence http://users.csc.calpoly.edu/~fkurfess/Courses/480/F03/Slides/3-Search.pdf [3] "Breadth-first Search." Wikipedia. Wikimedia Foundation. Web. 3 Feb. 2015. <http://en.wikipedia.org/wiki/Breadth-f irst_search>. [4] David Lee Matuszek: Lecture Notes on Tree Searches http://www.cs.nyu.edu/courses/fall06/V22.0102-001/lectures/treeSearching.ppt