0% found this document useful (0 votes)
18 views13 pages

04 05 AI UninformedSearch

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views13 pages

04 05 AI UninformedSearch

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

CSD311: Artificial Intelligence

Search

Many problems can be modelled as searching for an action


sequence to reach one or more goal states from a starting
state.
Examples: Board games (checkers, chess, etc.), puzzles, route
planning, robot path planning, scheduling manufacturing,
protein design, etc.
This is most conveniently modelled as a directed graph where
each node represents a state and each edge is an action that
takes the system from one state to a successor state. An edge
can also have extra data associated with it e.g. cost.
The entire graph represents the reachability map of the search
space.
The graph cannot usually be represented explicitly since it can
be very large. It is implicitly modelled by a succ:S × A → S
function which is an implicit graph constructor. The succ
function can be deterministic or probabilistic.
Uninformed search

Breadth first search.


Depth first search.
Depth-limited search.
Iterative deepening search.
Bi-directional search.
Uniform cost search.
It is assumed there is at least one goal node at finite depth.
Properties of search algorithms

Completeness: An algorithm is complete if it always finds a path in


the search graph provided at least one such path
exists between start node and goal nodes.
Optimality: An algorithm is optimal if it always finds the shortest
or least cost path. If more than one shortest path
exists it need find only one of them.
Time complexity: The time complexity of the algorithm is the
worst case time complexity usually in terms of
branching factor b and maximum path length `.
Space complexity: The space complexity of the algorithm is the
amount of memory (or space) the algorithm takes in
the worst case.
Search algorithms are compared on the basis of these four
properties.
Breadth first search

Algorithm 0.1: Breadth First Search(initNode)

q ← newQueue();
node ← initNode;
while 
(isNotGoalNode(node))
expandNode(node, q);

do comment: Adds unvisited new successors of node to q.

node ← dequeue(q);
return (node);
Bread first search contd.

Algorithm 0.2: expandNode(node, q)

mark(node);
 n ∈ children(node)
for each
if (notMarked(n))
do then q.add(n);
chp

comment: The function children uses the succ function.
BFS properties

BFS is complete and will terminate with goal node at lowest


depth.
If b is the average fan out from each node then BFS requires
O(b d ) expansions and O(b d ) space at depth d.
Depth first search

Algorithm 0.3: Depth first search(initNode)

node ← initNode;
while (isNotGoalNode(node))
do node ← getChild(node);
return (node);

Not complete. Can loop indefinitely if no goal node on path.


Number of node expansions is O(d) and space required is
O(1) at depth d.
Depth limited search

Algorithm 0.4: Depth limited dfs(initNode, D)

comment: D is the max depth limit.


node ← initNode;
depth ← 0;
while 
(isNotGoalNode(node))

 if (depth == D)
then




repeat




 node ← backtrack(node); depth − −;


do until (node! = NULL or depth == 0)
if (depth == 0)




then return (NULL);




node ← getNextUnmarkedChild(node);




mark(node); depth + +;

return (node)
Iterative deepening DFS

Algorithm 0.5: Iterative deepening DFS(initNode)

comment: Iterates depth limited DFS with increasing depth.


node ← initNode;
D ← 1;
repeat
node ← depthLimitedDFS(node, D);
D + +;
until (node! = NULL)
return (node);

Iterative deepening is complete and finds the shallowest solution.


Depth limited DFS is not complete (if goal node depth > D).
Both algorithms expand O(b d ) nodes in the worst case and take
O(bD) space due to back tracking.
Bi-directional search

Expand forward from initNode and backwards from goalNode.


Not feasible when many goal nodes are possible (e.g. chess).
Searches in forward and backward directions can use any
search algorithm.
Assumes actions can be inverted and one can get to the
parent node.
Search stops when forward-backward searches intersect at a
common node.
d
Is complete. Expands O(b 2 ) nodes and takes same space
since all nodes must be remembered.
Summary of uninformed search algorithms

Assumes branching factor b is finite, d is depth of reached goal and p


length of the solution path from start to reached goal, ` is the depth
limit. Note that p ≥ d. We are not using edge costs here. Assumes
bi-directional uses BF in both directions. Optimality is left out since
costs are not being considered.
Criterion BFS DFS Depth ltd. It’ive deepening Bi-directional
Completeness Yes No No Yes Yes
d
Time O(b d ) O(b m ) O(b ` ) O(b d ) O(b 2 )
d
Space O(b d ) O(bm) O(b`) O(bd) O(b 2 )
Algorithm 0.6: Uniform cost search(initNode)

comment: Assumes each edge cost >  > 0.


node ← initNode;
while isNotGoalNode(node)
node ← findMinCostNode(node);
do
mark(node);
return (node);

Expands node with lowest path cost storing cost in a priority


queue ordered by path cost. Test for goal node applied when
it is selected for expansion not at time it is generated.
Will find goal node if it is cheapest in a path sense -
guaranteed by condition on costs.
C
O(b  ) worst case time and space, C is cost of optimal path.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy