WEBVTT

00:00:09.409 --> 00:00:11.378
PATRICK WINSTON: It's too bad,
in a way, that we can't paint

00:00:11.378 --> 00:00:14.214
everything black, because this
map coloring problem sure

00:00:14.214 --> 00:00:17.383
would be a lot easier.

00:00:17.383 --> 00:00:21.888
So I don't know what we're
going to do about that.

00:00:21.888 --> 00:00:23.890
How long is this
going to take?

00:00:23.890 --> 00:00:24.724
Here's what we're going to do.

00:00:24.724 --> 00:00:26.459
We're going to wait till either
all the laptops are

00:00:26.459 --> 00:00:28.895
closed, or this program
terminates,

00:00:28.895 --> 00:00:30.130
whichever comes first.

00:00:32.499 --> 00:00:34.667
So how long is this
going to take?

00:00:34.667 --> 00:00:36.569
I actually don't know.

00:00:36.569 --> 00:00:38.671
I think it'll take more than the
life time of the universe,

00:00:38.671 --> 00:00:39.706
but I'm not sure.

00:00:39.706 --> 00:00:42.709
So let's take a look at
a slightly easier

00:00:42.709 --> 00:00:44.511
map coloring problem.

00:00:44.511 --> 00:00:47.247
We'll stop this one and change
the map to something I call

00:00:47.247 --> 00:00:49.315
[? simplicia. ?]

00:00:49.315 --> 00:00:53.753
There's 26 states, one for each
letter in the alphabet.

00:00:53.753 --> 00:00:55.889
And what we're going to do is
we're going to do a depth

00:00:55.889 --> 00:01:01.327
first search for a suitable
coloring of this map.

00:01:01.327 --> 00:01:04.330
We're going to go in order,
A, B, C, D, E. And as I've

00:01:04.330 --> 00:01:08.134
suggested here, at each level
we're going to rotate the

00:01:08.134 --> 00:01:11.871
color choices so we don't
over use any one color.

00:01:11.871 --> 00:01:14.807
So if we launch this particular
search, this depth

00:01:14.807 --> 00:01:17.777
first attempt to
color this map.

00:01:17.777 --> 00:01:18.478
There it goes.

00:01:18.478 --> 00:01:21.381
And maybe we should wait
until it terminates.

00:01:21.381 --> 00:01:25.184
Or maybe we should just let it
run and it'll terminate,

00:01:25.184 --> 00:01:27.320
perhaps, sometime within
the lecture.

00:01:27.320 --> 00:01:30.923
Or maybe we should just let
it run over the weekend.

00:01:30.923 --> 00:01:33.960
Or how long do you think we
would have to wait, if we want

00:01:33.960 --> 00:01:37.196
to come back and watch
it terminate?

00:01:37.196 --> 00:01:39.232
At roughly 30 frames
a second--

00:01:39.232 --> 00:01:41.934
I'm calculating it all in my
head, I don't want to bet my

00:01:41.934 --> 00:01:46.506
life on it-- but I think
about 5,000 years.

00:01:46.506 --> 00:01:50.276
And if we want to use as many
states as there are in the

00:01:50.276 --> 00:01:53.946
United States, in this
demonstration, you get up to

00:01:53.946 --> 00:01:58.918
numbers like 10 to
the 17th years--

00:01:58.918 --> 00:02:01.254
17th, 18th, 16th, I'm
not exactly sure.

00:02:01.254 --> 00:02:03.656
I did a rough calculation.

00:02:03.656 --> 00:02:06.092
And, of course, you could do
some parallels into that, and

00:02:06.092 --> 00:02:07.994
it's not as bad as chess, where
you need all the atoms

00:02:07.994 --> 00:02:09.328
in the universe and you
still can't do it,

00:02:09.328 --> 00:02:10.562
and things like that.

00:02:10.562 --> 00:02:11.497
Acting as computers.

00:02:11.497 --> 00:02:14.400
But still, it's pretty
horrendous.

00:02:14.400 --> 00:02:20.573
The problem is, well the problem
is illustrated by this

00:02:20.573 --> 00:02:22.809
diagram I put in back of me.

00:02:22.809 --> 00:02:27.914
If you do a depth first
search and you have a

00:02:27.914 --> 00:02:31.517
problem like Texas.

00:02:31.517 --> 00:02:36.189
If you label... if you
assign a color to Arizona,

00:02:36.189 --> 00:02:40.893
Oklahoma, Arkansas, and
Louisiana first, and then wait

00:02:40.893 --> 00:02:47.733
around to Texas last, then you
get yourself into a bind by

00:02:47.733 --> 00:02:50.803
your fourth choice, that you
don't discover until you're

00:02:50.803 --> 00:02:52.972
48th choice.

00:02:52.972 --> 00:02:56.042
So what happens then, is that
you start developing this tree

00:02:56.042 --> 00:03:00.913
like this, you get to those
states surrounding Texas.

00:03:00.913 --> 00:03:04.150
Texas is last state assigned
a color and there's

00:03:04.150 --> 00:03:05.718
nothing left for it.

00:03:05.718 --> 00:03:08.521
And that problem was there on
the fourth choice, and you

00:03:08.521 --> 00:03:10.923
don't discover it until
your 50th choice.

00:03:10.923 --> 00:03:15.227
So you develop a horrendous,
impossible, impossible search.

00:03:15.227 --> 00:03:19.265
So you simply can't
do it that way.

00:03:19.265 --> 00:03:22.468
But now, not to worry.

00:03:22.468 --> 00:03:24.603
I've come equipped with
the idea of constraint

00:03:24.603 --> 00:03:26.605
propagation.

00:03:26.605 --> 00:03:28.374
So we could just take
a country with four

00:03:28.374 --> 00:03:30.042
states, like this.

00:03:30.042 --> 00:03:34.380
Each can be labeled red,
green, blue and yellow.

00:03:34.380 --> 00:03:37.283
So just like in a case of line
drawings, we'll pile up all

00:03:37.283 --> 00:03:41.487
the possible things that the
value can be-- red, green,

00:03:41.487 --> 00:03:42.954
blue and yellow.

00:03:42.954 --> 00:03:48.627
Red, green, blue and yellow.

00:03:48.627 --> 00:03:51.497
And we start up constraint
propagation.

00:03:51.497 --> 00:03:55.401
So we say for the upper left
hand corner state, is there

00:03:55.401 --> 00:03:58.504
any reason to believe that
R is impossible?

00:03:58.504 --> 00:04:00.372
Well we look at our neighbors
and see what kind of

00:04:00.372 --> 00:04:02.508
constraint flows in from them.

00:04:02.508 --> 00:04:04.276
And sure, this guy could
be green, and this

00:04:04.276 --> 00:04:05.511
guy could be blue.

00:04:05.511 --> 00:04:09.248
They don't have to be red,
so there's nothing

00:04:09.248 --> 00:04:11.984
that rules out red.

00:04:11.984 --> 00:04:13.519
And there's nothing the
rules out blue.

00:04:13.519 --> 00:04:16.454
And there's nothing that
rules out yellow.

00:04:16.454 --> 00:04:18.624
And there's nothing that
rules out green.

00:04:18.624 --> 00:04:22.595
So constraint propagation just
sits there with its finger up

00:04:22.595 --> 00:04:25.564
its nose, doing nothing.

00:04:25.564 --> 00:04:31.804
So it doesn't look like we can
use either depth first search,

00:04:31.804 --> 00:04:34.673
or constraint propagation.

00:04:34.673 --> 00:04:37.843
So we could just give
up and cry.

00:04:37.843 --> 00:04:41.714
But maybe there's some other
approach that will help.

00:04:41.714 --> 00:04:45.017
So let me actually work
the Texas problem.

00:04:45.017 --> 00:04:50.890
So with apologies to
Houston and Tyler,

