SlideShare a Scribd company logo
1 of 57
Searching
AI, Subash Chandra Pakhrin 1
A search problem
• A Figure below represents a map.
• The nodes represent cities, and the links represent direct road
connections between cities.
• The number associated to a link represents the length of the
corresponding road.
• The search problem is to find a path from a city S to a city G
S
G
D
E
B
A
C
5
3
4
4
6
3
5
AI, Subash Chandra Pakhrin 2
Classes of search methods:
• Uninformed (or blind) search:
• The order in which potential solution paths are considered is arbitrary, using
no domain specific information to judge where the solution is likely to lie
• Informed (heuristic) search:
• The domain dependent (heuristic) information is used in order to search the
space more efficiently.
• Searching using heuristic function.
AI, Subash Chandra Pakhrin 3
Measuring problem solving Performance
We will evaluate the performance of search algorithm in four ways
• Completeness: An algorithm is said to be complete if it definitely finds solution
to the problem, if exist.
• Time Complexity: How long (worst or average case) does it take to find a
solution ?
• Usually measured in terms of the number of nodes expanded.
• Space Complexity: How much space is used by the algorithm ? Usually
measured in terms of the maximum number of nodes in memory at a time.
• Optimality / Admissibility: If a solution is found, is it guaranteed to be an
optimal one ?
AI, Subash Chandra Pakhrin 4
Measuring problem solving Performance
Time and space complexity are measured in terms of
• b – maximum branching factor (number of successor of any node) of
the search tree
• m – maximum depth of the search tree
• d – depth of the shallowest goal node
AI, Subash Chandra Pakhrin 5
A
B
HGE
FB
HGG
FC
D GD E
C
d
m
AI, Subash Chandra Pakhrin 6
Uninformed / Blind Search
Blind Search
• The algorithm doesn’t use any information about the domain
• British Museum Search
• Breadth First Search
• Depth First Search
• Iterative Deepening Search
• Bidirectional Search
AI, Subash Chandra Pakhrin 7
British Museum Approach
• Find every possible path
# Note: Rule we should develop the tree associated with the search in
Lexical (alphabetical) order.
S
A B
B D
C
E
G
A C
D
G
E
British Museum
Expansion of Tree
AI, Subash Chandra Pakhrin 8
Breadth First Search (BFS)
• Build up the tree level by level
• At some point when you scan across a level you will find that you
have completed the path that goes to the goal.
AI, Subash Chandra Pakhrin 9
Breadth First Search (BFS)
• Fringe (OPEN / QUEUE / FRONTIER)
• Fringe is a list of nodes which are waiting to be expanded.
• The new nodes which are generated will be put at the back of
fringe
• Breadth First Search results in the expansion of shallowest nodes
earlier than the deeper nodes.
AI, Subash Chandra Pakhrin 10
Breadth First Search (BFS)
Let fringe be a list containing the initial state
LOOP
if fringe is empty return failure
Node <- remove – first (fringe)
if Node is a goal
then return the path from initial state to Node
else generate all successors of Node,
and %% Expand shallowest node first add generated nodes to the back of fringe
END LOOP
AI, Subash Chandra Pakhrin 11
Search Space (Apply BFS for the search space)
A
G
C
HFD
E
B
AI, Subash Chandra Pakhrin 12
Previous Search
Space will give rise
to the this Search
Tree
A
B
HGE
FB
HGG
FC
D GD E
C
d = 0 Level 0: Expanded
d = 1 Level 1: All nodes Expanded
d = 2 Level 2: All nodes Expanded
d = 3 And so on
AI, Subash Chandra Pakhrin 13
BFS
S
A D
B
E
C
F
G
D A
E E B B
A CECFBFD
It’s an stupid approach:
Because, it extends the path that go to the same node more than once.
AI, Subash Chandra Pakhrin 14
BFS FRINGE Expansion
Initially
• FRINGE: A // we will execute loop of an algorithm.
• FRINGE: BC // remove first node from the FRINGE and get
// its successor
• FRINGE: CDE // B is removed from the FRINGE as B is the
// first node in the FRINGE and successor of
// ‘C’ DE will be generated and merged at the
// back of the FRINGE.
• FRINGE: DEDG // C is removed from the FRINGE and its
// successor D and G are generated and put at
// the back of FRINGE
• FRINGE: EDGCF // D is selected for expansion so, D will be removed
// form FRINGE and its successors C & F will be
// generated and merged at the back of FRINGE
• FRINGE: DGCF // E will be removed from the FRINGE and its
// successor will be put at the back of the fringe
// Since E has no successors it will be simply removed from the
// FRINGE
• FRINGE: GCFBF // D will be removed from the FRINGE and its successors B & F
// will be generated and added to the back of FRINGE.
• G is the next node to be expanded and G happens to be goal node, In this case search will stop.
AI, Subash Chandra Pakhrin 15
Breadth First Search (BFS)
• First node A is expanded then
• Node B is expanded
• Node C is expanded
• Node D is expanded
• Node E is expanded
• Node D is expanded
• Node G is expanded
In BFS nodes are expanded in this order according to their level.
AI, Subash Chandra Pakhrin 16
BFS Evaluation
• Enqueue nodes on FRINGE in FIFO order
• Completeness
• Does it always find a solution if one exists ?
• Yes
• If shallowest goal node is at some finite depth d and if b is finite.
• Optimal (i.e. admissible)
• If all paths have the same cost. Otherwise, finds solution with shortest path
length.
• Exponential Time and Space Complexity, O (b d), where d is the depth
of the solution and b is the branching factor ( i.e. number of children)
at each node.
• A complete search tree of depth d where each non – leaf node has b
children, has a total of
1 + b + b 2 + … + b d = (b d +1 - 1) / (b – 1) = O (b d) nodesAI, Subash Chandra Pakhrin 17
BFS Evaluation
• For a complete search tree of depth 12, where every node at depths
0, 1, 2, … , 11 has 10 children and every node at depth 12 has 0
children, there are O (10 12) nodes in the complete search tree.
• If BFS expands 1000 nodes / sec and each node uses 100 bytes of
storage, then BFS will take 35 years to run in the worst case, and it
will use 111 Terabytes of memory.
AI, Subash Chandra Pakhrin 18
BFS
• Advantages
• Finds the path of minimal length to the goal.
• Disadvantage
• Requires the generation and storage of a tree whose size is exponential the
depth of the shallowest goal node.
AI, Subash Chandra Pakhrin 19
Depth First Search
Let fringe be a list containing the initial state
LOOP
if fringe is empty return failure
Node <- remove – first (fringe)
if Node is a goal
then return the path from initial state to Node
else generate all successors of Node,
and : : Expand deepest node first add generated nodes to the front of
fringe
END LOOP AI, Subash Chandra Pakhrin 20
Depth First Search
• Fringe is
maintained as Last
in First out (LIFO)
structure or a
stack structure.
• We always go
down to left
branch by
convention
A
B
HGE
FB
HGG
FC
D GD E
C
AI, Subash Chandra Pakhrin 21
Depth First Search
S
G
D
E
B
A
C
5
3
4
4
6
3
5
S
A B
B D
C
E
G
Follow Lexical Convention
Dead End
Goal
Back – up or Back Tracking AI, Subash Chandra Pakhrin 22
Depth First Search
FRINGE: S
FRINGE: A B
FRINGE: B D B
FRINGE: C D B
FRINGE: E D B
FRINGE: D B
FRINGE: G B
AI, Subash Chandra Pakhrin 23
Depth First Search S
A
B
C
G
E
FD
AI, Subash Chandra Pakhrin 24
DFS Evaluation
• Completeness
• Does it always find a solution if one exists ?
• NO
• If search space is infinite and search space contains loops then DFS may not find solution.
• Exponential Time Complexity, O (b d), where d is the depth of the
solution and b is the branching factor ( i.e. number of children) at
each node.
• Space Complexity:
• It needs to store only a single path from the root node to a leaf node, along
with remaining unexpanded sibling nodes for each node on the path.
• Total no. of nodes in memory: O (bm)
• Optimal (i.e. admissible)
• DFS expand deepest node first, it expands entire left sub-tree even if right
sub-tree contains goal nodes at levels 2 or 3. Thus we can say DFS may not
always give optimum solution.
AI, Subash Chandra Pakhrin 25
Depth First Search
AI, Subash Chandra Pakhrin 26
A
B
HGE
FB
HGG
FC
D GD E
C
Class work:
Expand this search
tree using Depth
First Search
approach
Depth First Search
Fringe: A
Fringe: BC
Fringe: DEC
Fringe: CFEC
Fringe: GFEC
AI, Subash Chandra Pakhrin 27
Questions
• Consider the following graph. Starting from state A, execute DFS. The
goal node is G. Show the order in which the nodes are expanded.
Assume that the alphabetically smaller node is expanded first to
break ties.
AI, Subash Chandra Pakhrin 28
A
G
C
HFD
E
B
DFS
AI, Subash Chandra Pakhrin 29
1. FRINGE: A
2. FRINGE: BC
3. FRINGE: DEC
4. FRINGE: FEC
5. FRINGE: HEC
6. FRINGE: EC
7. FRINGE: C
7. FRINGE: DG
8. FRINGE: G
Formalizing search in a state space
• A state space is a graph (V, E)
• V is a set of nodes and
• E is a set of arcs
• Each arc has a fixed, positive cost.
• Each node is a data structure
• A state description
• The parent of the node
• Depth of the node
• The operator that generated this node
• Cost of this path (sum of operator costs)
AI, Subash Chandra Pakhrin 30
Formalizing search II
• A solution is a sequence of operators that is associated with a path
from a start node to a goal node.
• Cost of a solution: sum of the arc costs on the solution path
• For large state spaces, it isn’t practical to represent the whole space.
State space search makes explicit a sufficient portion of an implicit
state space graph to find a goal node.
• Each node represents a partial solution path from the start node to
the given node.
• In general, from this node there are many possible paths that have this partial
path as a prefix.
AI, Subash Chandra Pakhrin 31
Some issues
• Search process constructs a search tree, where
• Root is the initial state and
• Leaf nodes are nodes
• Not yet expanded (i.e., in fringe) or
• Having no successors (i.e. “dead ends”)
• Search tree may be infinite because of loops even if state space is
small
• Return a path or a node depending on problem.
AI, Subash Chandra Pakhrin 32
Depth limited search (limit)
Let fringe be a list containing the initial state
LOOP
if fringe is empty return failure
Node <- remove-first (fringe)
if Node is a goal
then return the path from initial state to Node
else if depth of Node = limit return cutoff
else add generated nodes to the front of fringe
End LOOP
AI, Subash Chandra Pakhrin 33
Depth limited search (limit)
• If we limit the depth before hand a solution may not be found at that
depth therefore we have a variation of depth first search which is
called:
Depth First Iterative Deepening (DFID)
AI, Subash Chandra Pakhrin 34
Depth First Iterative Deepening (DFID)
• First do DFS to depth 0 (i.e., treat start node as having no successors),
then, if no solution found, do DFS to depth 1, etc.
AI, Subash Chandra Pakhrin 35
Until solution found do
DFS with depth cutoff c
c = c + 1
Iterative Deepening
• Advantage
• Linear memory requirements of depth-first search
• Guarantee for goal node of minimal depth
• Procedure
• Successive depth-first searches are conducted – each with depth bounds
increasing by 1
AI, Subash Chandra Pakhrin 36
Iterative Deepening Search
AI, Subash Chandra Pakhrin 37
Stages in Iterative-Deepening Search
Iterative Deepening Search
AI, Subash Chandra Pakhrin 38
Stages in Iterative-Deepening Search
Depth First Iterative Deepening (DFID)
• Complete
• Optimal/Admissible if all operators have the same cost. Otherwise,
not optimal but guarantees finding solution of shortest length (like
BFS).
• Time complexity is a little worse than BFS or DFS because nodes near
the top of the search tree are generated multiple times, but because
almost all of the nodes are near the bottom of a tree, the worst case
time complexity is still exponential, O (b d).
AI, Subash Chandra Pakhrin 39
Depth First Iterative Deepening (DFID)
• If branching factor is b and solution is at depth d, then nodes at
depth d are generated once, nodes at depth d-1 are generated twice,
etc.
• Hence b d + 2b (d-1) + … +db <= b d /(1 - 1/b)2 = O(b d)
• Linear space complexity, O(b d), like DFS
• Has advantage of BFS (i.e. completeness) and also advantages of DFS
(i.e. limited space and finds longer paths more quickly)
• Generally preferred for large state spaces where solution depth is
unknown
AI, Subash Chandra Pakhrin 40
Iterative Deepening Search
AI, Subash Chandra Pakhrin 41
• Run Iterative Deepening search on the same graph.
A
G
C
HFD
E
B
Iterative
Deepening
Search
LIMIT = 0
FRINGE: A
LIMIT = 1
FRINGE: A
FRINGE: BC
FRINGE: C
FRINGE: empty
AI, Subash Chandra Pakhrin 42
LIMIT = 2
FRINGE = A
FRINGE = BC
LIMIT = 2
FRINGE = DEC
FRINGE = EC
LIMIT = 2
FRINGE = C
FRINGE = DG
LIMIT = 2
FRINGE = G
GOAL
Bi-directional search
43AI, Subash Chandra Pakhrin
Bi-directional search
44AI, Subash Chandra Pakhrin
Bi-directional search
45AI, Subash Chandra Pakhrin
Bi-directional search
• Alternate searching from the start state towards the goal and from the
goal state towards the start.
• Stops when the frontiers intersect.
• Works well only when there are unique start and goal states.
• Problem: How do we search backwards from goal ?
• Requires the ability to generate “predecessor” states. Predecessors of node n =
all nodes that have n as successor
46AI, Subash Chandra Pakhrin
Bi-directional search
• For bidirectional search to work well, there must be an efficient way to
check whether a given node belongs to the other search tree.
• Select a given search algorithm for each half.
• Can (sometimes) lead to finding a solution more quickly.
47AI, Subash Chandra Pakhrin
Bi-directional search
b = branching factor
d = distance from start to goal state
BFS: O (b d) ;Time and space
complexity
No of Nodes expanded in
BDS: 2* O (b d/2)
48AI, Subash Chandra Pakhrin
Comparing Search Strategies
m = depth of the search tree
49AI, Subash Chandra Pakhrin
Search Graphs
• If the search space is not a tree, but a graph, the search tree may contain
different nodes corresponding to the same state.
50AI, Subash Chandra Pakhrin
A state space that Generates an Exponentially Growing
Search Space
51AI, Subash Chandra Pakhrin
Avoiding Repeated States
• In increasing order of effectiveness in reducing size of state space and
with increasing computational costs:
• Do not return to the state you just came from.
• Do not create paths with cycles in them.
• Do not generate any states that was ever created before.
• CLOSED IS A LIST WHICH KEEPS TRACK OF ALL THE EXPANDED NODE, AND WHENEVER
WE GENERATE A NODE WE CHECK IF IT IS NOT ALREAD IN CLOSED
• Net effect depends on frequency of “loops” in state space.
52AI, Subash Chandra Pakhrin
Graph Search Algorithm
Let fringe be a list containing the initial state // FRINGE = OPEN
Let closed be initially empty // CLOSED WILL KEEP ALL THE EXPANDED NODES
LOOP
If fringe is empty return failure
Node <- remove - first (fringe)
If Node is a goal
then return the path from initial state to Node
else put Node in closed
generate all successors of Node S
For all nodes m in S
if m is not in closed
merge m into fringe
End LOOP
53AI, Subash Chandra Pakhrin
Uniform Cost Search (UCS)
• Modified version of BFS to make optimal.
• Enqueue nodes by path cost.
• Let g(n) = cost of the path from the start node to the current node n.
Sort nodes by increasing value of g.
Expand lowest cost node of the fringe.
Search continues by visiting the next node which has the least total
cost from the root.
• Complete
• Optimal / Admissible
• Exponential time and space complexity, O (b d)
54AI, Subash Chandra Pakhrin
Uniform Cost Search (UCS)
55AI, Subash Chandra Pakhrin
If we do Uniform Cost
Search (UCS) we can
find the minimum
path cost path from
start to goal.
Uniform Cost Search
4
1
341315
11
73612 161810
A
B C
D E F H
I J G1 K L M N G2
Note: Heurisitic
estimates are not
used in this search!
Paths from root
are generated.
4 11
A
B C
11
19
Since B has the least cost,
we expand it.
4
34
11
A
C
F H
1415
Node H has the least cost thus far, so we expand it.
4 11
A
B
4
C
11
A
0
Start with
root node
A.
1315
D E 17
B
19
1315
D E 17
Of our 3 choices, C
has the least cost so
we’ll expand it.
4
34
11
A
C
F
15
B
19
1315
D E 17
1
N
H
7
G215
21
We have a goal, G2 but
need to expand other
branches to see if there is
another goal with less
distance.
4
34
11
A
C
F
B
19
1315
E 17
1
N
H
7
G2
15 21
36
L M
21 18
Note: Both
nodes F and N
have a cost of
15, we chose to
expand the
leftmost node
first. We
continue
expanding until
all remaining
paths are
greater than 21,
the cost of G2
AI, Subash Chandra Pakhrin 56
Uniform Cost Search
AI, Subash Chandra Pakhrin 57
S
A B
B D
C G
A C
D E
S
G
D
E
B
A
C
5
3
4
4
6
3
53 5
7
9 9
11
6
11 12 15
• Extend node that has shortest accumulated length from start node
to the current node.

