Artificial Intelligence Lecture No. 7,8
Artificial Intelligence Lecture No. 7,8
top of stack
Snap shot at iteration 6
frontier
visited
Properties of depth-first search
Cannot move
blank downward
Depth-first search of 8-puzzle with a depth bound of 5
Breadth-first
took
46 nodes.
Depth Limited Search (DLS):
DLS is a variation of DFS. If we put a limit l on how
deep a depth first search can go, we can guarantee that the search will
terminate (either in success or failure).
If there is at least one goal state at a depth less than l, this algorithm is guaranteed
to find a goal state, but it is not guaranteed to find an optimal path.
The space complexity is O(bl), and
the time complexity is O(bl).
Repeated States:
In the above discussion we have ignored an important complication
that often arises in search processes – the possibility that we will waste time by
expanding states that have already been expanded before somewhere else on
the search tree.
Avoiding Repeated States
There are three principal approaches for dealing with
repeated states
• Never return to the state you have just come from
The node expansion function must be prevented from generating
any node successor that is the same state as the node’s parent.
• Never create search paths with cycles in them
The node expansion function must be prevented from generating
any node successor that is the same state as any of the node’s
ancestors.
• Never generate states that have already been generated before
This requires that every state ever generated is remembered,
potentially resulting in space complexity of O(bd).
2. Informed/Directed Search Control Strategy
Some info about problem space(heuristic) is used
to compute preference among the children for
exploration and expansion.
Examples: 1. Best First Search, 2. Problem
Decomposition, A*, Mean end Analysis
Heuristic function:
It maps each state to a numerical value which depicts goodness
of a node.
H(n)=value
Where ,
H() is a heuristic function and ‘n’ is the current state.
Ex: in travelling salesperson problem heuristic
value associated with each node(city) might
reflect estimated distance of the current node
from the goal node.
Y’
Local Maximum
X’
Objective function
P2’
P1’
P2 X P1 Y
State space
• Maximization function is called Objective Function
• Minimization function is called Heuristic Cost function
• Heuristic cost= distance, time, money spent
• Objective function= profit, success
State space
HEURISTIC COST FUNCTION
Local Minimum
Global Minimum
Algorithm for Hill Climbing
A 8 1
E
K
6
13 0
B F
L
S
14
5
5 G
I 1
C
M
H
7
J
OPEN={ S} 6
CLOSED={}
10
D
2
A 8 1
E
K
6
13 0
B F
L
S
14
5
5 G
I 1
C
M
H
7
J
OPEN={ A(2),C(5),B(6)} 6
CLOSED={S}
10
D
2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7+7=19)}
CLOSED={S,A,B,C}
10
4 D
2
A 8
2 18
E 2
5 6 K
13 1
3 0
B F
2 1 L
S 8
1 2 8
2 14
5
5 G 2
5
I 1
C
7 M
4 1
H
7 1 J
6
OPEN={K(5+2+2+1=10), F(18),G(18), D(19),H(19)}
CLOSED={S,A,B,C,E}
10
4 D
2
A 8
2 18
E 2
5 6 K
13 1
3 0
B F
2 1 L
S 8
1 2 8
2 14
5 G 2
5 5
I 1
C
7 M
4 1
H
7 1 J
6
OPEN={ F(18),G(18), D(19),H(19), I(21+5=26)}
CLOSED={S,A,B,C,E,K}
10
4 D
2
A 8
2 18
E 2
5 6 K
13 1
3 0
B F
2 1 L
S 8
1 2 8
2 14
5 G 2
5 5
I 1
C
7 M
4 1
H
7 1 J
6
OPEN={ I(2+3+8+5=18),(F(18),G(18), D(19),H(19), I(26)}
CLOSED={S,A,B,C,E,K,F}
10
4 D
2
A 8
2 18
E 2
5 6 K
13 1
3 0
B F
2 1 L
S 8
1 2 8
2 14
5 G 2
5 5
I 1
C
7 M
4 1
H
7 1 J
6
OPEN={ M(2+3+8+1+1=15),F(18),G(18), D(19),H(19),L(21+0=21) ,I(26)}
CLOSED={S,A,B,C,E,K,F,I}
10
4 D
2
A 8
2 18
E 2
5 6 K
13 1
3 0
B F
2 1 L
S 8
1 2 8
2 14
5 G 2
5 5
I 1
C
7 M
4 1
H
7 1 J
6
OPEN={ L(2+3+8+1+2+0=16), F(18),G(18), D(19),H(19),L(21) ,I(26)}
CLOSED={S,A,B,C,E,K,F,I,M}
10
4 D
2
A 8
2 18
E 2
5 6 K
13 1
3 0
B F
2 1 L
S 8
1 2 8
2 14
5 G 2
5 5
I 1
C
7 M
4 1
H
7 1 J
6
OPEN={F(18),G(18), D(19),H(19),L(21) ,I(26)} GOAL FOUND!!
CLOSED={S,A,B,C,E,K,F,I,M,L}
Problem Reduction and Decomposition
(AND-OR Graphs)
Goal: Acquire
TV