00:04:50.890 --> 00:04:52.157
here's a map of Texas.

00:04:57.863 --> 00:04:58.764
There we are.

00:04:58.764 --> 00:05:01.834
And here's, roughly
speaking, Arizona

00:05:01.834 --> 00:05:03.702
is over here somewhere.

00:05:03.702 --> 00:05:05.404
And we've got Oklahoma
in there.

00:05:05.404 --> 00:05:09.642
And old Bill Clinton's
state, Arkansas.

00:05:09.642 --> 00:05:12.611
And then Louisiana sticks
out there a little bit.

00:05:12.611 --> 00:05:15.914
So there's our map of that

00:05:15.914 --> 00:05:18.384
particular part of the country.

00:05:18.384 --> 00:05:25.524
So we've got Arizona here,
Oklahoma here, Arkansas here,

00:05:25.524 --> 00:05:29.528
and Louisiana here,
and Texas here.

00:05:29.528 --> 00:05:34.233
And we have elected to assign
colors to these states, in

00:05:34.233 --> 00:05:35.100
that order.

00:05:35.100 --> 00:05:39.271
So this is one, two,
three, four.

00:05:42.174 --> 00:05:44.710
And we're going to do that.

00:05:44.710 --> 00:05:46.912
We're going to rotate our color
choices, just so we

00:05:46.912 --> 00:05:50.649
don't over use any one color.

00:05:50.649 --> 00:05:53.819
But we're going to also have a
look at Texas as we go around.

00:05:53.819 --> 00:05:57.122
Because Texas is a state that
borders on the States they

00:05:57.122 --> 00:06:00.926
were choosing colors for.

00:06:00.926 --> 00:06:05.230
So the only possible colors that
Texas could be are red,

00:06:05.230 --> 00:06:10.702
green, blue, and yellow.

00:06:10.702 --> 00:06:15.707
So as we make our choices around
here, we'll say that--

00:06:15.707 --> 00:06:18.744
we don't have to adhere to any
particular style-- we can say

00:06:18.744 --> 00:06:26.018
that Arizona is going to get
the colored red, R. That's

00:06:26.018 --> 00:06:29.454
going to rule out R over here
for Texas, because no adjacent

00:06:29.454 --> 00:06:32.925
states can have the
same color.

00:06:32.925 --> 00:06:35.194
Then we go over to Oklahoma, and
we're rotating our color

00:06:35.194 --> 00:06:38.864
choices, so we'll say
that can be green.

00:06:38.864 --> 00:06:41.800
And that's fine, because it's
consistent with the red here,

00:06:41.800 --> 00:06:43.368
but it rules out the
possibility that

00:06:43.368 --> 00:06:46.004
Texas could be green.

00:06:46.004 --> 00:06:52.377
And then we go over here to
Arkansas, red, green, blue.

00:06:52.377 --> 00:06:55.647
That's fine, that's consistent
with the green on Oklahoma,

00:06:55.647 --> 00:06:58.483
but if we look at its neighbors
we know that Texas

00:06:58.483 --> 00:07:02.788
is forever forbidden
to be blue, now.

00:07:02.788 --> 00:07:05.324
So now we go over to Louisiana,
and remember, we're

00:07:05.324 --> 00:07:07.459
rotating our color choices
because we don't want to

00:07:07.459 --> 00:07:09.428
overuse them.

00:07:09.428 --> 00:07:11.229
So this means that the first
choice we're going to make

00:07:11.229 --> 00:07:12.864
here, for Louisiana,
is yellow.

00:07:15.600 --> 00:07:18.570
And that's fine because it's
consistent with Arkansas, but

00:07:18.570 --> 00:07:22.307
it's not so fine because it's
now ruled out the last

00:07:22.307 --> 00:07:25.410
possibility for Texas.

00:07:25.410 --> 00:07:30.248
So even though Texas is going
to be the 48th state that we

00:07:30.248 --> 00:07:33.985
color, we're going to say,
at this point, there's no

00:07:33.985 --> 00:07:35.020
need in going on.

00:07:35.020 --> 00:07:36.888
We'd better back up.

00:07:36.888 --> 00:07:39.124
Because there's nothing left for
Texas when we get around

00:07:39.124 --> 00:07:40.692
to coloring it.

00:07:40.692 --> 00:07:45.163
So that means that this yellow
is ruled out here.

00:07:45.163 --> 00:07:47.732
This yellow reappears.

00:07:47.732 --> 00:07:51.937
We select the next color in my
line for Louisiana, which

00:07:51.937 --> 00:07:53.839
happens to be red.

00:07:53.839 --> 00:07:57.509
And now that's consistent
with this yellow that's

00:07:57.509 --> 00:07:59.010
still left for Texas.

00:07:59.010 --> 00:08:00.445
And it's also consistent
with the blue

00:08:00.445 --> 00:08:03.482
that's up here for Arkansas.

00:08:03.482 --> 00:08:04.416
So that's cool.

00:08:04.416 --> 00:08:07.786
I wonder if maybe we could make
an algorithm out of that,

00:08:07.786 --> 00:08:09.187
and solve problems like this.

00:08:09.187 --> 00:08:12.057
Do you see, sort of, the
intuition of what we're doing?

00:08:12.057 --> 00:08:14.159
We're actually using the martial
arts principle, again.

00:08:14.159 --> 00:08:17.696
Because the whole problem is
that local constraints,

00:08:17.696 --> 00:08:19.798
undiscovered local constraints,
are causing

00:08:19.798 --> 00:08:21.900
downstream problems.

00:08:21.900 --> 00:08:24.970
So we're going to use the
enemy's powers against him,

00:08:24.970 --> 00:08:26.938
and we're going to look at those
local constraints as we

00:08:26.938 --> 00:08:30.108
go and make sure they're not
going downstream, not going to

00:08:30.108 --> 00:08:32.177
get us later on.

00:08:32.177 --> 00:08:37.249
So now I'm going to look like
I'm getting a little formal,

00:08:37.249 --> 00:08:39.084
but I'm just getting a little
bit more formal.

00:08:39.084 --> 00:08:44.289
Because I want to have some
language that I can use to

00:08:44.289 --> 00:08:46.324
describe what's going on, so
that it's clear what the

00:08:46.324 --> 00:08:48.360
choices are.

00:08:48.360 --> 00:08:50.762
So to start off with, we're
going to have to have some

00:08:50.762 --> 00:08:52.497
vocabulary.

00:08:52.497 --> 00:08:55.867
So let's start up our
vocabulary here.

00:08:55.867 --> 00:09:04.209
We're going to have a notion
of a variable v. And that's

00:09:04.209 --> 00:09:05.443
something that can have
an assignment.

00:09:24.029 --> 00:09:25.463
There's nothing complicated
about that.

00:09:25.463 --> 00:09:26.731
And a value.

00:09:30.902 --> 00:09:36.241
A value x is something that
can be in assignment.

00:09:39.544 --> 00:09:41.079
It's a little bit circular,
but we're all in computer

00:09:41.079 --> 00:09:43.515
science so you know
what I mean.

00:09:43.515 --> 00:09:47.986
So the next thing is a little
slightly less obvious, and

00:09:47.986 --> 00:09:54.058
that's the notion
of a domain, d.

00:09:54.058 --> 00:09:57.428
And that's going to be
a bag of values.

00:10:01.366 --> 00:10:01.699
OK.

00:10:01.699 --> 00:10:03.334
So one more thing.

00:10:03.334 --> 00:10:04.602
A constraint.

00:10:10.008 --> 00:10:18.283
That's a constraint
c, is a limit on--

00:10:18.283 --> 00:10:20.885
in our examples it's mostly
going to be pairs of

00:10:20.885 --> 00:10:23.121
variables, pairs of
variable values.

00:10:23.121 --> 00:10:25.189
But in general, it could
be variable values.