More Related Content

What's hot

Microprogrammed Control Unit
Microprogrammed Control UnitMicroprogrammed Control Unit
Microprogrammed Control UnitPreethiSureshkumar1
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler designKuppusamy P
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy methodhodcsencet
 
Relationship Among Token, Lexeme & Pattern
Relationship Among Token, Lexeme & PatternRelationship Among Token, Lexeme & Pattern
Relationship Among Token, Lexeme & PatternBharat Rathore
 
Loops in flow
Loops in flowLoops in flow
Loops in flowindhu mathi
 
Intermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignIntermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignKuppusamy P
 
Error Recovery strategies and yacc | Compiler Design
Error Recovery strategies and yacc | Compiler DesignError Recovery strategies and yacc | Compiler Design
Error Recovery strategies and yacc | Compiler DesignShamsul Huda
 
Pipeline and data hazard
Pipeline and data hazardPipeline and data hazard
Pipeline and data hazardWaed Shagareen
 
context free language
context free languagecontext free language
context free languagekhush_boo31
 
Concurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and SynchronizationConcurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and SynchronizationAnas Ebrahim
 
Address mapping
Address mappingAddress mapping
Address mappingrockymani
 
Example of iterative deepening search &amp; bidirectional search
Example of iterative deepening search &amp; bidirectional searchExample of iterative deepening search &amp; bidirectional search
Example of iterative deepening search &amp; bidirectional searchAbhijeet Agarwal
 
