1
00:00:48,649 --> 00:00:55,649
Today's class is the first chapter that we
are going to take up in this course. The topic
2
00:00:56,629 --> 00:01:03,629
is problem solving by search. Slides, please.
Under problem solving by search, we will look
3
00:01:09,939 --> 00:01:16,939
at several different search frameworks. The
first is what we will call state space search.
4
00:01:18,170 --> 00:01:23,049
Here we will see how a real world problem
can be mapped into a state space, and then
5
00:01:23,049 --> 00:01:28,860
we can have search algorithms for searching
out the goals in the state space. Under these,
6
00:01:28,860 --> 00:01:34,740
we are going to look at 2 different types
of search, namely uninformed search or blind
7
00:01:34,740 --> 00:01:40,170
search: these are search problems where we
do not know any domain specific information,
8
00:01:40,170 --> 00:01:44,979
so we have to search without any additional
knowledge; and the second thing will be informed
9
00:01:44,979 --> 00:01:51,670
or heuristic search, where we will have functions
to guide the search procedure. And we will
10
00:01:51,670 --> 00:01:57,819
also study some algorithms for informed heuristic
search. The next topic that we will study
11
00:01:57,819 --> 00:02:03,349
is problem deduction search. This will be
done in the next lecture, and this will talk
12
00:02:03,349 --> 00:02:09,739
about problems which can be decomposed into
sub-problems, in a flavor similar to dynamic
13
00:02:09,739 --> 00:02:16,739
programming, except that we will try to understand
through search, how best to solve the problem.
14
00:02:16,920 --> 00:02:23,920
Take for example integration by parts. You
remember integration by parts? We can solve
15
00:02:24,300 --> 00:02:29,690
the same problem in different ways. So, we
will associate a cost function with every
16
00:02:29,690 --> 00:02:34,239
kind of solution, and then try to see what
is the best way to decompose the problem into
17
00:02:34,239 --> 00:02:40,480
parts and solve it the best way, okay? That
is what we will learn in problem reduction
18
00:02:40,480 --> 00:02:46,650
search. And finally, we will have a look at
game tree search, to give you an idea how
19
00:02:46,650 --> 00:02:52,640
about how chess playing programs work. We
will have a few lectures on search in game
20
00:02:52,640 --> 00:02:59,640
trees and see how you can do optimization
in the presence of an adversary. And I will
21
00:02:59,989 --> 00:03:06,659
briefly touch upon some advances in the search
area, which is mostly research d1 in our department
22
00:03:06,659 --> 00:03:12,909
by our AI group. This is memory bounded search,
multi-objective search and learning how to
23
00:03:12,909 --> 00:03:18,489
search. So these will be I will just briefly
touch upon what these topics are.
24
00:03:18,489 --> 00:03:25,489
Right. So, coming to state space search, the
basic search problem is as follows: we are
25
00:03:26,989 --> 00:03:33,989
given 4 tuples. The 4 tuples In the 4 tuples,
the first is S, which is the set of states
26
00:03:36,829 --> 00:03:43,829
which is implicitly specified. Now this is
very important. If you have a graph and you
27
00:03:46,689 --> 00:03:53,590
are asked to find out the shortest path from
1 node to another node in a graph, well, we
28
00:03:53,590 --> 00:03:57,909
know that we can do it by Dijkstra's or any
other shortest path algorithm. And the problem
29
00:03:57,909 --> 00:04:03,459
is not hard. We have polynomial time algorithms
for doing that. But in AI, we are going to
30
00:04:03,459 --> 00:04:09,829
look at problems where the graph is not explicit.
And I will shortly come to some examples over
31
00:04:09,829 --> 00:04:16,829
that, where the graph is specified in terms
of a start state s which we have here- the
32
00:04:17,620 --> 00:04:24,620
start state s and a set of state transition
operators called O. So, if you apply the state
33
00:04:25,800 --> 00:04:31,330
transition operators on the states that will
give you the next states of the current state.
34
00:04:31,330 --> 00:04:38,330
It is like you studied in switching. When
you specify your finite state machine, you
35
00:04:38,760 --> 00:04:43,730
can either specify the whole finite state
machine graph or you can actually just specify
36
00:04:43,730 --> 00:04:48,460
the state transition function or the next
state function. When you specify just the
37
00:04:48,460 --> 00:04:54,060
next state function, then the actual state
space is exponential in size of the next state
38
00:04:54,060 --> 00:05:01,060
function, right? Suppose I have a next state
function for a 4-bit state machine. Then,
39
00:05:02,530 --> 00:05:07,280
you can potentially have 2 to the power of
4 states, but that does not mean that the
40
00:05:07,280 --> 00:05:12,050
next state function is of size 2 to the power
of 4. We do not actually present the truth
41
00:05:12,050 --> 00:05:18,180
table of the next state function. Instead,
what we have is a function which specifies
42
00:05:18,180 --> 00:05:24,060
the next step. Similarly, in AI also, we will
have lots of problems where the search space
43
00:05:24,060 --> 00:05:29,620
is implicitly specified and the state transition
operators will enable us to unfold the state
44
00:05:29,620 --> 00:05:36,610
space. We are also given the set of goals
which will again be specified in terms of
45
00:05:36,610 --> 00:05:42,919
some formula and our objective is to find
a sequence of state transitions, from the
46
00:05:42,919 --> 00:05:46,370
start state s to a goal state.
47
00:05:46,370 --> 00:05:52,250
So, in the basic problem we are satisfied
by any goal state. Later on, when we go for
48
00:05:52,250 --> 00:05:59,250
optimization problems, we will look for the
best goal state, right? Okay. The copies of
49
00:06:11,439 --> 00:06:16,629
these transparencies are in my website, so
whatever you want to write down, you can always
50
00:06:16,629 --> 00:06:23,629
download from there and write it down. Let
me take up a few examples. The first example
51
00:06:23,819 --> 00:06:29,889
that we will take up is the 8-puzzle problem.
How many of you have seen the 15-puzzle problem?
52
00:06:29,889 --> 00:06:36,889
Okay, let me just briefly explain. I think
once I tell you what the 15-puzzle is, you
53
00:06:36,909 --> 00:06:43,909
will remember. The 15 or the less say that
the 8-puzzle, is a puzzle where you have a
54
00:06:48,030 --> 00:06:55,030
square grid having nine spaces, and there
are tiles in each of these spaces. Say I have
55
00:07:00,500 --> 00:07:07,500
and these tiles are numbered from 1 to eight.
Suppose I have 1 here, 3 here, 2... right?
56
00:07:15,400 --> 00:07:22,400
And 1 of the places is a blank, right? And
this is a sample start state. Suppose we want
57
00:07:31,860 --> 00:07:38,860
to reach some goal state and let us say the
goal state is the 1 where all these numbers
58
00:07:43,499 --> 00:07:48,379
are properly arranged, all these tiles are
properly arranged.
59
00:07:48,379 --> 00:07:55,379
Suppose this is the goal state. And now we
want to go from here to here, and the way
60
00:07:59,139 --> 00:08:05,120
to do that is slide the tiles. So, you can
slide this tile here, or you can slide this
61
00:08:05,120 --> 00:08:10,139
tile here, or you can slide this tile here,
right? And keep on this doing this procedure,
62
00:08:10,139 --> 00:08:14,919
until you have been able to arrange all these
tiles in the final form, right? You are not
63
00:08:14,919 --> 00:08:21,129
allowed to pick up a tile and move it into
another place; you just can move them by sliding
64
00:08:21,129 --> 00:08:28,129
the tiles. So, the version of this problem
with 15 tiles, which is a 4 by 4 square, is
65
00:08:30,800 --> 00:08:37,610
the 1 which is most popular. But because that
is much larger problem, we are just talking
66
00:08:37,610 --> 00:08:44,390
about the 8-puzzle, where you have 8 tiles
and 1 blank. Let us see- how do we formulate
67
00:08:44,390 --> 00:08:46,840
the state space of this?
68
00:08:46,840 --> 00:08:53,840
We can say that the state description is the
location of each of the 8 tiles and the blank,
69
00:08:56,200 --> 00:09:03,200
okay? Now, if you note here, that if we just
indicate the position of the blank and the
70
00:09:04,900 --> 00:09:11,900
tiles, then what are the operators that can
operate? Shift right, shift left, of? Yes,
71
00:09:17,400 --> 00:09:24,400
the only operators that we need to consider
are the 4 operators for moving the blank left,
72
00:09:25,430 --> 00:09:31,440
right, up or down. So, if you just indicate
the way in which the blank moves, that is
73
00:09:31,440 --> 00:09:36,970
sufficient. For example, from here, the blank
can move up, it can move left, it can move
74
00:09:36,970 --> 00:09:42,520
right. It cannot move towards the bottom,
because we will fall off the end of the puzzle.
75
00:09:42,520 --> 00:09:48,850
Right. So, if we just indicate the motion
of the blank, that is sufficient to indicate
76
00:09:48,850 --> 00:09:55,850
the possible state transition operators, right?
Here we have out of 4 operators; not all of
77
00:10:00,890 --> 00:10:07,890
them are applicable on each state. In a given
state, it could be that 2 operators are applicable,
78
00:10:08,570 --> 00:10:15,570
3 operators are applicable or all 4 operators
are applicable. The search paradigm will start
79
00:10:16,310 --> 00:10:21,850
from the start state, which is the starting
configuration, and try to use these operators
80
00:10:21,850 --> 00:10:26,540
systematically, so that we reach 1 of the
goal configurations.
81
00:10:26,540 --> 00:10:31,690
In this case, as we said, that the goal configuration
could be the set of tiles arranged in the
82
00:10:31,690 --> 00:10:38,690
proper sequence. It could be any other goal
configuration. Interestingly, not all goal
83
00:10:39,070 --> 00:10:44,150
configurations are reachable. For example,
in 15-puzzle problem, if you physically pick
84
00:10:44,150 --> 00:10:51,150
up 2 tiles, and exchange them, then the configuration
that you reach cannot be reached from the
85
00:10:51,900 --> 00:10:58,900
original configuration. Suppose I start from
configuration x and I just swap the positions
86
00:11:00,000 --> 00:11:07,000
of 2 tiles- any 2 tiles- and try to reach
this configuration, instead of swapping by
87
00:11:09,430 --> 00:11:16,430
sliding tiles. Well, you cannot do it. Actually,
the state space is partitioned into 2 parts.
88
00:11:17,750 --> 00:11:22,960
You can reach half of the states by sliding
this from this configuration and the remaining
89
00:11:22,960 --> 00:11:29,010
half by sliding from the other configuration,
right?
90
00:11:29,010 --> 00:11:36,010
Let us look at another example. This is the
8 queens' problem, which I am sure most of
91
00:11:36,320 --> 00:11:43,320
you are familiar with. 8 queens' problem is
placing 8 queens on a chess board so that
92
00:11:43,450 --> 00:11:50,450
none of the queens can attack the other. Everyone
is familiar with chess, right? So, a queen
93
00:11:53,120 --> 00:12:00,120
can move horizontally, vertically and diagonally,
so which means that if I put a queen on 1
94
00:12:02,610 --> 00:12:09,610
of the grid points, then I cannot put anything
in this same any other queen in the same diagonal,
95
00:12:11,820 --> 00:12:17,880
in the same row and in the same column, right?
So, I have to put the 8 queens on the chess
96
00:12:17,880 --> 00:12:24,880
board, so that none of them attack each other.
Now, if we look at the state space formulation,
97
00:12:24,880 --> 00:12:30,440
there are many ways in which we can do this.
I am going to give you 3 formulations. The
98
00:12:30,440 --> 00:12:37,440
first formulation is that the state is any
arrangement of the 0 to 8 queens on the board,
99
00:12:37,880 --> 00:12:44,880
right? So, there is no systematic way of putting
the queens. I will just put 0 to 8 queens
100
00:12:45,370 --> 00:12:50,870
on the board. Now, what I mean by 0 to 8 is
that it could be any number. So, I have placed
101
00:12:50,870 --> 00:12:57,870
4 queens, let us say, and the next step is
to add a queen to any square, right? This
102
00:13:00,950 --> 00:13:07,490
is an unsystematic way of doing it. I take
the first queen, place it anywhere; take the
103
00:13:07,490 --> 00:13:14,490
second queen and just place it to any other
square, where it does not attack. Now, I am
104
00:13:15,420 --> 00:13:22,420
not going row-wise or column-wise or anything
like that. This is formulation number 1. Clear?
105
00:13:25,120 --> 00:13:32,120
Formulation number 2 is a state is any arrangement
of 0 to 8 queens with none attacked, but the
106
00:13:38,410 --> 00:13:45,410
operators will always place a queen in the
left-most empty column. What does that mean?
107
00:13:46,150 --> 00:13:53,150
It means- suppose I start with the chess board.
So, I will place the first queen in the first
108
00:13:58,110 --> 00:14:05,110
column. Suppose I place it here. Then the
next queen what the operators will try to
109
00:14:07,490 --> 00:14:14,490
do is- the next queen will be put in the second
column, in a way that it does not attack the
110
00:14:16,880 --> 00:14:23,880
first queen. So, we can put it, say here,
for example, right? Then, if we again apply
111
00:14:24,760 --> 00:14:31,760
the operator, the third queen will be placed
in, again, some square which is not attacked
112
00:14:33,760 --> 00:14:40,760
by the first 2. In this way we continue, and
this is the state space definition. But you
113
00:14:41,940 --> 00:14:47,580
can also- instead of placing the second queen
here, you could have placed it here also,
114
00:14:47,580 --> 00:14:54,580
or here or here. These are all the different
operators to place the queens, right. But
115
00:14:55,760 --> 00:15:02,000
after placing the first queen, when I am applying
the operators, I will never attempt to put
116
00:15:02,000 --> 00:15:08,580
a queen in the third, 4th or fifth column
until I have put a queen in the second column.
117
00:15:08,580 --> 00:15:15,580
We are going left columns left to right, okay?
This is formulation 2. It is slightly more
118
00:15:16,650 --> 00:15:23,650
systematic.
119
00:15:26,240 --> 00:15:33,240
Right. Formulation 3 is where a state is any
arrangement of 8 queens- 1 in each column.
120
00:15:42,350 --> 00:15:49,350
So, I just without looking at any of the constants,
I place 8 queens on the board, 1 in each column.
121
00:15:52,300 --> 00:15:59,300
They will attack each other, and then the
operators move an attacked queen to another
122
00:15:59,320 --> 00:16:06,310
square in the same column, right? Here, the
formulation is slightly different. In the
123
00:16:06,310 --> 00:16:12,380
previous 2 formulations, we were maintaining
a valid partial solution and trying to grow
124
00:16:12,380 --> 00:16:19,380
it into a total solution, right, and this
formulation is what we call an iterative refinement
125
00:16:20,320 --> 00:16:26,420
or iterative corrective procedure, where we
just start with any formulation, any arrangement
126
00:16:26,420 --> 00:16:33,420
of the queens, and try to correct them based
on the constraints. So, we will study some
127
00:16:35,680 --> 00:16:42,680
kinds of search algorithms which work in this
way.
128
00:16:44,560 --> 00:16:50,420
In formulation 3 also, you will definitely
get a solution right, but it may so happen,
129
00:16:50,420 --> 00:16:55,380
that when you move an attacked queen to another
square in the same column, you will move into
130
00:16:55,380 --> 00:17:01,390
another place which is also attacked, and
then keep on doing this shuffling, until you
131
00:17:01,390 --> 00:17:08,390
reach a configuration where none is attacked.
If you just think over it you will see that
132
00:17:08,789 --> 00:17:15,789
even this formulation is complete. That is,
it allows you to visit all the valid goal
133
00:17:16,000 --> 00:17:21,860
configurations, but again, I have just shown
you the formulations here, I have not told
134
00:17:21,860 --> 00:17:28,860
you how to solve them. Next thing that we
will look at is- how do we actually go about,
135
00:17:29,010 --> 00:17:34,780
to systematically solve such problems? But
the kind of formulation that you do is very
136
00:17:34,780 --> 00:17:38,309
important. If you can do a good formulation,
then your search effort will be less. If you
137
00:17:38,309 --> 00:17:42,940
do a bad formulation, your search effort will
be more. Right?
138
00:17:42,940 --> 00:17:49,940
The final example is the famous Missionaries
and Cannibals problem. So, the story is like
139
00:17:51,679 --> 00:17:58,679
this- that you have 3 missionaries and 3 cannibals
on 1 side of the river, along with a boat
140
00:17:59,370 --> 00:18:05,800
that can hold 1 or 2 people. Now, you have
to transport all the missionaries and all
141
00:18:05,800 --> 00:18:12,800
the cannibals to the other side, but if, at
any point of time, the number of cannibals
142
00:18:12,970 --> 00:18:17,510
are more than the number of missionaries,
then, that is the end of the remaining missionaries-
143
00:18:17,510 --> 00:18:23,560
the cannibals will finish them off.
144
00:18:23,560 --> 00:18:30,560
The question is, how do we transport them
to the other side of the river? Let me first
145
00:18:31,710 --> 00:18:38,710
show you 1 solution for doing this. In this
solution, let us see how we transport them
146
00:18:41,800 --> 00:18:48,800
to the other side. Let us say that I will
use rounds for the missionaries and crosses
147
00:18:52,630 --> 00:18:59,630
for the cannibals. This is the initial state,
where all the missionaries and all the cannibals
148
00:19:05,440 --> 00:19:12,440
are on the left side of the bank. This is
our boat, right? So, this state I will denote
149
00:19:14,740 --> 00:19:21,740
by 3, 3 and 0, where this 3 denotes the number
of missionaries, this 3 denotes the number
150
00:19:25,720 --> 00:19:32,720
of cannibals and this flag, which will toggle
between 0 and 1, indicates that the boat is
151
00:19:32,850 --> 00:19:38,960
now in the left bank, right? Okay.
152
00:19:38,960 --> 00:19:45,960
Then, what are the things that we can do?
We can transport 1 cannibal and 1 missionary
153
00:19:50,160 --> 00:19:56,460
to the other side, or we can send 1 cannibal,
or we can send 1 missionary. If we send 1
154
00:19:56,460 --> 00:20:00,920
missionary, then, the number of cannibals
will have a majority on this bank, because
155
00:20:00,920 --> 00:20:05,880
we will have 3 cannibals and 2 missionaries
left. So, that will be the end of these 2
156
00:20:05,880 --> 00:20:11,470
missionaries, right? Let me first show you
the solution, then, we will see what is the
157
00:20:11,470 --> 00:20:18,470
formulation of the problem. Let us say, that
I start by sending 2 cannibals to the other
158
00:20:20,280 --> 00:20:27,280
side. If I send 2 cannibals to the other side,
then what I have here is 3 missionaries here,
159
00:20:29,550 --> 00:20:36,550
and 2 cannibals here, 1 cannibal here. But
the boat is now on this side. This is the
160
00:20:37,050 --> 00:20:43,790
state where I have 3 missionaries here, 1
cannibal here and the boat is on the other
161
00:20:43,790 --> 00:20:50,790
side. So, 1, right? Then next, 1 of the cannibals
will have to bring the boat back. So, this
162
00:20:56,180 --> 00:20:59,880
cannibal will take the boat back.
163
00:20:59,880 --> 00:21:06,880
In the next state, I will have 3 missionaries
here, 2 cannibals here and 1 cannibal on the
164
00:21:08,440 --> 00:21:15,440
other side. The boat is here and this state
is 3, 2 and 0, right? Then, what
do I do? Okay. Next, I will send 2 cannibals
165
00:21:26,130 --> 00:21:33,130
to the other side. If you send 1 missionary
and 1 cannibal, you will land up in trouble
166
00:21:36,170 --> 00:21:42,140
in the next step, so that is where the search
paradigm will come in. I know the solution.
167
00:21:42,140 --> 00:21:48,180
That is why I am writing it down cleanly,
but the search algorithm will attempt to find
168
00:21:48,180 --> 00:21:53,760
out in an automated way. The next After these
2 cannibals are on the other side, I will
169
00:21:53,760 --> 00:21:58,680
have all 3 cannibals on that side and all
3 missionaries on this side, and the boat
170
00:21:58,680 --> 00:22:05,680
is on the other side, right? This is the state
where I have 3, 0 and 1.
171
00:22:09,809 --> 00:22:16,809
In the next state, 1 of the cannibals will
bring the boat back and the state that I will
172
00:22:16,960 --> 00:22:23,960
have is 2 cannibals on that side, 3 missionaries
here and 1 cannibal. And the boat is here.
173
00:22:24,830 --> 00:22:31,830
So, this is the state- 3, 1 and 0, right?
Then, I will send 2 missionaries to the other
174
00:22:37,880 --> 00:22:44,880
side. If I send 2 missionaries to the other
side, so I will have 2 cannibals and 2 missionaries
175
00:22:45,980 --> 00:22:51,809
on the other side, and 1 cannibal and 1 missionary
here. And the boat is on the other side. So,
176
00:22:51,809 --> 00:22:58,809
this is one, 1 and one. Then, I will send
1 missionary and 1 cannibal to bring the boat
177
00:23:01,309 --> 00:23:08,309
back, right? If I send 2- if I send 1 cannibal,
then I will be in trouble on this bank. If
178
00:23:09,390 --> 00:23:14,450
I send 1 missionary, then the remaining missionaries
will be in trouble in this bank. So, I have
179
00:23:14,450 --> 00:23:21,320
to send 1 missionary and 1 cannibal. When
I send 1 missionary and 1 cannibal back here,
180
00:23:21,320 --> 00:23:28,320
then what I will have here is 1 missionary,
1 cannibal here 2; missionaries and 2 cannibals
181
00:23:31,030 --> 00:23:38,030
here, and the boat is now in this side, right?
Then, I will send both the missionaries to
182
00:23:38,130 --> 00:23:45,130
the other bank. So, I will have 2 cannibals
here, all 3 missionaries here and 1 cannibal
183
00:23:48,420 --> 00:23:55,420
here. And this, right? Then the remaining
is part is easy, right? You send the cannibal
184
00:23:57,600 --> 00:24:04,520
back. You have all 3 cannibals here, all 3
missionaries here, and the cannibals have
185
00:24:04,520 --> 00:24:05,340
the boat.
186
00:24:05,340 --> 00:24:11,330
So, now they can transport themselves. What
they will do is, in 2 steps- first step: 2
187
00:24:11,330 --> 00:24:18,330
will go to the other side, right? I will have
1 cannibal here and 2 cannibals, 3 missionaries,
188
00:24:19,650 --> 00:24:26,650
here. Boat is on this side. Then, 1 cannibal
will come back. So, I will have 2 cannibals
189
00:24:28,800 --> 00:24:35,330
here, 1 cannibal and 3 missionaries here.
And the boat is now on this side. And then,
190
00:24:35,330 --> 00:24:42,330
finally- these 2 cannibals will go over to
the other side. I will have 3 cannibals here,
191
00:24:42,540 --> 00:24:48,830
3 missionaries here and boat is here. The
final configuration that I wanted to reach
192
00:24:48,830 --> 00:24:55,830
was 0, 0 and one, right?
193
00:24:59,470 --> 00:25:06,470
Now, we know what will be the formulation
of the problem. I will have the state as #m,
194
00:25:12,600 --> 00:25:19,600
#c, which means the number of missionaries
here, the number of cannibals- and the last
195
00:25:20,000 --> 00:25:27,000
bit indicates whether the boat is in the first
bank or in the second bank- and the start
196
00:25:27,710 --> 00:25:34,660
state is 3 3 actually 3, 3, 0. And the goal
state is 0, 0, 1. Depending on how you interpret
197
00:25:34,660 --> 00:25:41,660
the flag. And the operators are: the boat
carries 1 missionary, 0 cannibals; or 0 missionaries,
198
00:25:43,890 --> 00:25:49,740
1 cannibal; or 1 missionary, 1 cannibal; 2
missionaries, 0 cannibals; and 0 missionaries,
199
00:25:49,740 --> 00:25:56,740
2 cannibals. The nice way of searching this
would be to start from the start state and
200
00:25:56,890 --> 00:26:03,890
systematically apply these operators, one
by one, and see whether you are able to reach
201
00:26:03,890 --> 00:26:07,570
the goal.
202
00:26:07,570 --> 00:26:13,110
You will start from one of the states and
then see what happens. Suppose we start from
203
00:26:13,110 --> 00:26:20,110
the state 3, 3, 0, and then I take 2 missionaries
to the other side. That will leave me in a
204
00:26:29,860 --> 00:26:36,860
state: 1, 3, 0; 1, 3, 1, rather, and this
state is a state where it is the end of this
205
00:26:40,350 --> 00:26:47,350
missionary. So, we can backtrack from here
and try instead, sending 1 missionary and
206
00:26:50,550 --> 00:26:57,550
0 cannibals. If we do that, then we will have
2, 3, 1, which is again a bad state, because
207
00:27:00,000 --> 00:27:07,000
these 2 missionaries will go. Then, you try
applying the other operator. You send 1, 1;
208
00:27:08,270 --> 00:27:15,270
then that will leave you in 2, 2, 1- which
is fine- and then, again, from this, you can
209
00:27:16,990 --> 00:27:21,670
try some other operators or you can try some
other operators here. For example, you can
210
00:27:21,670 --> 00:27:28,670
try 0, 2, to get 3, 1, 1- right? This is how
the search tree is going to grow, but if you
211
00:27:36,510 --> 00:27:43,510
look at it, the search space can be quite
large. But, it is not just a tree, it is a
212
00:27:44,690 --> 00:27:50,760
graph, because in various sequences of operators
can actually take you to the same state.
213
00:27:50,760 --> 00:27:57,760
So, there will be necessity to detect whether
there is a state which is revisited, otherwise,
214
00:27:58,640 --> 00:28:03,470
if you apply something like depth first search,
and in DFS, if you cannot determine whether
215
00:28:03,470 --> 00:28:09,870
you have visited some state, then you can
potentially go into an infinite loop. So,
216
00:28:09,870 --> 00:28:15,080
we will have to devise mechanisms by which
we are able to check whether we are visiting
217
00:28:15,080 --> 00:28:21,790
some state or we are arriving at the same
state, along some other path, right? And so
218
00:28:21,790 --> 00:28:28,790
on. Now we will look at the outline of our
first basic search algorithm and we will develop
219
00:28:31,900 --> 00:28:36,350
this search algorithm to encompass all the
different kinds of AI search algorithms that
220
00:28:36,350 --> 00:28:43,350
we will study. We will start by maintaining
a list called OPEN. This is a-, this terminology
221
00:28:45,710 --> 00:28:52,710
of a list called OPEN was devised many decades
back, and so we will continue with the same
222
00:28:53,280 --> 00:29:00,280
names and jargon. Initially our list OPEN
will contain the start state- this is the
223
00:29:01,179 --> 00:29:08,179
initialization. Then, we have 1 termination
criterion. If we find that the list OPEN is
224
00:29:13,730 --> 00:29:20,730
empty, then we will terminate with failure,
right? Let us look at a little bit more, then
225
00:29:25,520 --> 00:29:32,520
it will become clear. Third step is, we select
a node n from OPEN. We select any state n
226
00:29:33,809 --> 00:29:40,809
from OPEN. And then we check whether n is
a goal. If n is a goal, then we have found
227
00:29:43,059 --> 00:29:48,730
a goal, so we terminate with success. Remember,
there, our objective is to start from the
228
00:29:48,730 --> 00:29:55,730
start state and find a path to a goal state.
So if n belongs to G, then we terminate with
229
00:29:57,220 --> 00:30:04,220
success. Otherwise we generate the successors
of n using the transition operators O, and
230
00:30:07,000 --> 00:30:10,460
insert these new states in OPEN, right?
231
00:30:10,460 --> 00:30:16,390
So, what we are doing is, we are starting
from 1 state and then expanding that state
232
00:30:16,390 --> 00:30:22,309
to generate its successor states by using
the state transition operators, and inserting
233
00:30:22,309 --> 00:30:27,670
these states into OPEN. At this point of time,
I have not mentioned whether OPEN is a FIFO
234
00:30:27,670 --> 00:30:34,090
or LIFO, or whether it is a priority queue.
Nothing. And these algorithms will vary depending
235
00:30:34,090 --> 00:30:41,090
on the kind of data structure that we use
for OPEN. And then finally, we go to step
236
00:30:42,190 --> 00:30:49,190
2. After expanding and inserting the children
in OPEN, we go back to step 2. Now think of
237
00:31:00,950 --> 00:31:07,950
this algorithm- just study this algorithm.
Slide?
238
00:31:08,130 --> 00:31:15,130
Look at this algorithm and try to figure out
what kind of algorithm this will be, if OPEN
239
00:31:18,510 --> 00:31:25,510
is a queue and if OPEN is a stack. No, if
you treat OPEN as a stack, then you will select
240
00:31:47,830 --> 00:31:54,830
the top element from OPEN. If the OPEN is
queue, then you will select the last element,
241
00:31:56,450 --> 00:32:03,450
right? Let me give an example. Right. So,
if the so if OPEN is a queue, then we will
242
00:32:09,049 --> 00:32:15,100
have breadth first search, and if OPEN is
a stack, then we will have depth first search.
243
00:32:15,100 --> 00:32:22,100
See, think of the recursive depth first search.
Where is the stack? It is the recursion stack.
244
00:32:25,770 --> 00:32:31,160
You have visited from one, pushed that node,
because you have not yet visited all its successors,
245
00:32:31,160 --> 00:32:37,429
right, and picked up one successor, gone down
to that successor and again pushed that node,
246
00:32:37,429 --> 00:32:42,809
because you have not yet seen the other successors.
So, when you backtrack from a node, you go
247
00:32:42,809 --> 00:32:48,950
back to the previous parent and pop it up
and then start visiting its other successors,
248
00:32:48,950 --> 00:32:50,049
right?
249
00:32:50,049 --> 00:32:57,049
Let us see this through an example. The graph
that we have is, say- this is state 1- and
250
00:33:00,710 --> 00:33:07,710
then let us say, suppose
251
00:33:18,970 --> 00:33:25,970
this is the start state, s. Initially, let
us see the contents of OPEN, and here we will
252
00:33:34,040 --> 00:33:41,040
treat OPEN as a stack. Now, in the first step,
what do we have in OPEN- we have 1. In the
253
00:33:53,799 --> 00:34:00,220
first step, what we are going to do is- we
are going to select. If you look at the slide,
254
00:34:00,220 --> 00:34:07,210
the first step is to select a state n. In
step 3, select a state n from OPEN and then
255
00:34:07,210 --> 00:34:14,129
if it is not a goal, then expand and generate
its successors. Coming back to here, if we
256
00:34:14,129 --> 00:34:21,129
expand this, then what will happen is- here
we visit 1 and then generate its successors,
257
00:34:23,190 --> 00:34:30,190
and let us say we put them in this order-
4, 3, 2, right? In the next step, we are going
258
00:34:34,069 --> 00:34:41,069
to pop out 2 and visit 2. When we visit 2,
let us say that we find that its successors
259
00:34:43,190 --> 00:34:50,190
are 6 and 3. So, what happens is, 2 comes
out and 3 is already there. We just put 4
260
00:34:59,359 --> 00:35:06,359
followed by 3 is there, and we have 6.
261
00:35:07,289 --> 00:35:14,289
In the next step, we visit 6. Let us say 6
does not have any next state. So, we will
262
00:35:19,599 --> 00:35:26,259
backtrack. The next thing that is going to
pop out is 3, so we will have a state where
263
00:35:26,259 --> 00:35:33,259
we have 4, 3. And now we will visit 3. When
we expand 3, we find that it has 2 successors-
264
00:35:38,559 --> 00:35:45,559
namely 4 and 5. The OPEN contents 4 and 5.
Next, we visit 5, right, and we find that
265
00:35:58,039 --> 00:36:05,039
5 has successors 6 and 7, which happens to
be a goal node. So, what happens is, when
266
00:36:14,019 --> 00:36:21,019
we visit 5, we will have 4 and 6 and 7, and
as soon as we have visited a goal, then we
267
00:36:24,099 --> 00:36:31,099
stop. So, we have goal found. If you look
at the sequence of states visited, then you
268
00:36:32,950 --> 00:36:39,950
see we have gone from 1 to 2, then 2 to 6,
then backtracked and then went to 3, and 3
269
00:36:45,339 --> 00:36:52,339
to 5 and then 5 to 7. And this is exactly
what we do in DFS, right?
270
00:36:54,549 --> 00:37:01,549
Okay. In your state space, you can also have
other transitions, like, you can have a state
271
00:37:04,710 --> 00:37:11,710
8, which are not visited at all by the search
algorithm. And you can also have some states
272
00:37:12,940 --> 00:37:17,950
which are not reachable. For example, if you
look at the state 9, it is not reachable from
273
00:37:17,950 --> 00:37:23,680
the start state. But the whole point is that,
at no point of time do we want to make the
274
00:37:23,680 --> 00:37:29,910
whole state space explicit. We want to only
unfold that portion of the state space which
275
00:37:29,910 --> 00:37:36,910
is necessary to find out the goal. So, nodes
like 8 and 9 never came into the picture here,
276
00:37:39,180 --> 00:37:42,799
because those were not necessary for this
depth first " "
277
00:37:42,799 --> 00:37:49,799
Now, if instead of using a stack, we used
a queue, how would it have looked? Yes. This
278
00:38:05,729 --> 00:38:12,729
one. Yes. No, but I did not visit 6. Oh. Here.
Yesyes. This 6 should not come, right? This
279
00:38:26,849 --> 00:38:32,519
6 should not be entered in OPEN again, because
we have already visited, but I have not yet
280
00:38:32,519 --> 00:38:38,849
told you how we maintain this information
about what we visited.
281
00:38:38,849 --> 00:38:45,849
Later, I will show you that we will maintain
another list called CLOSED, which will keep
282
00:38:46,539 --> 00:38:53,019
track of those states which we have already
visited, but before that just let us quickly
283
00:38:53,019 --> 00:39:00,019
see what happens if we do a BFS with this
same graph. In that case, what we will do
284
00:39:04,269 --> 00:39:11,269
is- OPEN will be treated as a queue. OPEN
will be treated as a queue, so initially we
285
00:39:14,599 --> 00:39:21,599
will have 1, right? I will enter nodes through
this side and take them out through this side,
286
00:39:22,599 --> 00:39:29,599
as in a FIFO. So, when I visit 1, then I will
enter the successors- 2, 3, 4, right? Then,
287
00:39:37,239 --> 00:39:44,239
I will take out 2 and when I take out 2, then,
I will insert its successors. 3 is already
288
00:39:45,529 --> 00:39:52,529
there, so I will not reinsert it. I will insert
6. That is right. Next, I will be taking out
289
00:39:56,160 --> 00:40:03,160
3. This is where we deviate from the DFS.
So, will be taking out 3 and when I take out
290
00:40:03,950 --> 00:40:10,950
3, I will insert 5, right? Next, I will take
out 4 and I have 6, 5 and I get 7. And since
291
00:40:20,809 --> 00:40:27,809
this is the goal, so I will say that as I
have found the goal, right? This is breadth
292
00:40:31,559 --> 00:40:37,829
first search. So, if I treat OPEN as a stack,
then I have DFS.
293
00:40:37,829 --> 00:40:44,829
If I treat OPEN as a queue, then I have BFS,
but there is a significant difference between
294
00:40:46,220 --> 00:40:53,220
the 2, in terms of the kind of space that
I am going to require. So, let us see the
295
00:40:56,779 --> 00:41:03,779
following things. Suppose we have used OPEN
as a FIFO. Is the algorithm guaranteed to
296
00:41:09,969 --> 00:41:16,969
terminate? In breadth first search? But you
must remember one thing: is that when we are
297
00:41:22,099 --> 00:41:27,299
talking about the state spaces, we are not
necessarily talking about finite state spaces.
298
00:41:27,299 --> 00:41:34,299
The state spaces can be infinite. For example,
if you are working on state transition operators
299
00:41:36,349 --> 00:41:43,059
which work on real numbers or integers, then
potentially you can go from one state to another.
300
00:41:43,059 --> 00:41:49,390
And because you have integer functions giving
you the next state, you can continue forever,
301
00:41:49,390 --> 00:41:50,369
right?
302
00:41:50,369 --> 00:41:57,369
So, in breadth first search, we are looking
at breadth first. That is why, if you have
303
00:41:57,950 --> 00:42:04,950
a goal in a finite depth, you will terminate.
But in depth first search, if the tree is
304
00:42:05,499 --> 00:42:10,479
infinite, then there is a possibility that
you go down an infinite path, and the goal
305
00:42:10,479 --> 00:42:17,479
is on some other path. So, depending on the
size of the state space, if your size of the
306
00:42:17,539 --> 00:42:24,539
state space is very large in depth, then if
you do depth first search, then you might
307
00:42:24,769 --> 00:42:31,769
actually end up doing a lot more work. This
analysis is what we will do later on, okay?
308
00:42:34,519 --> 00:42:39,089
And then under what circumstances will it
terminate? Again, we will look at this problem
309
00:42:39,089 --> 00:42:44,049
in more detail subsequently.
310
00:42:44,049 --> 00:42:50,749
Let us look at the complexity of the breadth
first search. Suppose b is the branching factor.
311
00:42:50,749 --> 00:42:55,660
By branching factor, I mean that the number
of transition operators that you have. So,
312
00:42:55,660 --> 00:43:01,599
given a state, that is the number of different
next states that you can possibly have. And
313
00:43:01,599 --> 00:43:08,599
d is the depth of the goal. If you do breadth
first search, then on an average, this is
314
00:43:09,249 --> 00:43:16,249
the time that you are going to require. One,
first the start state. b for the set of states
315
00:43:17,460 --> 00:43:24,460
at depth 1. b square states at depth 2, b
cube depth states at depth 3, and so on. And
316
00:43:26,640 --> 00:43:32,789
you will visit, in the worst case, all states
up to depth d. So, in the last iteration,
317
00:43:32,789 --> 00:43:38,809
you will have b to the power of d states,
in the dth level, right?
318
00:43:38,809 --> 00:43:45,809
If you take the sum of these, it comes to
order of b to the power of d. And the space
319
00:43:46,279 --> 00:43:52,039
required is also order of b to the power of
d, because since you are doing breadth first
320
00:43:52,039 --> 00:43:59,039
search, when you are starting with a node
at depth d, you must be having all the other
321
00:44:01,569 --> 00:44:08,569
states at depth d already in OPEN, right?
The space requirement is order of b to the
322
00:44:08,859 --> 00:44:15,400
power of d. This is what kills breadth first
search. Otherwise, this is a nice algorithm,
323
00:44:15,400 --> 00:44:21,769
but the space requirement is a more stringent
requirement in the kind of problems that we
324
00:44:21,769 --> 00:44:28,769
are working at, because after some time, you
will be eating up so much of memory that your
325
00:44:30,390 --> 00:44:37,390
system will start crashing. We will do some
assignments to actually test the limits of
326
00:44:37,599 --> 00:44:44,539
the system, and you will see that if we start
by simple things like 15-puzzle, that is enough
327
00:44:44,539 --> 00:44:50,999
to kill the kind of desktop machines that
you have. That is enough. Okay. We will see
328
00:44:50,999 --> 00:44:53,729
those things later.
329
00:44:53,729 --> 00:45:00,599
If we look at the complexity of depth first
search, then the time required is order of
330
00:45:00,599 --> 00:45:07,599
b to the power of m, where m is the depth
of the state space tree. Now, note that in
331
00:45:07,869 --> 00:45:14,869
depth first search, the depth of the goal
is not important because you are not going
332
00:45:15,960 --> 00:45:22,960
level by level. Rather, what you are doing
is, you are going from straight down as far
333
00:45:25,700 --> 00:45:32,700
as you do, and if m is the depth of your state
space, then you will do right down here, and
334
00:45:33,829 --> 00:45:39,039
then start backtracking and trying out the
other parts, right? This is how depth first
335
00:45:39,039 --> 00:45:44,880
search will work. So, even if your goal is
here, you know you will end up visiting all
336
00:45:44,880 --> 00:45:49,559
these parts and then come back and find that
the goal is here. That is what happens in
337
00:45:49,559 --> 00:45:56,559
depth first search. If you look at the complexity,
it is order of b to the power of m, where
338
00:46:00,089 --> 00:46:03,630
m is the depth of the state space tree.
339
00:46:03,630 --> 00:46:10,630
Is this clear? Yes? Oh, the state space tree
is the tree that you obtain by applying the
340
00:46:15,279 --> 00:46:20,710
state transition operators repeatedly on the
set of states. So, you start with the start
341
00:46:20,710 --> 00:46:27,009
state. These are the next states that you
can generate with your state transition operators.
342
00:46:27,009 --> 00:46:31,549
From this state, these are the states that
you can generate with your next state operators,
343
00:46:31,549 --> 00:46:38,549
right? If you keep on unfolding this, what
you get is the state space tree, right. And
344
00:46:40,900 --> 00:46:47,900
where do I end this state space tree? When
I find that all the next states of this state
345
00:46:47,999 --> 00:46:54,999
are already there in the state space tree.
They are already there in this path. You have
346
00:46:57,130 --> 00:47:04,130
already visited that. That is where there
are no new states, so you backtrack and try
347
00:47:05,289 --> 00:47:11,910
another one, or you reach a state from where
there is no state transition operator.
348
00:47:11,910 --> 00:47:18,910
So, if you have a state space tree of depth
m, then the time required is order of b to
349
00:47:21,029 --> 00:47:28,029
the power of m, because it is going to go
right down, up to depth m, and then in the
350
00:47:28,309 --> 00:47:35,309
worst case, visit all nodes there and come
back to the top, and find that the last node
351
00:47:35,700 --> 00:47:40,759
in the top of the start state- the last child
of the start state is the goal state. That
352
00:47:40,759 --> 00:47:45,710
is the worst case scenario, and there you
will require order of b to the power of m.
353
00:47:45,710 --> 00:47:52,710
But the good thing is that the space complexity
of depth first search is order of bm. Why
354
00:47:55,299 --> 00:48:02,299
bm? I am going down one path, right? If you
just look at the path, what I am pushing in
355
00:48:12,599 --> 00:48:17,380
OPEN is- in the first round. I will push this
in OPEN. In the second round, I will push
356
00:48:17,380 --> 00:48:21,739
this in OPEN. In the third round, I will push
this in OPEN. In the fourth round, I will
357
00:48:21,739 --> 00:48:23,829
push this in OPEN.
358
00:48:23,829 --> 00:48:30,829
At every round, I am pushing the node that
I am visiting and the brothers of that. So,
359
00:48:33,239 --> 00:48:40,239
if I have if the depth of this tree is m,
then I have m nodes here, and each m having
360
00:48:46,400 --> 00:48:53,400
b brothers, right? So, my OPEN is not going
to be larger than order of bm.
361
00:48:54,959 --> 00:49:01,959
Now, if you compare that with the complexity
of breadth first search, then you see that
362
00:49:02,719 --> 00:49:07,700
this is significantly better. For breadth
first search, we had order of b to the power
363
00:49:07,700 --> 00:49:14,700
of d, and here the space complexity is order
of bm. And typically, bm can be much lesser
364
00:49:16,700 --> 00:49:23,680
than order of b to the power of d. So, that
is why depth first search is useful for some
365
00:49:23,680 --> 00:49:30,680
kinds of algorithm; many scenarios, right?
Now, there are some nice trade offs that we
366
00:49:31,049 --> 00:49:38,049
can have between space and time. We saw that
in breadth first search, we were able to do
367
00:49:39,499 --> 00:49:46,499
it quickly, whenever the goal is near the
start state. And the drawback was, it was
368
00:49:49,549 --> 00:49:56,369
using up too much of space. So, one nice trade-off
between space and time is, we will use depth
369
00:49:56,369 --> 00:50:03,249
first search to do breadth first search. What
we are going to do is what is called an iterative
370
00:50:03,249 --> 00:50:10,249
deepening. We will perform DFS, but by repeatedly
using increasing depth bounds. Let us see
371
00:50:17,690 --> 00:50:19,940
how we go about doing this.
372
00:50:19,940 --> 00:50:26,940
We will start from the start state and do
a DFS of depth 1. We have seen all the steps
373
00:50:28,640 --> 00:50:35,640
at depth 1, but we have done it with DFS,
mind it. If we have found the goal, we terminate.
374
00:50:39,650 --> 00:50:46,650
Otherwise, we go to depth 2. Again, do a DFS
up to depth 2. If you have not found the goal,
375
00:50:48,549 --> 00:50:55,549
do a DFS up to depth 3. We continue in this
way until we have found the goal. If you look
376
00:51:01,670 --> 00:51:08,670
at the complexity now, we are working in order
of b to the power of d time, and order bd
377
00:51:10,029 --> 00:51:17,029
space. The space is easy to see, right, because
in the first iteration my space is b. In the
378
00:51:18,140 --> 00:51:23,599
second iteration my space requirement is 2b.
In the third iteration my space requirement
379
00:51:23,599 --> 00:51:29,019
is 3b, and the dth iteration, I will get the
goal. If d is at If the goal is at a depth
380
00:51:29,019 --> 00:51:31,849
d, then in the dth iteration, I will have
the goal.
381
00:51:31,849 --> 00:51:37,979
So, order bd is the worst case space that
I will require, but that it works in order
382
00:51:37,979 --> 00:51:44,979
b to the power of d time, is not so obvious,
right? In the first iteration, it is going
383
00:51:47,140 --> 00:51:54,140
to take order of b, then order of b square,
then order of b cube; unlike space, where
384
00:51:55,660 --> 00:52:02,259
you will take the max of the space requirements
in the different iterations. For the time,
385
00:52:02,259 --> 00:52:09,219
they will add up- for the time complexities,
they will add up. In the first iteration,
386
00:52:09,219 --> 00:52:14,920
you had order of b, second iteration: order
of b square, third iteration: order of b cube.
387
00:52:14,920 --> 00:52:21,920
So, b plus b square plus b cube plus... up
to b to the power of d. That is also going
388
00:52:21,969 --> 00:52:28,969
to come to order of b to the power of d. So,
please check out this recurrence. One final
389
00:52:31,799 --> 00:52:38,799
thing is bi-directional search, where what
you can do is, you can do breadth first search,
390
00:52:41,249 --> 00:52:48,249
but from 2 directions. You can start from
the start state, work in 1 direction and start
391
00:52:48,569 --> 00:52:50,759
from the goal state.
392
00:52:50,759 --> 00:52:57,369
I start from the start state and proceed like
this; start from the goal state, proceed like
393
00:52:57,369 --> 00:53:04,369
this and then I do 1 iteration of breadth
first search for this. And we keep on doing
394
00:53:07,390 --> 00:53:14,229
this until, at some point of time, there is
some common node which I find between the
395
00:53:14,229 --> 00:53:19,200
2. When I found that, then I know a path from
here to here, I know a part from here to here.
396
00:53:19,200 --> 00:53:26,200
So, I have found a path to the goal. This
helps because instead of having done this,
397
00:53:26,779 --> 00:53:33,619
which would have taken order of b to the power
of d, I am not doing- in the worst case- this
398
00:53:33,619 --> 00:53:40,619
part and this part. This is order of b to
the power of d by 2, and again, this part
399
00:53:43,999 --> 00:53:50,999
is order of b to the power of d by 2, right?
So, the total is again order of b to the power
400
00:53:51,160 --> 00:53:52,049
of d by 2.
401
00:53:52,049 --> 00:53:57,089
It works in order of b to the power of d by
2 time and order of b to the power of d by
402
00:53:57,089 --> 00:54:02,369
2 space, but this can only work if the state
transition operators are reversible, so that
403
00:54:02,369 --> 00:54:09,119
you can start from the goal and work backwards.
And in puzzles like 15-puzzle, etc. it is
404
00:54:09,119 --> 00:54:16,119
indeed reversible. You can try out from both
sides. Of the bi-directional search? Well,
405
00:54:17,209 --> 00:54:24,209
you can start in, if you did normal breadth
first search, then you will go straight from
406
00:54:26,109 --> 00:54:32,920
the start state and expand all nodes up to
depth d. So, your complexity will be order
407
00:54:32,920 --> 00:54:38,920
of b to the power of d. Here, what we are
doing is, we are starting from the start state
408
00:54:38,920 --> 00:54:43,989
and moving in this direction, and we are also
starting from the goal state and moving in
409
00:54:43,989 --> 00:54:49,589
the other direction, using the reverse of
the state transition operators. And we continue
410
00:54:49,589 --> 00:54:56,349
until the frontiers of the searches from these
2 sides meet at some point of time at some
411
00:54:56,349 --> 00:54:56,969
place.
412
00:54:56,969 --> 00:55:03,969
When you have a common node in these 2, then
you can find out a path from the start state
413
00:55:04,849 --> 00:55:10,619
to the goal state. Now you see that because
you were doing 1 iteration from this side,
414
00:55:10,619 --> 00:55:15,029
1 iteration from that side- so, you will be
doing d to the power of 2 iterations from
415
00:55:15,029 --> 00:55:20,459
this side and d to the power of 2 iterations
from the other side, right? Order of d to
416
00:55:20,459 --> 00:55:24,519
the power of 2 from this side, order of d
to the power 2 from the other side. If you
417
00:55:24,519 --> 00:55:30,309
do d to the power of 2 iterations from this
side, your complexity for BFS is order of
418
00:55:30,309 --> 00:55:36,670
b to the power of d by 2; and also from the
other side, it is order of b to the power
419
00:55:36,670 --> 00:55:43,069
of d by 2. If you add up this plus this, you
still have order of b to the power of d by
420
00:55:43,069 --> 00:55:46,900
2, right?
421
00:55:46,900 --> 00:55:53,900
So, you have actually reduced the complexity
by half, right? If you have order of b to
422
00:55:58,709 --> 00:56:04,339
the power of d, you have order of b to the
power of d by 2, which is significant actually,
423
00:56:04,339 --> 00:56:11,239
right? We will conclude this lecture here
and from tomorrow onwards, we will start looking
424
00:56:11,239 --> 00:56:18,239
at the search problem with the introduction
of costs. We will see what happens when the
425
00:56:19,069 --> 00:56:26,069
state transition operators have associated
cost when the goals have associated costs.
426
00:56:27,670 --> 00:56:34,670
Today, we will start with the next chapter
on searching with costs. In the last class,
427
00:56:46,549 --> 00:56:53,549
what we had done was, we studied the first
search algorithm which was as follows: that
428
00:56:58,410 --> 00:57:04,749
we start with initialize and we were maintaining
a list called OPEN. We put the start node
429
00:57:04,749 --> 00:57:11,749
in s. Then, if we find at some point of time,
that OPEN is empty and we have still not found
430
00:57:12,269 --> 00:57:19,269
the goal, then we terminate with failure.
Then select a state n from OPEN. Terminate:
431
00:57:22,349 --> 00:57:28,420
if n is a goal- then we terminate with success.
Otherwise, we generate the successors of n
432
00:57:28,420 --> 00:57:35,279
using O and insert them in OPEN, and finally
go to step 2. So, what we are essentially
433
00:57:35,279 --> 00:57:41,869
doing is, we are progressively maintaining
a frontier of the nodes. And in each iteration,
434
00:57:41,869 --> 00:57:46,709
we are picking up a node from the frontier
and expanding that. That extends the frontier
435
00:57:46,709 --> 00:57:48,249
and we continue in this way.
436
00:57:48,249 --> 00:57:53,489
OPEN maintains the current frontier. If at
any point of time, we find that OPEN is empty,
437
00:57:53,489 --> 00:57:57,109
that means we have reached the end of the
frontier and we have still not found the goal.
438
00:57:57,109 --> 00:58:03,759
So then, we will terminate with failure. One
thing that I had not mentioned so far is that-
439
00:58:03,759 --> 00:58:10,759
how do we maintain the part of the state space
that we have already visited? And that is
440
00:58:10,979 --> 00:58:16,140
important, because there are cases where we
have to know that node is already visited
441
00:58:16,140 --> 00:58:23,140
so that we do not revisit that node. This
is the extension of the same algorithm, where
442
00:58:29,609 --> 00:58:33,959
we will save the explicit state space. Let
us see how we do that.
443
00:58:33,959 --> 00:58:40,469
See, this just shows the difference with the
previous algorithm. The only changes that
444
00:58:40,469 --> 00:58:47,469
I have made are highlighted in yellow. We
are now maintaining another list called CLOSED.
445
00:58:49,499 --> 00:58:56,499
When we select a state n from OPEN, here we
save the state in CLOSED, right?