00:10:33.765 --> 00:10:37.235
So if we go back here to Texas
we could say, OK, how does our

00:10:37.235 --> 00:10:40.371
vocabulary drape itself over
that configuration?

00:10:40.371 --> 00:10:45.610
And the answer is, the states
have the role of variables,

00:10:45.610 --> 00:10:50.882
the colors have the
role of values.

00:10:50.882 --> 00:10:53.985
And the domains are the
remaining color possibilities

00:10:53.985 --> 00:10:56.721
that we can still use on
a particular state.

00:10:56.721 --> 00:10:58.990
And the constraint, in this
case, is the simple map

00:10:58.990 --> 00:11:02.960
coloring constraint that no
states that share a boundary

00:11:02.960 --> 00:11:05.296
can have the same color.

00:11:05.296 --> 00:11:09.033
So states are variables, colors
are values, domains are

00:11:09.033 --> 00:11:11.936
bags of colors, and
constraints--

00:11:11.936 --> 00:11:13.504
there's only one--

00:11:13.504 --> 00:11:16.507
adjacent states can't
have the same color.

00:11:16.507 --> 00:11:19.644
So that's how it fits with
this vocabulary.

00:11:19.644 --> 00:11:22.013
So now, what did I
actually do here?

00:11:22.013 --> 00:11:25.149
Well what I actually did here,
I'm going to now formalize a

00:11:25.149 --> 00:11:29.720
little by writing it down
in pseudo code.

00:11:29.720 --> 00:11:33.324
So here we are, we're going to
have a look at what we did

00:11:33.324 --> 00:11:35.793
here with our intuition,
and we're going to

00:11:35.793 --> 00:11:37.895
reduce it to a procedure.

00:11:37.895 --> 00:11:39.130
And here's the procedure.

00:11:42.900 --> 00:11:45.036
Remember, we're doing depth
first search on this stuff.

00:11:45.036 --> 00:11:46.838
I did a depth first search.

00:11:46.838 --> 00:11:52.410
We're going to do a depth first
search, and for each

00:11:52.410 --> 00:11:55.780
depth first search
assignment--

00:12:01.385 --> 00:12:05.823
OK, so here I am, I'm labeling
Arizona, and then Oklahoma,

00:12:05.823 --> 00:12:08.426
and then Arkansas, and
then Louisiana.

00:12:08.426 --> 00:12:12.697
When I give each one of those a
label, a color, I'm going to

00:12:12.697 --> 00:12:14.398
do this procedure.

00:12:14.398 --> 00:12:15.666
Every time I make one of
those assignments.

00:12:15.666 --> 00:12:18.836
The last one that caused
trouble was

00:12:18.836 --> 00:12:20.404
coloring Louisiana yellow.

00:12:20.404 --> 00:12:23.708
Each time I put one of those
colors down, each time I make

00:12:23.708 --> 00:12:25.276
an assignment, I'm going
to do this procedure.

00:12:25.276 --> 00:12:38.889
So for each depth first search
assignment, for each variable

00:12:38.889 --> 00:12:40.290
v, considered.

00:12:45.896 --> 00:12:48.566
Now you don't know what
I mean by considered.

00:12:48.566 --> 00:12:54.505
But when I put a label, when I
put up a value, show something

00:12:54.505 --> 00:12:59.543
as a color for Louisiana,
I thought about Texas.

00:12:59.543 --> 00:13:02.546
So I was considering the
variable, Texas, when I made

00:13:02.546 --> 00:13:04.849
the assignment for Louisiana.

00:13:04.849 --> 00:13:07.084
Now I'm going to be a little bit
vague about what I mean by

00:13:07.084 --> 00:13:07.918
considered, right now.

00:13:07.918 --> 00:13:09.720
Because there are lots of
choices about how much stuff

00:13:09.720 --> 00:13:11.455
you actually consider.

00:13:11.455 --> 00:13:13.591
So let me just say consider,
and then we'll open that up

00:13:13.591 --> 00:13:18.095
and talk about the options in a
moment, so for each variable

00:13:18.095 --> 00:13:22.733
v considered for--

00:13:22.733 --> 00:13:26.237
let's call that variable
v sub i--

00:13:26.237 --> 00:13:35.546
for each x sub i, for each value
in the domain of that

00:13:35.546 --> 00:13:40.951
variable, consider each of the
things that still surviving.

00:13:40.951 --> 00:13:55.699
For each of those, for each
constraint c, that's between x

00:13:55.699 --> 00:14:08.579
sub i, and some x sub j, where
x sub j is an element of the

00:14:08.579 --> 00:14:11.248
domain of j.

00:14:11.248 --> 00:14:14.218
Now that sounds awfully fancy,
but this just says, in the

00:14:14.218 --> 00:14:18.155
case of Texas up there, whenever
I consider one of the

00:14:18.155 --> 00:14:22.359
values that's still remaining as
a choice for Texas, I want

00:14:22.359 --> 00:14:24.895
to consider all of the
constraints between that

00:14:24.895 --> 00:14:29.733
variable and the adjacent
states.

00:14:29.733 --> 00:14:34.805
And I want to be sure that
anything I leave in the domain

00:14:34.805 --> 00:14:38.542
is OK for some selection in
the other states, some

00:14:38.542 --> 00:14:41.145
remaining choices in
the other states.

00:14:41.145 --> 00:14:43.280
So that's why we're getting
pretty nested here.

00:14:43.280 --> 00:14:46.750
But we're doing depth
first search.

00:14:46.750 --> 00:14:49.953
We are considering the variables
in a certain

00:14:49.953 --> 00:14:54.825
collection of variables.

00:14:54.825 --> 00:14:57.327
For each one of those where
considering all the values

00:14:57.327 --> 00:15:00.531
that still remain in the domains
of those variables.

00:15:00.531 --> 00:15:03.133
And then for each of those
values, we're checking to see

00:15:03.133 --> 00:15:06.203
if it satisfies this some
constraint, satisfies the

00:15:06.203 --> 00:15:09.473
constraint that are
placed upon it.

00:15:09.473 --> 00:15:14.778
So for each of these constraints
if there does not

00:15:14.778 --> 00:15:23.120
exist an x sub j, such that, the
constraint between x sub i

00:15:23.120 --> 00:15:33.263
and x sub j is satisfied, well
if in that adjacent place

00:15:33.263 --> 00:15:36.967
there's nothing that is
consistent with a value, then

00:15:36.967 --> 00:15:39.570
we've got to get rid of it.

00:15:39.570 --> 00:15:40.537
If that's true.

00:15:40.537 --> 00:15:46.009
If there does not exist some
value in an adjacent variable

00:15:46.009 --> 00:15:48.579
such that that constraint is
satisfied, we're hosed.

00:15:48.579 --> 00:15:50.981
We've got to get rid
of that value.

00:15:50.981 --> 00:16:01.558
So we're going to remove
x sub i from d sub i.

00:16:05.162 --> 00:16:05.429
OK.

00:16:05.429 --> 00:16:07.264
Now, that's fine.

00:16:07.264 --> 00:16:09.900
That's sort of what
I did with Texas.

00:16:09.900 --> 00:16:13.804
As soon as I plopped down a
value for Louisiana I said,

00:16:13.804 --> 00:16:15.973
well what are the possible
values in Texas?

00:16:15.973 --> 00:16:17.808
Red, green, blue and yellow.

00:16:17.808 --> 00:16:19.810
Let's consider red.

00:16:19.810 --> 00:16:21.678
Let's consider the constraints
between Texas and

00:16:21.678 --> 00:16:23.347
all adjacent states.

00:16:23.347 --> 00:16:24.848
One of those constraints
says it can't be the

00:16:24.848 --> 00:16:26.850
same color as Arizona.

00:16:26.850 --> 00:16:28.885
The only color I've got
available for Arizona, since