Fault tolerance techniques for real time operating system
Fault tolerance techniques for real time operating systemFault tolerance techniques for real time operating system
Fault tolerance techniques for real time operating systemanujos25
 
Interconnection Network
Interconnection NetworkInterconnection Network
Interconnection NetworkHeman Pathak
 

What's hot (20)

Microprogrammed Control Unit
Microprogrammed Control UnitMicroprogrammed Control Unit
Microprogrammed Control Unit
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler design
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
 
Relationship Among Token, Lexeme & Pattern
Relationship Among Token, Lexeme & PatternRelationship Among Token, Lexeme & Pattern
Relationship Among Token, Lexeme & Pattern
 
Loops in flow
Loops in flowLoops in flow
Loops in flow
 
Chapter 8
Chapter 8Chapter 8
Chapter 8
 
Intermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignIntermediate code generation in Compiler Design
Intermediate code generation in Compiler Design
 
Error Recovery strategies and yacc | Compiler Design
Error Recovery strategies and yacc | Compiler DesignError Recovery strategies and yacc | Compiler Design
Error Recovery strategies and yacc | Compiler Design
 
Pipeline and data hazard
Pipeline and data hazardPipeline and data hazard
Pipeline and data hazard
 
context free language
context free languagecontext free language
context free language
 
Concurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and SynchronizationConcurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and Synchronization
 
Subroutines
SubroutinesSubroutines
Subroutines
 
Matrix multiplication
Matrix multiplicationMatrix multiplication
Matrix multiplication
 
Address mapping
Address mappingAddress mapping
Address mapping
 
Branch & bound
Branch & boundBranch & bound
Branch & bound
 
Example of iterative deepening search &amp; bidirectional search
Example of iterative deepening search &amp; bidirectional searchExample of iterative deepening search &amp; bidirectional search
Example of iterative deepening search &amp; bidirectional search
 
Array Processor
Array ProcessorArray Processor
Array Processor
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
 
Fault tolerance techniques for real time operating system
Fault tolerance techniques for real time operating systemFault tolerance techniques for real time operating system
Fault tolerance techniques for real time operating system
 
Interconnection Network
Interconnection NetworkInterconnection Network
Interconnection Network
 

Similar to Final slide4 (bsc csit) chapter 4

PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptxPPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptxRaviKiranVarma4
 
Lecture 08 uninformed search techniques
Lecture 08 uninformed search techniquesLecture 08 uninformed search techniques
Lecture 08 uninformed search techniquesHema Kashyap
 
Uninformed search /Blind search in AI
Uninformed search /Blind search in AIUninformed search /Blind search in AI
Uninformed search /Blind search in AIKirti Verma
 
Search strategies
Search strategiesSearch strategies
Search strategiesShiwani Gupta
 
ARTIFICIAL INTELLIGENCE UNIT 2(2)
ARTIFICIAL INTELLIGENCE UNIT 2(2)ARTIFICIAL INTELLIGENCE UNIT 2(2)
ARTIFICIAL INTELLIGENCE UNIT 2(2)SURBHI SAROHA
 
Chapter 3.pptx
Chapter 3.pptxChapter 3.pptx
Chapter 3.pptxashetuterefa
 
Uniformed tree searching
Uniformed tree searching Uniformed tree searching
Uniformed tree searching Ayaelshiwi
 
uninformed search part 1.pptx
uninformed search part 1.pptxuninformed search part 1.pptx
uninformed search part 1.pptxMUZAMILALI48
 
Artificial intelligence(05)
Artificial intelligence(05)Artificial intelligence(05)
Artificial intelligence(05)Nazir Ahmed
 
Search strategies BFS, DFS
Search strategies BFS, DFSSearch strategies BFS, DFS
Search strategies BFS, DFSKuppusamy P
 
Lecture 16 - Dijkstra's Algorithm.pdf
Lecture 16 - Dijkstra's Algorithm.pdfLecture 16 - Dijkstra's Algorithm.pdf
Lecture 16 - Dijkstra's Algorithm.pdfiftakhar8
 
RPT_AI_03_PartB_UNINFORMED_FINAL.pptx
RPT_AI_03_PartB_UNINFORMED_FINAL.pptxRPT_AI_03_PartB_UNINFORMED_FINAL.pptx
RPT_AI_03_PartB_UNINFORMED_FINAL.pptxRahulkumarTivarekar1
 
Search problems in Artificial Intelligence
Search problems in Artificial IntelligenceSearch problems in Artificial Intelligence
Search problems in Artificial Intelligenceananth
 
2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt
2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt
2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.pptmmpnair0
 
uniformed (also called blind search algo)
uniformed (also called blind search algo)uniformed (also called blind search algo)
uniformed (also called blind search algo)ssuser2a76b5
 
Chap11 slides
Chap11 slidesChap11 slides
Chap11 slidesBaliThorat1
 
3-uninformed-search.ppt
3-uninformed-search.ppt3-uninformed-search.ppt
3-uninformed-search.pptABINASHACHERJEE1
 

Similar to Final slide4 (bsc csit) chapter 4 (20)

PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptxPPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
 
Lecture 08 uninformed search techniques
Lecture 08 uninformed search techniquesLecture 08 uninformed search techniques
Lecture 08 uninformed search techniques
 
