Professional Documents
Culture Documents
Deepak Khemani
Plaksha University
First Knowledge
Principles
Ontology +
Semantics Experience
Informed Search: Choose a colour that does not conflict with neighbours.
• Constraint Processing:
• Define a set of variables each with their own domain
• Describe the constraints between subsets of variables
• Search for an assignment for each variable such that all
constraints are satisfied
Given
Desired or or
3,5,0 5,0,3
3,2,3 0,5,3
State transition graph
((G L C) (B))
Exercise:
((L C) (G B)) ((L G) (C B)) Write the MoveGen function
((G C) (L B)) Write the GoalTest function
(() (G L C B))
boat
man BM is
is where
where the
the man
boat M
B is
()
man M is where the boat B is
Search Methods in Artificial Intelligence Deepak Khemani, Plaksha University
Which bank is the boat on? The MGLC Problem
A man needs to transport a lion, a goat, and a cabbage across a river.
He has a boat in which he can take only one of them at a time. It is
only his presence that prevents the lion from eating the goat, and the
goat from eating the cabbage. He cannot leave the goat alone with the
lion, nor the cabbage with the goat. How can he take them all across
the river?
Objects on the side where the boat is
(G L C Left)
Exercise:
(Right)
(G Right) (C Right) Write the MoveGen function
(L Right) Write the GoalTest function
(G L C Right)
Man M is in each state shown
1
2
3
4
5
6
A B C D E F
Goal
AI
Applications
Domain descriptions
and
A à (S,B,D)
B à (S,A,D) The GOAL state
A B C
C à (S,G)
D à (A,B,E)
E à (D,G) D G
G à (C,E)
E
We have represented the set of neighbours
as a list returned by the MoveGen function
A B C
S B D S A D S G
A B C A B E A B E C E
S A D D G D G D G
Algorithm SimpleSearch1
A B C
(S)
(ABC)
(SBDBC)
(ABCBDBC)
S B D
(ASADCBDBC)
A B C
Algorithm SimpleSearch2
Search Methods in Artificial Intelligence Deepak Khemani, Plaksha University
The search tree for SimpleSearch2 It does not add nodes
S on CLOSED to OPEN
OPEN CLOSED
A B C
(S) ()
(ABC) (S)
(BDBC) (AS)
B
(DDBC) (BAS)
D
(EDBC) (DBAS)
(GDBC) (EDBAS)
D
At termination it still has extra copies
of D,B and C in OPEN
A
(S) ()
B C
(ABC) (S)
(DBC) (AS)
(EBC) (DAS)
D
(GBC) (EDAS)
A B C A B E A B E C E
S A D D G D G D G
A,S B,S C,S A,D B,D E,D A,D B,D E,D C,G E,G
E,D
CLOSED
((E,D), (D,A), (A,S), (S, nil))
G,E
For example
makePairs([A, B, C, D], S) = [(A,S), (B,S), (C,S), (D,S)]
Only change
MoveGen
OPEN
2 34 Shallowest
2 Nodes First
A Search Tree
4
When the two searches pick the fifth node, coloured green,
they have explored different parts of the search tree,
expanding the four nodes before in the order shown.
Search Methods in Artificial Intelligence Deepak Khemani, Plaksha University
Depth First Search … dives down into the search tree
BFS
DFS
Blue – CLOSED
Blank - OPEN
Start
d
Why?
S à (A,B) A B
A à (S,C)
B à (S,D)
C
C à (E,D,A) D
D à (B,C,G)
E à (C,G) E
G à (D,E)
G
This was pointed out by Siddharth Sagar a student at IIT Dharwad in 2019
Points to note –
𝑳 leaves
DFID inspects (𝑳+𝑰) nodes whereas
Breadth First Search would have inspected 𝑳 nodes
(𝑳+𝑰)
NDFID = NBFS
𝑳
But 𝑳 = (b−1)*𝑰 + 1 for a full tree with branching factor b