00:16:28.885 --> 00:16:31.088
I've already made the
assignment is red.

00:16:31.088 --> 00:16:32.789
Red is not consistent with
red, so I've got

00:16:32.789 --> 00:16:35.258
to get rid of it.

00:16:35.258 --> 00:16:39.262
So it looks complicated, but
it's just intuition.

00:16:39.262 --> 00:16:41.965
So what do we do if we get
to a situation where

00:16:41.965 --> 00:16:43.900
the domain is empty?

00:16:43.900 --> 00:16:46.169
That means whenever we get
around to making assignment to

00:16:46.169 --> 00:16:48.739
it, there won't be
anything left.

00:16:48.739 --> 00:17:03.520
So if that ever happens, if the
domain ever becomes empty,

00:17:03.520 --> 00:17:04.954
then what do we do?

00:17:04.954 --> 00:17:06.189
We've got to back up.

00:17:13.195 --> 00:17:14.297
So the intuition is clear.

00:17:14.297 --> 00:17:15.265
This is the algorithm.

00:17:15.265 --> 00:17:18.135
The algorithm when you work
through it, think about

00:17:18.135 --> 00:17:19.536
whether it makes sense
and what not.

00:17:19.536 --> 00:17:20.569
How it fits with Texas.

00:17:20.569 --> 00:17:21.371
Yeah, it sure does.

00:17:21.371 --> 00:17:24.340
All we're doing is we're making
these death first

00:17:24.340 --> 00:17:24.907
assignments.

00:17:24.907 --> 00:17:27.477
And in the neighborhood of those
depth first assignments

00:17:27.477 --> 00:17:31.181
we're looking around to see if
the values that are possible

00:17:31.181 --> 00:17:32.148
include something.

00:17:32.148 --> 00:17:35.385
And if they don't include
anything, we know we made and

00:17:35.385 --> 00:17:39.589
irrevocable blunder, and
we have to back up.

00:17:39.589 --> 00:17:43.226
So that's the essence
of the idea.

00:17:43.226 --> 00:17:46.229
Now, how well does it work?

00:17:46.229 --> 00:17:53.770
Well a little bit depends on
what we choose for considered.

00:17:53.770 --> 00:17:55.739
There are lots of choices
for what we consider.

00:17:58.708 --> 00:18:02.545
So let me enumerate some of
those choices and then we'll

00:18:02.545 --> 00:18:03.914
have a look and see
what they do.

00:18:18.128 --> 00:18:21.898
Oh I guess one possibility
is to consider nothing.

00:18:32.275 --> 00:18:33.510
Let's try it out.

00:18:39.115 --> 00:18:42.685
So our type of search is
going to be no checks.

00:18:42.685 --> 00:18:44.087
What do you think is
going to happen?

00:18:46.790 --> 00:18:50.093
We're not even checking
the assignment.

00:18:50.093 --> 00:18:51.561
That's pretty fast.

00:18:51.561 --> 00:18:53.730
Unfortunately, since we haven't
even check the most

00:18:53.730 --> 00:18:56.666
recent assignment, we get lots
of places where there are

00:18:56.666 --> 00:18:58.668
states that are adjacent
to each other that

00:18:58.668 --> 00:19:00.303
have the same color.

00:19:00.303 --> 00:19:01.571
That's no good.

00:19:05.141 --> 00:19:09.646
So another thing we can do
is consider everything

00:19:09.646 --> 00:19:10.880
everything.

00:19:18.254 --> 00:19:20.824
That's no good, because that
would say, as soon as we color

00:19:20.824 --> 00:19:25.195
our first state, we check to
make sure that all 47 other

00:19:25.195 --> 00:19:27.463
states can be colored.

00:19:27.463 --> 00:19:31.267
That seems like it over
doing it a little bit.

00:19:31.267 --> 00:19:34.971
But in any case, at least we
want to check the assignment.

00:19:43.413 --> 00:19:47.417
So if we go back here and check
the assignment, let's

00:19:47.417 --> 00:19:48.685
see what happens.

00:19:54.190 --> 00:19:57.126
Type assignments, assignments
only.

00:19:57.126 --> 00:19:57.827
Boom.

00:19:57.827 --> 00:20:00.763
Aw, gees, that's where I
got in trouble before.

00:20:00.763 --> 00:20:08.338
This is the thing is going to
run for 17 billion years at

00:20:08.338 --> 00:20:10.506
nanosecond or something
like that.

00:20:10.506 --> 00:20:12.809
It's only a billion years if
you run it at nanosecond

00:20:12.809 --> 00:20:15.945
speed, so I guess maybe
you could do that.

00:20:15.945 --> 00:20:17.313
Have a fast computer.

00:20:17.313 --> 00:20:19.549
But this isn't going to work
because of our unfortunate

00:20:19.549 --> 00:20:25.154
choice of Texas as the last
state to be considered, and

00:20:25.154 --> 00:20:27.890
the unfortunate coloring of the
four surrounding states

00:20:27.890 --> 00:20:29.459
right up front.

00:20:29.459 --> 00:20:32.295
And our unfortunate decision to
rotate the color so as to

00:20:32.295 --> 00:20:36.499
avoid overdoing any one color.

00:20:36.499 --> 00:20:37.400
So this doesn't work.

00:20:37.400 --> 00:20:40.937
We know we went to the trouble
of working out the business

00:20:40.937 --> 00:20:46.142
with Texas by hand, using the
domain reduction algorithm.

00:20:46.142 --> 00:20:47.677
Better make a note
that this is the

00:20:47.677 --> 00:20:48.945
domain reduction algorithm.

00:20:58.554 --> 00:21:00.456
And what we're going to do is
we're going to check the

00:21:00.456 --> 00:21:03.292
neighbors of the assignments.

00:21:03.292 --> 00:21:04.160
Just like we did here.

00:21:04.160 --> 00:21:06.529
We checked Texas each time
we made one of those four

00:21:06.529 --> 00:21:10.233
choices, because it's a neighbor
of all of the choices

00:21:10.233 --> 00:21:12.668
of the states that we made.

00:21:12.668 --> 00:21:14.837
So one thing to do is
to check neighbors.

00:21:20.109 --> 00:21:23.713
This is one, two, three, now
let's see what happens.

00:21:32.455 --> 00:21:35.024
Check neighbors only, go.

00:21:53.643 --> 00:21:54.577
Shoot, I don't know.

00:21:54.577 --> 00:21:57.747
It's OK with Texas, right?

00:21:57.747 --> 00:22:02.718
Because it didn't color the
states around Texas with all

00:22:02.718 --> 00:22:04.954
of the four color choices.

00:22:04.954 --> 00:22:07.990
But it's still getting into
trouble in other places.

00:22:10.660 --> 00:22:15.097
Like the states like Missouri,
Kentucky, Virginia, Tennessee,

00:22:15.097 --> 00:22:17.266
states with lots
of boundaries.

00:22:19.869 --> 00:22:22.271
So I don't know whether
this is going to--

00:22:22.271 --> 00:22:25.541
oh, there it finally worked.

00:22:25.541 --> 00:22:28.210
It went through a lot
of effort, though.

00:22:28.210 --> 00:22:30.746
For the sake of comparison, we
might make a note that it ran

00:22:30.746 --> 00:22:43.426
into 9,139 dead ends.

00:22:43.426 --> 00:22:44.894
But it did do some good.

00:22:44.894 --> 00:22:49.398
It didn't take a length of time
longer than the remaining

00:22:49.398 --> 00:22:51.801
part of the universe.

00:22:51.801 --> 00:22:55.337
But if it's a good idea to check
the neighbors, if we

00:22:55.337 --> 00:22:58.774
make a change to the neighbors,
what might that

00:22:58.774 --> 00:23:03.145
suggests that we
do in addition?

