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

AI Lecture 12

The lecture covers various problem-solving strategies in artificial intelligence, focusing on search algorithms such as blind, heuristic, depth-first, breadth-first, and bidirectional search. It discusses the complexities of these algorithms, including depth-limited and iterative-deepening strategies, as well as the uniform-cost strategy for finding the lowest cost path. The importance of avoiding repeated states in search processes is also highlighted.

Uploaded by

abdoantar264
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 views20 pages

AI Lecture 12

The lecture covers various problem-solving strategies in artificial intelligence, focusing on search algorithms such as blind, heuristic, depth-first, breadth-first, and bidirectional search. It discusses the complexities of these algorithms, including depth-limited and iterative-deepening strategies, as well as the uniform-cost strategy for finding the lowest cost path. The importance of avoiding repeated states in search processes is also highlighted.

Uploaded by

abdoantar264
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/ 20

Artificial Intelligence

Lecture 12
Problem Solving as Search
& State Space Search

Dr. Mahmoud Bassiouni


[email protected]
Outline
o Blind vs. Heuristic Strategies
o Blind Strategies
o Depth-First Strategy
o Depth-Limited Strategy
o Heuristic Function
o Iterative-Deepening
o Robot Navigation
Strategy
o Examples of Evaluation function
o Breadth-First Strategy
o 8-Puzzle
o Bidirectional Search
Strategy
o More on Heuristic Search & Functions
o Comparison of Blind Search
o Symmetry Reduction
Strategies
o Heuristic Reduction
o Complexity of Basic Search
o Hill Climbing Strategy
Algorithms
o Best-First Search
o Repeated States
o 8-Puzzle Heuristics
o Avoiding Repeated States
o Uniform-Cost Strategy
o Best-First Search
Depth-LimitedStrategy
• You are working depth, but to a limited level. Your
depth is limited.
• You do not move on the tree completely till reaching
the leaves. You say you will move on the tree till level
5 and I will work depth, but until level 5 only.
• When I reach to level 5 I backtrack.
• Let’s consider that the level is 2 then we will work till
level two in the search.
1
• You select a cutoff or called
the maximum depth which is
2 in this example. 2 3

4 5 6 7

8 9 10 11 12 13 14 15
Depth-LimitedStrategy
Depth-first with depth cutoff k (maximal depth below
which nodes are not expanded). You do not exceed
maximum depth.

Three possible outcomes:


• Solution. (you can find it in the area range of k)
• Failure (no solution). (you cannot find it)
• Cutoff (no solution within cutoff, but you can
find it with a bigger value to k). This leads to
iterative deepening strategy.
Iterative-DeepeningStrategy
• Your are deepening in an iterative way.
• In other words, you start with a k equal to 0 for example, is the
node the goal (NO). Then try to increase the k with 5 for example,
did you find the goal (NO). Then try to increase the k with 8 for
example, did you find the goal (NO) then increase the value of
the k and so on till you find the goal.
• It is like a loop, the k has a range from 0 to 2 for example.
Repeat for k = 0, 1, 2, .. :
- Perform depth-first with depth cutoff k
• You apply depth-first till level 0 (found goal NO)
• You apply depth-first till level 1 (found goal NO)
• You apply depth-first till level 2 and so on.
You are going deeper in your tree. This is called iterative deepening
strategy.
Iterative-DeepeningStrategy
• In these strategies, you are applying depth till a specific level. You
are not going further in the subtrees. Your controlling your self to
a specific level and if you did not find the goal then you go the
nodes next to me. It is like you are moving on the breadth of the
tree.
• Therefore, iterative deepening strategy is a mix between the
depth and breadth searching strategies.
Depth-LimitedStrategy
E.g., depth cutoff k = 1

Iterative-Deepening
Strategy
E.g., Repeat for k = 0 to 4
- Perform depth-first with depth cutoff k
ComparingDepth,Breadth,& IterativeDeepening
SearchAlgorithms
o Breadth-first and iterative deepening guarantee shortest
solution.
o Breadth-first: high space complexity. (Fringe expanded
exponentially)
o Depth-first: low space complexity, but may search below
solution depth.
o Iterative deepening: best performance in terms of orders
of complexity.
BidirectionalSearch
Bidirectional search is a graph search algorithm that finds a
shortest path from an initial start state to a goal state in a
directed graph. It runs two simultaneous searches: one
forward from the initial state, and one backward from the
goal, stopping when the two meet.
BidirectionalSearch
• You begin searching from the start and expand the
children and move in a direction, and in the same time
you move from the goal and try to find the parents and
the parents of these parent till we meet at specific node.
Then the path obtained from the two searches is the
final path to goal.