Ai unit-4
Ai unit-4Ai unit-4
Ai unit-4
 
Search 1
Search 1Search 1
Search 1
 
Uninformed search /Blind search in AI
Uninformed search /Blind search in AIUninformed search /Blind search in AI
Uninformed search /Blind search in AI
 
Search strategies
Search strategiesSearch strategies
Search strategies
 
Searching
SearchingSearching
Searching
 
ARTIFICIAL INTELLIGENCE UNIT 2(2)
ARTIFICIAL INTELLIGENCE UNIT 2(2)ARTIFICIAL INTELLIGENCE UNIT 2(2)
ARTIFICIAL INTELLIGENCE UNIT 2(2)
 
Chapter 3.pptx
Chapter 3.pptxChapter 3.pptx
Chapter 3.pptx
 
Uniformed tree searching
Uniformed tree searching Uniformed tree searching
Uniformed tree searching
 
uninformed search part 1.pptx
uninformed search part 1.pptxuninformed search part 1.pptx
uninformed search part 1.pptx
 
Artificial intelligence(05)
Artificial intelligence(05)Artificial intelligence(05)
Artificial intelligence(05)
 
Search strategies BFS, DFS
Search strategies BFS, DFSSearch strategies BFS, DFS
Search strategies BFS, DFS
 
Lecture 16 - Dijkstra's Algorithm.pdf
Lecture 16 - Dijkstra's Algorithm.pdfLecture 16 - Dijkstra's Algorithm.pdf
Lecture 16 - Dijkstra's Algorithm.pdf
 
RPT_AI_03_PartB_UNINFORMED_FINAL.pptx
RPT_AI_03_PartB_UNINFORMED_FINAL.pptxRPT_AI_03_PartB_UNINFORMED_FINAL.pptx
RPT_AI_03_PartB_UNINFORMED_FINAL.pptx
 
Search problems in Artificial Intelligence
Search problems in Artificial IntelligenceSearch problems in Artificial Intelligence
Search problems in Artificial Intelligence
 
2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt
2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt
2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt
 
uniformed (also called blind search algo)
uniformed (also called blind search algo)uniformed (also called blind search algo)
uniformed (also called blind search algo)
 
Chap11 slides
Chap11 slidesChap11 slides
Chap11 slides
 
3-uninformed-search.ppt
3-uninformed-search.ppt3-uninformed-search.ppt
3-uninformed-search.ppt
 

More from Subash Chandra Pakhrin

Torsion Angles, ASA Used for prediction of Non - Enzymatic PTM
Torsion Angles, ASA Used for prediction of Non - Enzymatic PTMTorsion Angles, ASA Used for prediction of Non - Enzymatic PTM
Torsion Angles, ASA Used for prediction of Non - Enzymatic PTMSubash Chandra Pakhrin
 
Characterization and identification of lysine succinylation sites based
Characterization and identification of lysine succinylation sites basedCharacterization and identification of lysine succinylation sites based
Characterization and identification of lysine succinylation sites basedSubash Chandra Pakhrin
 
Deep Learning or Convolutional Neural Network
Deep Learning or Convolutional Neural Network Deep Learning or Convolutional Neural Network
Deep Learning or Convolutional Neural Network Subash Chandra Pakhrin
 
Constraint satisfaction problem
Constraint satisfaction problem Constraint satisfaction problem
Constraint satisfaction problem Subash Chandra Pakhrin
 
Intelligent agents (bsc csit) lec 2
Intelligent agents (bsc csit) lec 2Intelligent agents (bsc csit) lec 2
Intelligent agents (bsc csit) lec 2Subash Chandra Pakhrin
 
Final slide (bsc csit) chapter 5
Final slide (bsc csit) chapter 5Final slide (bsc csit) chapter 5
Final slide (bsc csit) chapter 5Subash Chandra Pakhrin
 
Knnowledge representation and logic lec 11 to lec 15
Knnowledge representation and logic lec 11 to lec 15Knnowledge representation and logic lec 11 to lec 15
Knnowledge representation and logic lec 11 to lec 15Subash Chandra Pakhrin
 
Final slide (bsc csit) chapter 2
Final slide (bsc csit) chapter 2Final slide (bsc csit) chapter 2
Final slide (bsc csit) chapter 2Subash Chandra Pakhrin
 
Final slide (bsc csit) chapter 3
Final slide (bsc csit) chapter 3Final slide (bsc csit) chapter 3
Final slide (bsc csit) chapter 3Subash Chandra Pakhrin
 

More from Subash Chandra Pakhrin (20)

Prismoid
PrismoidPrismoid
Prismoid
 
Torsion Angles, ASA Used for prediction of Non - Enzymatic PTM
Torsion Angles, ASA Used for prediction of Non - Enzymatic PTMTorsion Angles, ASA Used for prediction of Non - Enzymatic PTM
Torsion Angles, ASA Used for prediction of Non - Enzymatic PTM
 
COVID 19
COVID 19 COVID 19
COVID 19
 
Lstm covid 19 prediction
Lstm covid 19 predictionLstm covid 19 prediction
Lstm covid 19 prediction
 
Rnn & Lstm
Rnn & LstmRnn & Lstm
Rnn & Lstm
 
Characterization and identification of lysine succinylation sites based
Characterization and identification of lysine succinylation sites basedCharacterization and identification of lysine succinylation sites based
Characterization and identification of lysine succinylation sites based
 
Cnn april 8 2020
Cnn april 8 2020Cnn april 8 2020
Cnn april 8 2020
 
Deep Learning or Convolutional Neural Network
Deep Learning or Convolutional Neural Network Deep Learning or Convolutional Neural Network
Deep Learning or Convolutional Neural Network
 
Ncit 1st ai lab
Ncit 1st ai labNcit 1st ai lab
Ncit 1st ai lab
 
Ai lab
Ai labAi lab
Ai lab
 
Constraint satisfaction problem
Constraint satisfaction problem Constraint satisfaction problem
Constraint satisfaction problem
 
Analysis
AnalysisAnalysis
Analysis
 
Planning
PlanningPlanning
Planning
 
Intelligent agents (bsc csit) lec 2
Intelligent agents (bsc csit) lec 2Intelligent agents (bsc csit) lec 2
Intelligent agents (bsc csit) lec 2
 
Final slide (bsc csit) chapter 5
Final slide (bsc csit) chapter 5Final slide (bsc csit) chapter 5
Final slide (bsc csit) chapter 5
 
Lec 6 bsc csit
Lec 6 bsc csitLec 6 bsc csit
Lec 6 bsc csit
 
Two player games
Two player gamesTwo player games
Two player games
 
Knnowledge representation and logic lec 11 to lec 15
Knnowledge representation and logic lec 11 to lec 15Knnowledge representation and logic lec 11 to lec 15
Knnowledge representation and logic lec 11 to lec 15
 
Final slide (bsc csit) chapter 2
Final slide (bsc csit) chapter 2Final slide (bsc csit) chapter 2
Final slide (bsc csit) chapter 2
 
Final slide (bsc csit) chapter 3
Final slide (bsc csit) chapter 3Final slide (bsc csit) chapter 3
Final slide (bsc csit) chapter 3
 

Recently uploaded

Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 

Recently uploaded (20)

Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 

Final slide4 (bsc csit) chapter 4

  • 2. A search problem • A Figure below represents a map. • The nodes represent cities, and the links represent direct road connections between cities. • The number associated to a link represents the length of the corresponding road. • The search problem is to find a path from a city S to a city G S G D E B A C 5 3 4 4 6 3 5 AI, Subash Chandra Pakhrin 2
  • 3. Classes of search methods: • Uninformed (or blind) search: • The order in which potential solution paths are considered is arbitrary, using no domain specific information to judge where the solution is likely to lie • Informed (heuristic) search: • The domain dependent (heuristic) information is used in order to search the space more efficiently. • Searching using heuristic function. AI, Subash Chandra Pakhrin 3
  • 4. Measuring problem solving Performance We will evaluate the performance of search algorithm in four ways • Completeness: An algorithm is said to be complete if it definitely finds solution to the problem, if exist. • Time Complexity: How long (worst or average case) does it take to find a solution ? • Usually measured in terms of the number of nodes expanded. • Space Complexity: How much space is used by the algorithm ? Usually measured in terms of the maximum number of nodes in memory at a time. • Optimality / Admissibility: If a solution is found, is it guaranteed to be an optimal one ? AI, Subash Chandra Pakhrin 4
  • 5. Measuring problem solving Performance Time and space complexity are measured in terms of • b – maximum branching factor (number of successor of any node) of the search tree • m – maximum depth of the search tree • d – depth of the shallowest goal node AI, Subash Chandra Pakhrin 5
  • 6. A B HGE FB HGG FC D GD E C d m AI, Subash Chandra Pakhrin 6
  • 7. Uninformed / Blind Search Blind Search • The algorithm doesn’t use any information about the domain • British Museum Search • Breadth First Search • Depth First Search • Iterative Deepening Search • Bidirectional Search AI, Subash Chandra Pakhrin 7
  • 8. British Museum Approach • Find every possible path # Note: Rule we should develop the tree associated with the search in Lexical (alphabetical) order. S A B B D C E G A C D G E British Museum Expansion of Tree AI, Subash Chandra Pakhrin 8
  • 9. Breadth First Search (BFS) • Build up the tree level by level • At some point when you scan across a level you will find that you have completed the path that goes to the goal. AI, Subash Chandra Pakhrin 9
  • 10. Breadth First Search (BFS) • Fringe (OPEN / QUEUE / FRONTIER) • Fringe is a list of nodes which are waiting to be expanded. • The new nodes which are generated will be put at the back of fringe • Breadth First Search results in the expansion of shallowest nodes earlier than the deeper nodes. AI, Subash Chandra Pakhrin 10
  • 11. Breadth First Search (BFS) Let fringe be a list containing the initial state LOOP if fringe is empty return failure Node <- remove – first (fringe) if Node is a goal then return the path from initial state to Node else generate all successors of Node, and %% Expand shallowest node first add generated nodes to the back of fringe END LOOP AI, Subash Chandra Pakhrin 11
  • 12. Search Space (Apply BFS for the search space) A G C HFD E B AI, Subash Chandra Pakhrin 12
  • 13. Previous Search Space will give rise to the this Search Tree A B HGE FB HGG FC D GD E C d = 0 Level 0: Expanded d = 1 Level 1: All nodes Expanded d = 2 Level 2: All nodes Expanded d = 3 And so on AI, Subash Chandra Pakhrin 13
  • 14. BFS S A D B E C F G D A E E B B A CECFBFD It’s an stupid approach: Because, it extends the path that go to the same node more than once. AI, Subash Chandra Pakhrin 14
  • 15. BFS FRINGE Expansion Initially • FRINGE: A // we will execute loop of an algorithm. • FRINGE: BC // remove first node from the FRINGE and get // its successor • FRINGE: CDE // B is removed from the FRINGE as B is the // first node in the FRINGE and successor of // ‘C’ DE will be generated and merged at the // back of the FRINGE. • FRINGE: DEDG // C is removed from the FRINGE and its // successor D and G are generated and put at // the back of FRINGE • FRINGE: EDGCF // D is selected for expansion so, D will be removed // form FRINGE and its successors C & F will be // generated and merged at the back of FRINGE • FRINGE: DGCF // E will be removed from the FRINGE and its // successor will be put at the back of the fringe // Since E has no successors it will be simply removed from the // FRINGE • FRINGE: GCFBF // D will be removed from the FRINGE and its successors B & F // will be generated and added to the back of FRINGE. • G is the next node to be expanded and G happens to be goal node, In this case search will stop. AI, Subash Chandra Pakhrin 15
  • 16. Breadth First Search (BFS) • First node A is expanded then • Node B is expanded • Node C is expanded • Node D is expanded • Node E is expanded • Node D is expanded • Node G is expanded In BFS nodes are expanded in this order according to their level. AI, Subash Chandra Pakhrin 16
  • 17. BFS Evaluation • Enqueue nodes on FRINGE in FIFO order • Completeness • Does it always find a solution if one exists ? • Yes • If shallowest goal node is at some finite depth d and if b is finite. • Optimal (i.e. admissible) • If all paths have the same cost. Otherwise, finds solution with shortest path length. • Exponential Time and Space Complexity, O (b d), where d is the depth of the solution and b is the branching factor ( i.e. number of children) at each node. • A complete search tree of depth d where each non – leaf node has b children, has a total of 1 + b + b 2 + … + b d = (b d +1 - 1) / (b – 1) = O (b d) nodesAI, Subash Chandra Pakhrin 17
  • 18. BFS Evaluation • For a complete search tree of depth 12, where every node at depths 0, 1, 2, … , 11 has 10 children and every node at depth 12 has 0 children, there are O (10 12) nodes in the complete search tree. • If BFS expands 1000 nodes / sec and each node uses 100 bytes of storage, then BFS will take 35 years to run in the worst case, and it will use 111 Terabytes of memory. AI, Subash Chandra Pakhrin 18
  • 19. BFS • Advantages • Finds the path of minimal length to the goal. • Disadvantage • Requires the generation and storage of a tree whose size is exponential the depth of the shallowest goal node. AI, Subash Chandra Pakhrin 19
  • 20. Depth First Search Let fringe be a list containing the initial state LOOP if fringe is empty return failure Node <- remove – first (fringe) if Node is a goal then return the path from initial state to Node else generate all successors of Node, and : : Expand deepest node first add generated nodes to the front of fringe END LOOP AI, Subash Chandra Pakhrin 20
  • 21. Depth First Search • Fringe is maintained as Last in First out (LIFO) structure or a stack structure. • We always go down to left branch by convention A B HGE FB HGG FC D GD E C AI, Subash Chandra Pakhrin 21
  • 22. Depth First Search S G D E B A C 5 3 4 4 6 3 5 S A B B D C E G Follow Lexical Convention Dead End Goal Back – up or Back Tracking AI, Subash Chandra Pakhrin 22
  • 23. Depth First Search FRINGE: S FRINGE: A B FRINGE: B D B FRINGE: C D B FRINGE: E D B FRINGE: D B FRINGE: G B AI, Subash Chandra Pakhrin 23
  • 24. Depth First Search S A B C G E FD AI, Subash Chandra Pakhrin 24
  • 25. DFS Evaluation • Completeness • Does it always find a solution if one exists ? • NO • If search space is infinite and search space contains loops then DFS may not find solution. • Exponential Time Complexity, O (b d), where d is the depth of the solution and b is the branching factor ( i.e. number of children) at each node. • Space Complexity: • It needs to store only a single path from the root node to a leaf node, along with remaining unexpanded sibling nodes for each node on the path. • Total no. of nodes in memory: O (bm) • Optimal (i.e. admissible) • DFS expand deepest node first, it expands entire left sub-tree even if right sub-tree contains goal nodes at levels 2 or 3. Thus we can say DFS may not always give optimum solution. AI, Subash Chandra Pakhrin 25
  • 26. Depth First Search AI, Subash Chandra Pakhrin 26 A B HGE FB HGG FC D GD E C Class work: Expand this search tree using Depth First Search approach
  • 27. Depth First Search Fringe: A Fringe: BC Fringe: DEC Fringe: CFEC Fringe: GFEC AI, Subash Chandra Pakhrin 27
  • 28. Questions • Consider the following graph. Starting from state A, execute DFS. The goal node is G. Show the order in which the nodes are expanded. Assume that the alphabetically smaller node is expanded first to break ties. AI, Subash Chandra Pakhrin 28 A G C HFD E B
  • 29. DFS AI, Subash Chandra Pakhrin 29 1. FRINGE: A 2. FRINGE: BC 3. FRINGE: DEC 4. FRINGE: FEC 5. FRINGE: HEC 6. FRINGE: EC 7. FRINGE: C 7. FRINGE: DG 8. FRINGE: G
  • 30. Formalizing search in a state space • A state space is a graph (V, E) • V is a set of nodes and • E is a set of arcs • Each arc has a fixed, positive cost. • Each node is a data structure • A state description • The parent of the node • Depth of the node • The operator that generated this node • Cost of this path (sum of operator costs) AI, Subash Chandra Pakhrin 30
  • 31. Formalizing search II • A solution is a sequence of operators that is associated with a path from a start node to a goal node. • Cost of a solution: sum of the arc costs on the solution path • For large state spaces, it isn’t practical to represent the whole space. State space search makes explicit a sufficient portion of an implicit state space graph to find a goal node. • Each node represents a partial solution path from the start node to the given node. • In general, from this node there are many possible paths that have this partial path as a prefix. AI, Subash Chandra Pakhrin 31
  • 32. Some issues • Search process constructs a search tree, where • Root is the initial state and • Leaf nodes are nodes • Not yet expanded (i.e., in fringe) or • Having no successors (i.e. “dead ends”) • Search tree may be infinite because of loops even if state space is small • Return a path or a node depending on problem. AI, Subash Chandra Pakhrin 32
  • 33. Depth limited search (limit) Let fringe be a list containing the initial state LOOP if fringe is empty return failure Node <- remove-first (fringe) if Node is a goal then return the path from initial state to Node else if depth of Node = limit return cutoff else add generated nodes to the front of fringe End LOOP AI, Subash Chandra Pakhrin 33
  • 34. Depth limited search (limit) • If we limit the depth before hand a solution may not be found at that depth therefore we have a variation of depth first search which is called: Depth First Iterative Deepening (DFID) AI, Subash Chandra Pakhrin 34
  • 35. Depth First Iterative Deepening (DFID) • First do DFS to depth 0 (i.e., treat start node as having no successors), then, if no solution found, do DFS to depth 1, etc. AI, Subash Chandra Pakhrin 35 Until solution found do DFS with depth cutoff c c = c + 1
  • 36. Iterative Deepening • Advantage • Linear memory requirements of depth-first search • Guarantee for goal node of minimal depth • Procedure • Successive depth-first searches are conducted – each with depth bounds increasing by 1 AI, Subash Chandra Pakhrin 36
  • 37. Iterative Deepening Search AI, Subash Chandra Pakhrin 37 Stages in Iterative-Deepening Search
  • 38. Iterative Deepening Search AI, Subash Chandra Pakhrin 38 Stages in Iterative-Deepening Search
  • 39. Depth First Iterative Deepening (DFID) • Complete • Optimal/Admissible if all operators have the same cost. Otherwise, not optimal but guarantees finding solution of shortest length (like BFS). • Time complexity is a little worse than BFS or DFS because nodes near the top of the search tree are generated multiple times, but because almost all of the nodes are near the bottom of a tree, the worst case time complexity is still exponential, O (b d). AI, Subash Chandra Pakhrin 39
  • 40. Depth First Iterative Deepening (DFID) • If branching factor is b and solution is at depth d, then nodes at depth d are generated once, nodes at depth d-1 are generated twice, etc. • Hence b d + 2b (d-1) + … +db <= b d /(1 - 1/b)2 = O(b d) • Linear space complexity, O(b d), like DFS • Has advantage of BFS (i.e. completeness) and also advantages of DFS (i.e. limited space and finds longer paths more quickly) • Generally preferred for large state spaces where solution depth is unknown AI, Subash Chandra Pakhrin 40
  • 41. Iterative Deepening Search AI, Subash Chandra Pakhrin 41 • Run Iterative Deepening search on the same graph. A G C HFD E B
  • 42. Iterative Deepening Search LIMIT = 0 FRINGE: A LIMIT = 1 FRINGE: A FRINGE: BC FRINGE: C FRINGE: empty AI, Subash Chandra Pakhrin 42 LIMIT = 2 FRINGE = A FRINGE = BC LIMIT = 2 FRINGE = DEC FRINGE = EC LIMIT = 2 FRINGE = C FRINGE = DG LIMIT = 2 FRINGE = G GOAL
  • 46. Bi-directional search • Alternate searching from the start state towards the goal and from the goal state towards the start. • Stops when the frontiers intersect. • Works well only when there are unique start and goal states. • Problem: How do we search backwards from goal ? • Requires the ability to generate “predecessor” states. Predecessors of node n = all nodes that have n as successor 46AI, Subash Chandra Pakhrin
  • 47. Bi-directional search • For bidirectional search to work well, there must be an efficient way to check whether a given node belongs to the other search tree. • Select a given search algorithm for each half. • Can (sometimes) lead to finding a solution more quickly. 47AI, Subash Chandra Pakhrin
  • 48. Bi-directional search b = branching factor d = distance from start to goal state BFS: O (b d) ;Time and space complexity No of Nodes expanded in BDS: 2* O (b d/2) 48AI, Subash Chandra Pakhrin
  • 49. Comparing Search Strategies m = depth of the search tree 49AI, Subash Chandra Pakhrin
  • 50. Search Graphs • If the search space is not a tree, but a graph, the search tree may contain different nodes corresponding to the same state. 50AI, Subash Chandra Pakhrin
  • 51. A state space that Generates an Exponentially Growing Search Space 51AI, Subash Chandra Pakhrin
  • 52. Avoiding Repeated States • In increasing order of effectiveness in reducing size of state space and with increasing computational costs: • Do not return to the state you just came from. • Do not create paths with cycles in them. • Do not generate any states that was ever created before. • CLOSED IS A LIST WHICH KEEPS TRACK OF ALL THE EXPANDED NODE, AND WHENEVER WE GENERATE A NODE WE CHECK IF IT IS NOT ALREAD IN CLOSED • Net effect depends on frequency of “loops” in state space. 52AI, Subash Chandra Pakhrin
  • 53. Graph Search Algorithm Let fringe be a list containing the initial state // FRINGE = OPEN Let closed be initially empty // CLOSED WILL KEEP ALL THE EXPANDED NODES LOOP If fringe is empty return failure Node <- remove - first (fringe) If Node is a goal then return the path from initial state to Node else put Node in closed generate all successors of Node S For all nodes m in S if m is not in closed merge m into fringe End LOOP 53AI, Subash Chandra Pakhrin
  • 54. Uniform Cost Search (UCS) • Modified version of BFS to make optimal. • Enqueue nodes by path cost. • Let g(n) = cost of the path from the start node to the current node n. Sort nodes by increasing value of g. Expand lowest cost node of the fringe. Search continues by visiting the next node which has the least total cost from the root. • Complete • Optimal / Admissible • Exponential time and space complexity, O (b d) 54AI, Subash Chandra Pakhrin
  • 55. Uniform Cost Search (UCS) 55AI, Subash Chandra Pakhrin If we do Uniform Cost Search (UCS) we can find the minimum path cost path from start to goal.
  • 56. Uniform Cost Search 4 1 341315 11 73612 161810 A B C D E F H I J G1 K L M N G2 Note: Heurisitic estimates are not used in this search! Paths from root are generated. 4 11 A B C 11 19 Since B has the least cost, we expand it. 4 34 11 A C F H 1415 Node H has the least cost thus far, so we expand it. 4 11 A B 4 C 11 A 0 Start with root node A. 1315 D E 17 B 19 1315 D E 17 Of our 3 choices, C has the least cost so we’ll expand it. 4 34 11 A C F 15 B 19 1315 D E 17 1 N H 7 G215 21 We have a goal, G2 but need to expand other branches to see if there is another goal with less distance. 4 34 11 A C F B 19 1315 E 17 1 N H 7 G2 15 21 36 L M 21 18 Note: Both nodes F and N have a cost of 15, we chose to expand the leftmost node first. We continue expanding until all remaining paths are greater than 21, the cost of G2 AI, Subash Chandra Pakhrin 56
  • 57. Uniform Cost Search AI, Subash Chandra Pakhrin 57 S A B B D C G A C D E S G D E B A C 5 3 4 4 6 3 53 5 7 9 9 11 6 11 12 15 • Extend node that has shortest accumulated length from start node to the current node.

Editor's Notes

  1. Do not generate any states that was ever created before. We need to maintain a list other than fringe in the algorithms: List CLOSED is a list