00:23:03.145 --> 00:23:04.880
Well it might suggest that
if we make a change to a

00:23:04.880 --> 00:23:08.984
neighbor, that we check its
neighbors, too, make sure

00:23:08.984 --> 00:23:11.253
they're all right.

00:23:11.253 --> 00:23:15.691
So another choice
is to propagate.

00:23:45.654 --> 00:23:50.559
So propagate through variables
with reduced domains.

00:23:50.559 --> 00:23:51.961
Let's see how that works.

00:24:03.706 --> 00:24:04.940
Wait a minute.

00:24:06.775 --> 00:24:08.410
I must have made a mistake.

00:24:08.410 --> 00:24:10.679
Let's try that again.

00:24:10.679 --> 00:24:13.115
Oh, maybe we better
slow it down.

00:24:17.953 --> 00:24:20.989
All that grey stuff is showing
the limit of the propagation.

00:24:27.463 --> 00:24:31.967
Man it's, let's see at
four second of 40,

00:24:31.967 --> 00:24:37.706
that's about 10 seconds.

00:24:37.706 --> 00:24:39.374
Boom.

00:24:39.374 --> 00:24:40.542
Not bad.

00:24:40.542 --> 00:24:42.311
Zero dead ends.

00:24:42.311 --> 00:24:43.278
And it was a lot faster.

00:24:43.278 --> 00:24:45.047
I didn't happen to notice how
many constraints were checked

00:24:45.047 --> 00:24:48.317
on that other thing, I think
it was around 20,000 or so.

00:24:48.317 --> 00:24:50.919
This is a lot less.

00:24:50.919 --> 00:24:53.522
So this looks like
a good idea.

00:24:53.522 --> 00:24:56.425
But why did I label
it number five?

00:24:56.425 --> 00:25:00.128
Well because there's something
between this and number three.

00:25:00.128 --> 00:25:14.509
So number four is, through v
with d reduced to one value.

00:25:18.213 --> 00:25:20.916
So we're not going to propagate
through all of the

00:25:20.916 --> 00:25:24.953
variables which have their
domains shrunk a little bit.

00:25:24.953 --> 00:25:26.822
We're only going to propagate
through those that have the

00:25:26.822 --> 00:25:31.693
greater shrinkage, all the way
down to a single value.

00:25:31.693 --> 00:25:33.395
So let's see how that
might work.

00:25:44.773 --> 00:25:48.043
Anybody want to place any
bets on this one?

00:25:48.043 --> 00:25:48.477
Let's see.

00:25:48.477 --> 00:25:52.681
We checked 2,623 constraints
last time.

00:25:52.681 --> 00:25:53.949
Let's see what happens
this time.

00:25:56.785 --> 00:26:00.122
You can see that the extent of
the gray is less, because it's

00:26:00.122 --> 00:26:01.656
not propagating so far.

00:26:10.799 --> 00:26:22.878
And as we breathily await the
answer, I'd say we've found

00:26:22.878 --> 00:26:23.712
our winner.

00:26:23.712 --> 00:26:27.215
As this does a couple of dead
ends, but the number of

00:26:27.215 --> 00:26:31.219
constraint checked is
less than 1,000.

00:26:31.219 --> 00:26:33.555
So in general, with problems
this, you have all of these

00:26:33.555 --> 00:26:35.891
choices for what you consider.

00:26:35.891 --> 00:26:37.492
You don't want to consider
nothing, because then you're

00:26:37.492 --> 00:26:39.628
not honoring your constraints.

00:26:39.628 --> 00:26:41.496
You'll certainly want to
consider the things you just

00:26:41.496 --> 00:26:47.869
made assignments for, because
otherwise you'll construct a

00:26:47.869 --> 00:26:51.106
solution that violates
a constraint.

00:26:51.106 --> 00:26:54.376
You don't want to do everything,
because that's

00:26:54.376 --> 00:26:56.244
excessive work.

00:26:56.244 --> 00:27:03.018
And so checking the neighbors
is a good idea, but it's

00:27:03.018 --> 00:27:05.520
always better in practice.

00:27:05.520 --> 00:27:08.356
In practice, inevitably it's the
case that it's better to

00:27:08.356 --> 00:27:09.658
do some propagation through the

00:27:09.658 --> 00:27:11.192
things that you've changed.

00:27:11.192 --> 00:27:12.694
How much propagation?

00:27:12.694 --> 00:27:14.729
It doesn't seem to do much
good to propagate through

00:27:14.729 --> 00:27:16.264
things are just changed.

00:27:16.264 --> 00:27:18.800
But it does seem to do some good
to propagate through the

00:27:18.800 --> 00:27:19.901
things that have changed
and been

00:27:19.901 --> 00:27:22.771
reduced to a single value.

00:27:22.771 --> 00:27:25.607
So as soon as you get a neighbor
of some assignment

00:27:25.607 --> 00:27:28.476
you just made that has its
domain reduced to a single

00:27:28.476 --> 00:27:30.912
value, then you check
its neighbors, too.

00:27:30.912 --> 00:27:32.614
So you check the neighbors,
of the neighbors, of the

00:27:32.614 --> 00:27:36.484
neighbors, of the neighbors, on
and on and on, as long as

00:27:36.484 --> 00:27:40.155
you've found a domain
being reduced.

00:27:40.155 --> 00:27:43.358
And not only being reduced, but
reduced to a signal value.

00:27:43.358 --> 00:27:43.758
All right?

00:27:43.758 --> 00:27:45.393
So that's the demand reduction
algorithm.

00:27:45.393 --> 00:27:49.030
And I guarantee you a
problem like that.

00:27:49.030 --> 00:27:52.500
And I know you don't know how
to work those problems yet,

00:27:52.500 --> 00:27:54.235
because this is a little
bit abstract.

00:27:54.235 --> 00:27:58.540
And to work these problems in
the exam setting you need to

00:27:58.540 --> 00:28:01.443
know a little bit about how to
keep track of the variable

00:28:01.443 --> 00:28:03.878
values that remain in
the domain, and

00:28:03.878 --> 00:28:04.512
that sort of thing.

00:28:04.512 --> 00:28:07.015
And you'll learn more about that
in your recitations, and

00:28:07.015 --> 00:28:10.985
in this mega recitation,
and in the tutorials.

00:28:10.985 --> 00:28:13.455
So we could go home except
that there are few little

00:28:13.455 --> 00:28:16.057
flourishes to deal with here.

00:28:16.057 --> 00:28:25.400
And those flourishes,
include some dirty,

00:28:25.400 --> 00:28:27.702
filthy little secrets.

00:28:27.702 --> 00:28:31.005
For example, I've chosen,
as my classroom

00:28:31.005 --> 00:28:33.575
example, to pick on Texas.

00:28:33.575 --> 00:28:35.810
And arranged for this
situation to

00:28:35.810 --> 00:28:38.313
be especially ugly.

00:28:38.313 --> 00:28:43.284
So I could arrange the states
in a different way.

00:28:43.284 --> 00:28:45.620
We have highly constrained
states, that have a lot of

00:28:45.620 --> 00:28:48.456
bordering states around them.

00:28:48.456 --> 00:28:54.128
And we have other states, like
Maine, up there, that only

00:28:54.128 --> 00:28:56.831
borders on one other state.

00:28:56.831 --> 00:28:59.734
So I don't know.

00:28:59.734 --> 00:29:01.869
Will, what do you think?

00:29:05.173 --> 00:29:09.043
Should we arrange the states for
our death first search in

00:29:09.043 --> 00:29:12.680
the order of least constrained
to most constrained, or most

00:29:12.680 --> 00:29:13.948
constrained to least
constrained?

00:29:17.885 --> 00:29:21.289
In other words, should we
start with Missouri, or

00:29:21.289 --> 00:29:23.891
Tennessee, or Kentucky, or
something like that?