• The reason for this approach is that in many cases it is


faster than depth and breadth. Because the nodes
investigated by the bidirectional search is less than the
number of nodes the depth or breadth are investigating.
Complexityof BasicSearchAlgorithms
• There exist several ways to calculate the complexity of
different search algorithms (more accurate)
• One way is to calculate the number of nodes at the last
level.
• Lets consider this as our tree, and the branching factor is b
(Each node has b children) if each node has two children
then the branching factor is 2. The height of the tree is
called solution depth d.
• Number of nodes at a specific level is b^d.
d

Number of nodes at level d : bd


Complexityof BasicSearchAlgorithms
• The number of nodes at level 0 is 2^0 = 1 b : 2 d = 0
• Number of nodes at level 2 is 2^2 = 4 and so on
• At each level we can calculate the number of nodes by
raising the branching factor ^ depth.

2 3

4 5 6 7

8 9 10 12 13 14 15
BidirectionalSearch
Complexityof BidirectionalSearch
Consider the following case:
- forward and backward branching both b, uniform ..

d/2 d/2

Time ~ bd/2 + bd/2 < bd


Complexityof BasicSearchAlgorithms
• Complexity of the breadth is b^d because the number of nodes at
the last level will be b^d
• If you are going breadth to the half of the tree from one direction
complexity will be b^d/2. If you are going breadth to the second half
of the tree from one direction complexity will be b^d/2
• Total complexity of bidirectional search is : b^(d/2) + b^(d/2) and it is
less that b^d the complexity of breadth
• For example if b = 2 and d = 8 it will give 2^8 = 256 size of the last
level in the tree for breadth
• For bidirectional search it will be 2^4 + 2^4 =16 +16 = 32
AvoidingRepeatedStates

Depth and Breadth-first strategy:


Solution 1:
• Keep track of all states associated with nodes in
current path
• If the state of a new node already exists, then
discard the node
Solution 2:
• Keep track of all states generated so far
• If the state of a new node has already been
generated, then discard the node
Uniform-CostStrategy
• How to search in a state space or tree. The values on the
edges is not equal to 1, but it have different values that
represent the cost of moving from one node to another node.
• You have some cost and this cost must be a positive number. It
should be greater than Zero.

Each step has some cost   > 0.

• The total cost from the initial state to any other state is based
on the summation of the cost of the steps.
• The cost of the path to each fringe node N is

g(N) =  costs of all steps.


Uniform-CostStrategy
• Try to find a path with a minimal cost from the initial state to
the goal state. There can be several paths, but we need the
path with the lowest cost.
• The fringe is queue, but this queue is sorted in an increasing
cost. priority queue
• The lowest cost is added at the beginning, while the highest
cost is added at the end.
Uniform-CostStrategy
• You have the Start State: S and the goal State: G.

• Then you have three states: (A, B, C).

• S to A cost is 1, S to B cost is 5, and S to C cost is 15.

• A to G cost is 10, B to G cost is 5, and C to G cost is 5.

• Start with the start state S is it the goal (NO). Expand and put its children
sorted by cost in the fringe or queue S
A 0
1 10
A B C
S 5 B 5 G
1 5 15
5 Nodes List = (S0)
15 C G G
11 10 Nodes List = (A1, B5, C15)
Nodes List = (B5, G11, C15)
Nodes List = (G10, G11, C15)
Uniform-CostStrategy
• After sorting they are A, B, and C because A has cost 1, then B with cost 5, and
then C with cost 15.

• First you go to the A, then B, and then C. Is A the goal (NO). Expand it and go to
G with cost 10 + 1 = 11.

• Then you go to B, is it the goal (NO) Expand it and you go to G with cost 5 + 5 =
10.

• No need to expand C because 15 is higher than 10 and 11 and the best is S,B,G
A S
0
1 10
S 5 B 5 G A B C
11 55 15
5
15 C
G G Nodes List = (S0)
11 10 Nodes List = (A1, B5, C15)
Nodes List = (B5, G11, C15)
Nodes List = (G10, G11, C15)
THANK YOU

You might also like