00:29:23.891 --> 00:29:26.427
Or should we start with Maine?

00:29:26.427 --> 00:29:28.396
What do you think?

00:29:28.396 --> 00:29:31.332
You have a 50% chance of getting
it right, just by

00:29:31.332 --> 00:29:33.835
[? looking ?] at points.

00:29:33.835 --> 00:29:36.137
WILL: Start with
the most first.

00:29:36.137 --> 00:29:36.170
PROF.

00:29:36.170 --> 00:29:37.105
PATRICK WINSTON: He thinks we
should start with the most

00:29:37.105 --> 00:29:38.806
constraint first.

00:29:38.806 --> 00:29:41.676
Do we have a volunteer who wants
to suggest that we start

00:29:41.676 --> 00:29:44.412
with the least constraint
first?

00:29:44.412 --> 00:29:47.782
That's the way I always
work on stuff.

00:29:47.782 --> 00:29:51.252
I'm working on a book or
something, I have 500 things

00:29:51.252 --> 00:29:54.122
to fix, I'll always choose to
work on the easiest stuff

00:29:54.122 --> 00:29:58.159
first, so that I feel like I'm
making the list a lot smaller.

00:29:58.159 --> 00:30:00.595
Leave the hardest
things to last.

00:30:00.595 --> 00:30:04.098
But we don't have any volunteers
who want to bet on

00:30:04.098 --> 00:30:07.235
that idea of least
constraint first?

00:30:07.235 --> 00:30:08.903
OK.

00:30:08.903 --> 00:30:11.205
Jason wants to suggest that
we should work on least

00:30:11.205 --> 00:30:12.240
constraint first.

00:30:12.240 --> 00:30:13.574
Well we have ground
truth, because we

00:30:13.574 --> 00:30:14.809
can just try it out.

00:30:19.514 --> 00:30:21.215
I guess we'll stick with
our shrinking to one

00:30:21.215 --> 00:30:24.152
value thing, here.

00:30:24.152 --> 00:30:29.090
But we will reorder things
so that we have the least

00:30:29.090 --> 00:30:30.324
constrained first.

00:30:34.128 --> 00:30:37.098
So right away, we got
a color for Maine.

00:30:40.334 --> 00:30:41.602
Maybe we ought to speed
this up a little bit.

00:30:46.741 --> 00:30:48.643
Well, that's a good idea.

00:30:48.643 --> 00:30:54.215
Jason suggested this and we only
1,732 constraints and we

00:30:54.215 --> 00:30:55.216
had 59 dead ends.

00:30:55.216 --> 00:31:01.122
So let's try the other way
around, and we'll go back to

00:31:01.122 --> 00:31:02.356
four frames a second.

00:31:15.069 --> 00:31:17.138
So we're working, kind of from
the middle of the country out,

00:31:17.138 --> 00:31:18.506
with this one.

00:31:18.506 --> 00:31:20.041
We're going to deal with
Maine, I guess, last.

00:31:26.080 --> 00:31:28.716
Which is better.

00:31:28.716 --> 00:31:31.852
Too bad, I think it looks
like this is better.

00:31:31.852 --> 00:31:35.056
In fact, let's not be so
aggressive with the use of

00:31:35.056 --> 00:31:36.157
constraint propagation.

00:31:36.157 --> 00:31:38.893
Let's just check the
assignments only.

00:31:38.893 --> 00:31:41.228
If we go back to an arrangement
where we have

00:31:41.228 --> 00:31:45.166
least constrained first, and
we'll crank up the speed.

00:31:48.335 --> 00:31:50.371
Well actually, we would have
to crank it up pretty big,

00:31:50.371 --> 00:31:54.909
because the states like
Missouri, Tennessee, Kentucky,

00:31:54.909 --> 00:31:58.446
they're going to
be like Texas.

00:31:58.446 --> 00:32:00.915
And so were kind of back to
the length of the universe

00:32:00.915 --> 00:32:01.615
type problem, here.

00:32:01.615 --> 00:32:04.852
With the least constraint
first, and no use of

00:32:04.852 --> 00:32:10.291
constraints, other than to check
the current assignment.

00:32:10.291 --> 00:32:14.628
So let's stop that, though, and
check the most constrained

00:32:14.628 --> 00:32:17.965
first, assignments only.

00:32:17.965 --> 00:32:19.500
I don't know how long's
this going to take.

00:32:22.069 --> 00:32:24.338
That's the dirty
little secret.

00:32:24.338 --> 00:32:28.209
If we had arranged our states
from most constrained to least

00:32:28.209 --> 00:32:30.644
constrained, ordinary depth
first search with none of this

00:32:30.644 --> 00:32:34.048
stuff we talked about today
would work just fine.

00:32:34.048 --> 00:32:35.282
All right.

00:32:38.919 --> 00:32:42.656
So it's a little
bit like games.

00:32:42.656 --> 00:32:44.425
Do you use progressive
deepening, or do

00:32:44.425 --> 00:32:45.693
you use alpha beta?

00:32:45.693 --> 00:32:47.061
And the answer is both.

00:32:47.061 --> 00:32:51.899
You use everything you've got
to deal with the problems.

00:32:51.899 --> 00:32:56.604
And depending on the problem,
one or another of the things

00:32:56.604 --> 00:32:59.440
you incorporate into your
approach will work just great,

00:32:59.440 --> 00:33:02.242
if you're lucky.

00:33:02.242 --> 00:33:06.246
So now, I promise that this is
useful not only for people who

00:33:06.246 --> 00:33:06.947
want to color maps.

00:33:06.947 --> 00:33:08.015
God, who wants to do that?

00:33:08.015 --> 00:33:10.217
We know it can be done
with four colors.

00:33:10.217 --> 00:33:13.087
But it's also useful for
doing all kinds of

00:33:13.087 --> 00:33:15.723
resource planning problems.

00:33:15.723 --> 00:33:18.092
So I want to show you a resource
planning problem, and

00:33:18.092 --> 00:33:19.994
I want you think about--
while I'm doing it--

00:33:19.994 --> 00:33:22.096
think about whether it's
actually analogous to the map

00:33:22.096 --> 00:33:22.896
coloring problem.

00:33:22.896 --> 00:33:24.465
All right?

00:33:24.465 --> 00:33:25.366
So here's the deal.

00:33:25.366 --> 00:33:29.136
You have just landed a summer
job with the Jet

00:33:29.136 --> 00:33:32.406
Green, a new airline.

00:33:32.406 --> 00:33:40.748
And Jet Green is a low cost,
no frills, hardly any

00:33:40.748 --> 00:33:43.650
maintenance type of airline.

00:33:43.650 --> 00:33:47.921
And they want to fly mostly
between Boston and New York.

00:33:47.921 --> 00:33:50.691
Occasionally they want to
fly to Los Angeles.

00:33:50.691 --> 00:33:52.059
And they're trying to
get by with the

00:33:52.059 --> 00:33:54.061
smallest number of airplanes.

00:33:54.061 --> 00:33:57.531
So that's why we have a kind of
resource allocation problem

00:33:57.531 --> 00:33:59.700
with Jet Green.

00:33:59.700 --> 00:34:02.069
So I'm going to write
down what their

00:34:02.069 --> 00:34:02.536
schedule looks like.

00:34:02.536 --> 00:34:08.775
They have one flight, F1,
that goes from Boston

00:34:08.775 --> 00:34:14.614
to JFK, like so.

00:34:14.614 --> 00:34:17.951
It's an early in
the day flight.

00:34:17.951 --> 00:34:21.221
Then they want to have
another one, F2, that

00:34:21.221 --> 00:34:24.491
flies from JFK to Boston.

00:34:29.563 --> 00:34:32.666
And then they want to have
another flight a little later

00:34:32.666 --> 00:34:36.803
in the day that flies
from Boston to JFK.

00:34:39.606 --> 00:34:41.541
And a little later than that,
they want to have another

00:34:41.541 --> 00:34:46.780
flight that goes from
JFK to Boston.

00:34:46.780 --> 00:34:49.416
They're going to start off
mostly as a shuttle airline in

00:34:49.416 --> 00:34:49.882
the beginning.

00:34:49.882 --> 00:34:55.621
So that's F1, F2, F3, and F4.

00:34:55.621 --> 00:35:00.627
And they have a fifth flight,
F5, that goes from Boston to

00:35:00.627 --> 00:35:03.797
Los Angeles, that takes
a long time.

00:35:03.797 --> 00:35:06.633
So it looks like this
on the schedule.

00:35:06.633 --> 00:35:09.136
Of course we have time
going that way.

00:35:09.136 --> 00:35:12.506
So that's Boston to LAX.

00:35:16.043 --> 00:35:22.082
Now your job is to determine if
they can fly this schedule

00:35:22.082 --> 00:35:24.818
with four aircraft?

00:35:24.818 --> 00:35:27.254
And naturally you don't want to
over use any one aircraft,

00:35:27.254 --> 00:35:30.290
because you would like to
have even wear on them.

00:35:30.290 --> 00:35:31.058
Right?

00:35:31.058 --> 00:35:35.262
So as you make your choices,
you'll rotate the aircraft.

00:35:35.262 --> 00:35:40.333
So you'll assign to this one
to A1, aircraft number one.

00:35:40.333 --> 00:35:42.335
This one will be A2.

00:35:42.335 --> 00:35:44.571
This one will be A3.

00:35:44.571 --> 00:35:47.340
And this one will be A4.

00:35:47.340 --> 00:35:51.578
And, oops, there's no aircraft
left for the flight to Los

00:35:51.578 --> 00:35:54.447
Angeles, because you
only have four.

00:35:54.447 --> 00:35:55.615
So, it's obvious, right?

00:35:55.615 --> 00:36:00.654
This is 100%, exactly, the map
coloring problem, even down to

00:36:00.654 --> 00:36:02.589
the four choices.

00:36:02.589 --> 00:36:06.226
Because, you have the
constraint, the no single

00:36:06.226 --> 00:36:11.498
physical aircraft can fly two
flights at the same time.

00:36:11.498 --> 00:36:13.099
Just like no two adjacent
states can

00:36:13.099 --> 00:36:15.001
be colored the same.

00:36:15.001 --> 00:36:20.207
So there's a no same time
constraint, like so.

00:36:27.380 --> 00:36:31.818
So if you were assigning
aircraft to these flights, you

00:36:31.818 --> 00:36:35.255
would get down to F4, the fourth
flight, and you would

00:36:35.255 --> 00:36:41.494
say, well, let's see, this
guy down here can be

00:36:41.494 --> 00:36:42.762
A1, A2, A3, or A4.

00:36:42.762 --> 00:36:45.899
But if I choose A4 for that
fourth flight, then there

00:36:45.899 --> 00:36:49.736
would be nothing left
in its domain.

00:36:49.736 --> 00:36:56.843
So you've thus set the problem
up to be identical to the map

00:36:56.843 --> 00:36:57.744
coloring problem.

00:36:57.744 --> 00:37:00.313
And, of course, you can enrich
it with other kinds of

00:37:00.313 --> 00:37:01.581
constraints.

00:37:01.581 --> 00:37:03.383
So, for example, you
might have--

00:37:03.383 --> 00:37:05.185
this is a not same
time constraint--

00:37:13.226 --> 00:37:18.198
and these, I mean,
this is at JFK.

00:37:18.198 --> 00:37:22.769
And it flies out of JFK, so
maybe you can use the same

00:37:22.769 --> 00:37:23.870
aircraft for those.

00:37:23.870 --> 00:37:25.739
But not if they're right up
against each other, because

00:37:25.739 --> 00:37:28.308
you have a minimum
ground time rule.

00:37:28.308 --> 00:37:30.210
So there's a minimum ground
time constraint here.

00:37:32.846 --> 00:37:34.681
And there's a minimum ground
time constraint here.

00:37:37.617 --> 00:37:39.419
There's a minimum ground
time constraint here.

00:37:44.224 --> 00:37:47.494
And if these are at the same
city, then you've got to allow

00:37:47.494 --> 00:37:49.696
enough time for them to fly
between the two cities that

00:37:49.696 --> 00:37:50.997
are involved.

00:37:50.997 --> 00:37:52.999
So the constraints can get a
little bit more complicated,

00:37:52.999 --> 00:37:55.602
but the idea is the same.

00:37:55.602 --> 00:37:58.872
So you say to me, I don't
trust you, show me.

00:37:58.872 --> 00:37:59.839
OK.

00:37:59.839 --> 00:38:02.809
So let me show you.

00:38:02.809 --> 00:38:04.878
Oh, by the way, there's one
more way to make this map

00:38:04.878 --> 00:38:06.112
coloring problem
easier, right?

00:38:09.616 --> 00:38:10.516
Let's see.

00:38:10.516 --> 00:38:13.987
The arrangement is going to be
alphabetical, the type is

00:38:13.987 --> 00:38:19.192
going to be assignments only,
and we know that's a loser.

00:38:19.192 --> 00:38:24.831
But not if we use a whole
lot of colors.

00:38:24.831 --> 00:38:28.701
So it's the use of four colors
that got us into trouble.

00:38:28.701 --> 00:38:30.737
Now that's an aside, but
it'll be coming back

00:38:30.737 --> 00:38:31.704
in a moment or two.

00:38:31.704 --> 00:38:35.141
Scheduling, here's
that problem.

00:38:35.141 --> 00:38:37.310
Boom.

00:38:37.310 --> 00:38:39.112
You can almost see it working
just like the

00:38:39.112 --> 00:38:40.813
map coloring thing.

00:38:40.813 --> 00:38:44.150
But that's maybe too easy.

00:38:44.150 --> 00:38:45.385
Let's do this one.

00:38:49.055 --> 00:38:52.191
See this is just like
[? simplicia. ?]

00:38:52.191 --> 00:38:55.695
We've kind of got a goofy
arrangement here that's

00:38:55.695 --> 00:38:58.965
guaranteed to lose at the bottom
because of choices made

00:38:58.965 --> 00:39:00.900
at the top.

00:39:00.900 --> 00:39:01.934
But that's OK.

00:39:01.934 --> 00:39:07.573
We can that we can stop this,
and we can change to check

00:39:07.573 --> 00:39:09.642
neighbors only.

00:39:09.642 --> 00:39:10.877
And boom, there it goes.

00:39:14.013 --> 00:39:16.416
Or alternatively, let me see
if I can do it this way.

00:39:16.416 --> 00:39:20.953
Most constrained first, type
will be assignments only.

00:39:20.953 --> 00:39:23.423
Boom.

00:39:23.423 --> 00:39:24.657
That worked fine, too.

00:39:26.959 --> 00:39:29.428
So you might choose to have
a slightly harder

00:39:29.428 --> 00:39:33.099
problem, like this.

00:39:33.099 --> 00:39:35.768
And we can search away.

00:39:40.573 --> 00:39:42.608
Actually I don't know if this
will complete or not.

00:39:42.608 --> 00:39:46.179
This is a randomly generated
example.

00:39:46.179 --> 00:39:49.248
But you're going to lose your
summer job if you can't figure

00:39:49.248 --> 00:39:51.150
out whether you can
do this, or not.

00:39:51.150 --> 00:39:52.418
So what are you going to do?

00:39:55.388 --> 00:39:57.256
[? Elliott, ?] you got any
thoughts about how you're

00:39:57.256 --> 00:40:00.426
going to save your job?

00:40:00.426 --> 00:40:03.029
So here's the question
you've been asked.

00:40:03.029 --> 00:40:08.568
How many airplanes does
Jet Green need?

00:40:08.568 --> 00:40:12.204
And you decide, well, four
seemed to work before, so

00:40:12.204 --> 00:40:14.206
we'll try four here.

00:40:14.206 --> 00:40:17.176
You're not sure if it's going
to terminate or not, I mean,

00:40:17.176 --> 00:40:20.379
in your lifetime, let alone
in your summer job.

00:40:24.951 --> 00:40:27.086
[? Elliott, ?] let me
give you a hint.

00:40:27.086 --> 00:40:28.354
Look at the outline.

00:40:30.323 --> 00:40:33.826
The outline up here, on the
board, the last item.

00:40:33.826 --> 00:40:34.794
[? ELLIOTT: [INAUDIBLE] ?]

00:40:34.794 --> 00:40:34.860
PROF.

00:40:34.860 --> 00:40:36.128
PATRICK WINSTON: Yeah,
what's that mean?

00:40:39.198 --> 00:40:42.568
What's the maximum number of
airplanes we're going to need?

00:40:42.568 --> 00:40:47.173
Suppose we've got five flights,
what's the maximum

00:40:47.173 --> 00:40:49.241
number of airplanes we
would ever need?

00:40:49.241 --> 00:40:50.543
Five.

00:40:50.543 --> 00:40:53.212
What's the minimum number
of airplanes we'll need?

00:40:53.212 --> 00:40:54.947
One.

00:40:54.947 --> 00:40:59.719
So let's try it with a small
number of airplanes and a

00:40:59.719 --> 00:41:00.953
large number of airplanes.

00:41:07.593 --> 00:41:11.363
So that showed us very
fast that we can't

00:41:11.363 --> 00:41:12.631
do it with one airplane.

00:41:21.407 --> 00:41:26.045
That showed us very fast we can
do it with ten airplanes.

00:41:26.045 --> 00:41:28.981
SPEAKER 1: [INAUDIBLE]

00:41:28.981 --> 00:41:33.886
amount of overlappage
from up [INAUDIBLE].

00:41:33.886 --> 00:41:33.953
PROF.

00:41:33.953 --> 00:41:35.187
PATRICK WINSTON: Volunteer?

00:41:37.323 --> 00:41:40.326
What are we going to do to find
the actual number, as

00:41:40.326 --> 00:41:41.260
fast as possible.

00:41:41.260 --> 00:41:45.297
And at least give our boss a
reasonable answer, even if not

00:41:45.297 --> 00:41:47.399
necessarily the exact
number very fast?

00:41:50.135 --> 00:41:50.803
It's easy, right?

00:41:50.803 --> 00:41:54.039
We're going to start up here
with one computer, and we're

00:41:54.039 --> 00:41:57.042
going to start down here
with another computer,

00:41:57.042 --> 00:41:59.111
and see what happens.

00:41:59.111 --> 00:42:01.480
So let's see if we can
do it with nine.

00:42:06.452 --> 00:42:09.421
Let's see if we can
do it with eight.

00:42:13.292 --> 00:42:16.295
Let's see if we can
do it with seven.

00:42:16.295 --> 00:42:17.796
These take almost zero
time, right?

00:42:17.796 --> 00:42:19.031
Because they're under
constraint.

00:42:22.901 --> 00:42:24.303
Wow, that's good, seven.

00:42:24.303 --> 00:42:26.005
Let's try six.

00:42:26.005 --> 00:42:27.239
Actually let's try two.

00:42:30.976 --> 00:42:32.778
It loses fast.

00:42:32.778 --> 00:42:34.013
Let's try three.

00:42:44.056 --> 00:42:44.323
I don't know.

00:42:44.323 --> 00:42:47.626
Maybe if you let it run one long
enough three will work.

00:42:47.626 --> 00:42:49.294
I doubt it.

00:42:49.294 --> 00:42:51.296
While we're at it though, we
might as well go back here and

00:42:51.296 --> 00:42:51.964
try it with six.

00:42:51.964 --> 00:42:53.232
Remember seven worked
real fast.

00:42:57.202 --> 00:42:59.705
Gees, six, that was
six, right?

00:42:59.705 --> 00:43:00.072
Yeah.

00:43:00.072 --> 00:43:01.306
So let's try it with five.

00:43:04.843 --> 00:43:05.144
OK.

00:43:05.144 --> 00:43:06.912
So it runs real fast
with five.

00:43:06.912 --> 00:43:09.848
It terminates real quick
with two, so we got

00:43:09.848 --> 00:43:11.917
three and four left.

00:43:11.917 --> 00:43:16.155
So we could tell our boss, a
la any time algorithm, that

00:43:16.155 --> 00:43:18.090
you're not real sure, but you
know it's going to be either

00:43:18.090 --> 00:43:19.458
three or four.

00:43:19.458 --> 00:43:21.460
And then, you got
two computers.

00:43:21.460 --> 00:43:25.297
You can let both run and see
if either one terminate.

00:43:25.297 --> 00:43:26.899
So you have three and four.

00:43:26.899 --> 00:43:31.336
My guess is that three will
eventually give up.

00:43:31.336 --> 00:43:33.238
But of course, there's another
little problem here.

00:43:33.238 --> 00:43:35.908
We haven't used the most
constraint first.

00:43:35.908 --> 00:43:38.710
If we did that, we might be
able to do it even faster.

00:43:38.710 --> 00:43:41.813
Actually, I don't think I can
make that switch without

00:43:41.813 --> 00:43:44.016
getting another random
assignment, but

00:43:44.016 --> 00:43:46.518
let's see what happens.

00:43:46.518 --> 00:43:48.153
Maybe so.

00:43:48.153 --> 00:43:49.421
SPEAKER 2: [INAUDIBLE]

00:43:52.391 --> 00:43:52.457
PROF.

00:43:52.457 --> 00:43:54.192
PATRICK WINSTON: Oh, I already
had most constraint first?

00:43:54.192 --> 00:43:55.561
OK.

00:43:55.561 --> 00:43:57.829
So it didn't help to
actually switch.

00:43:57.829 --> 00:44:00.933
And I think I've got a new
schedule to work here.

00:44:00.933 --> 00:44:03.368
So that's the end
of the story.

00:44:03.368 --> 00:44:07.439
You can do good resource
allocation if you do several

00:44:07.439 --> 00:44:08.707
things are once.

00:44:08.707 --> 00:44:11.643
Number one, you always want to
use most constraint first.

00:44:11.643 --> 00:44:13.545
Number two you want to propagate
through domains

00:44:13.545 --> 00:44:15.247
produced to a single
algorithm.

00:44:15.247 --> 00:44:17.582
And number three, if you really
try to figure out what

00:44:17.582 --> 00:44:21.286
the minimum number of resources
needed is, you do

00:44:21.286 --> 00:44:24.589
this under over business and you
can quickly converge on a

00:44:24.589 --> 00:44:27.726
narrow range where the search is
taking a long time, and be

00:44:27.726 --> 00:44:31.496
sure that it lies within
that narrow range.

00:44:31.496 --> 00:44:34.499
Because when you over resource,
it's fast to

00:44:34.499 --> 00:44:36.868
complete, and when you
under resource,

00:44:36.868 --> 00:44:39.371
it's fast to terminate.

00:44:39.371 --> 00:44:41.373
So you can just squeeze
it right down into

00:44:41.373 --> 00:44:42.808
a very small range.

00:44:42.808 --> 00:44:44.476
And that is the end
of the story.

00:44:44.476 --> 00:44:45.911
Enjoy your holiday on Monday.

00:44:45.911 --> 00:44:50.849
We'll have two classes next week
on Wednesday and Friday,

00:44:50.849 --> 00:44:52.117
as advertised.