1
00:00:18,050 --> 00:00:25,140
in today's class we will look at another formulation
for linear programming which is called the
2
00:00:25,140 --> 00:00:33,070
napkins problem this napkins problem also
sometimes called the caterer problem is a
3
00:00:33,070 --> 00:00:42,400
very important formulation in linear programming
the problem is as follows the requirement
4
00:00:42,400 --> 00:00:50,150
of napkins on five consecutive days of dinner
is hundred sixty eighty ninety and seventy
5
00:00:50,150 --> 00:00:58,989
which means that they are going to have dinner
on five consecutive days and for each guest
6
00:00:58,989 --> 00:01:05,700
there is a napkin that is given for them to
use and the requirement of these napkins are
7
00:01:05,700 --> 00:01:17,130
given as hundred sixty eighty ninety and seventy
a new napkin costs rupees sixty we can also
8
00:01:17,130 --> 00:01:23,959
send some of the used napkins to a laundry
and these napkins sent to a laundry at the
9
00:01:23,959 --> 00:01:30,750
end of any day which means after the dinner
can be used from the second day onwards which
10
00:01:30,750 --> 00:01:39,390
means if we send a bunch of napkins at the
end of the first day's dinner to the laundry
11
00:01:39,390 --> 00:01:47,170
we will assume that these napkins that have
come from the laundry can be used for the
12
00:01:47,170 --> 00:01:56,670
dinner on the third day and so on we can actually
use these napkins even on days four and five
13
00:01:56,670 --> 00:02:04,060
now we have some use napkins are sent to the
laundry at the end of the second day then
14
00:02:04,060 --> 00:02:11,500
they can be used from day four onwards and
so on the laundry cost is rupees twenty per
15
00:02:11,500 --> 00:02:18,810
napkin to wash and give it back find a solution
to the napkins problem that minimizes the
16
00:02:18,810 --> 00:02:28,730
total cost
now we first introduce the decision variables
17
00:02:28,730 --> 00:02:38,470
now there are five days it is possible to
use new napkins on each of these five days
18
00:02:38,470 --> 00:02:48,379
so we can define x one to x five as the number
of new napkins bought on days one to five
19
00:02:48,379 --> 00:02:54,550
we can also define x one to x five the same
variables as the number of new napkins used
20
00:02:54,550 --> 00:03:01,620
on days one to five they mean the same so
x one to x five would represent the number
21
00:03:01,620 --> 00:03:14,280
of new napkins used in day one to five now
we can also use napkins that have come from
22
00:03:14,280 --> 00:03:24,760
the laundry and we can put it to use on certain
days because this problem has demand only
23
00:03:24,760 --> 00:03:37,370
for five days and the laundry takes two days
we are not going to consider putting the used
24
00:03:37,370 --> 00:03:44,280
napkins to the laundry on days four and five
because when they come back they cannot be
25
00:03:44,280 --> 00:03:52,190
used therefore we are going to define that
we are going to send used napkins to the laundry
26
00:03:52,190 --> 00:03:59,940
only on the first three days and therefore
we introduce y one to y three as the number
27
00:03:59,940 --> 00:04:08,840
of used napkins sent to the laundry at the
end of days one two and three let me again
28
00:04:08,840 --> 00:04:13,069
explain the variables
there are five days in which we are going
29
00:04:13,069 --> 00:04:21,599
to have the dinner and obviously we can use
new napkins for the dinner so x one to x five
30
00:04:21,599 --> 00:04:29,900
will represent the number of new napkins used
in days one to five i have indicated here
31
00:04:29,900 --> 00:04:34,639
that they are bought on that day they are
bought and used they can be used so the number
32
00:04:34,639 --> 00:04:41,699
of new napkins used on that day y one to y
three represent the number of napkins sent
33
00:04:41,699 --> 00:04:48,939
to laundry at the end of days one two and
three now we don't define y four and y five
34
00:04:48,939 --> 00:04:57,939
because if some used napkins are sent at the
end of day four they will arrive on day six
35
00:04:57,939 --> 00:05:05,539
and can be used from day six onwards but the
problem talks only about five days therefore
36
00:05:05,539 --> 00:05:13,960
we do not introduce y four and y five and
we introduce only y one to y three so we have
37
00:05:13,960 --> 00:05:22,050
eight variables five variables representing
the new napkins for days one to five and three
38
00:05:22,050 --> 00:05:29,930
variables representing the number of napkins
sent to the laundry at the end of days one
39
00:05:29,930 --> 00:05:37,059
two and three so there are eight variables
in this formulation we will now look at the
40
00:05:37,059 --> 00:05:43,259
look at the constraints
now the important constraint is that the demand
41
00:05:43,259 --> 00:05:52,270
for napkins on each day has to be met so day
one demand x one is the number of new napkins
42
00:05:52,270 --> 00:05:59,339
used in day one x one should be greater than
or equal to hundred because hundred is the
43
00:05:59,339 --> 00:06:07,650
demand for day one the first day we have only
one way of meeting the demand which is by
44
00:06:07,650 --> 00:06:19,110
using new napkins that come from the laundry
can be used only on days three four and five
45
00:06:19,110 --> 00:06:25,889
because we have defined variables as the napkins
that go to the laundry at the end of days
46
00:06:25,889 --> 00:06:34,360
one two and three and these y one y two and
y three number of napkins which go at the
47
00:06:34,360 --> 00:06:41,729
end of days one two and three can be used
to make the demand of days three four and
48
00:06:41,729 --> 00:06:51,740
five because they take two days to come back
so the first two days we have to use new napkins
49
00:06:51,740 --> 00:07:00,779
and therefore to meet the first day's demand
we have x one greater than or equal to hundred
50
00:07:00,779 --> 00:07:12,229
second day's demand we have to use new napkins
but we can also do something like this we
51
00:07:12,229 --> 00:07:20,159
can either buy exactly the required number
of napkins on day two or nothing prevents
52
00:07:20,159 --> 00:07:26,710
us from buying more than hundred on day one
and using the remaining ones to meet the demand
53
00:07:26,710 --> 00:07:33,819
of day two so we can buy more than hundred
on day one and use some of the extra napkins
54
00:07:33,819 --> 00:07:42,449
on day two so this becomes x one minus hundred
plus x two is greater than or equal to sixty
55
00:07:42,449 --> 00:07:49,449
now this comes because we have x one greater
than or equal to hundred the number of new
56
00:07:49,449 --> 00:07:57,220
the number of napkins bought on day one is
greater than or equal to hundred so x one
57
00:07:57,220 --> 00:08:04,050
minus hundred napkins can be carried to day
two so x one minus hundred napkins that are
58
00:08:04,050 --> 00:08:10,909
carried to day two plus x two which are the
number of napkins bought at the beginning
59
00:08:10,909 --> 00:08:17,659
of day two now these two act as supplies for
day two and this should be greater than or
60
00:08:17,659 --> 00:08:26,990
equal to sixty
so this is rewritten as x one plus x two greater
61
00:08:26,990 --> 00:08:31,449
than or equal to hundred and sixty because
you take this hundred to the other side of
62
00:08:31,449 --> 00:08:37,089
the inequality so x one plus x two greater
than or equal to hundred and sixty which is
63
00:08:37,089 --> 00:08:43,409
shown in blue color and the two constraints
shown in blue color are the actual constrains
64
00:08:43,409 --> 00:08:51,980
for days one and two respectively now we move
on to the third day now the third day we have
65
00:08:51,980 --> 00:09:01,089
to meet the demand and we can do it in three
ways one is if we could carry some extra new
66
00:09:01,089 --> 00:09:06,610
napkins which have not been used new napkins
which have not been used at the end of second
67
00:09:06,610 --> 00:09:14,779
day we can buy some new napkins on the third
day and some napkins that we have put to the
68
00:09:14,779 --> 00:09:22,440
laundry at the end of the first day are going
to come back as usable napkins and therefore
69
00:09:22,440 --> 00:09:28,199
there are three ways in which we could meet
the demand of day three
70
00:09:28,199 --> 00:09:34,410
so extra napkins from day two new napkins
bought on day three and napkins received from
71
00:09:34,410 --> 00:09:44,730
laundry on day three which were sent at the
end of day one so this gives us now from the
72
00:09:44,730 --> 00:09:51,300
previous constraint x one plus x two greater
than or equal to one sixty now the extra napkins
73
00:09:51,300 --> 00:09:57,829
that are available extra new napkins that
are available are x one plus x two minus one
74
00:09:57,829 --> 00:10:05,630
sixty so that act as some kind of a supply
for day three so x one plus x two minus one
75
00:10:05,630 --> 00:10:12,509
sixty is the number of new napkins that are
available at the end of day two and have not
76
00:10:12,509 --> 00:10:19,470
yet been used so they can be used to meet
the demand of day three so x one plus x two
77
00:10:19,470 --> 00:10:27,199
minus one sixty plus x three napkins are bought
in day three so they can be used plus y one
78
00:10:27,199 --> 00:10:36,720
napkins have come back from the laundry y
one was sent at the end of day one so y one
79
00:10:36,720 --> 00:10:43,520
napkins would come back from the laundry so
x one plus x two minus hundred and sixty plus
80
00:10:43,520 --> 00:10:50,000
x three plus y one should be greater than
or equal to eighty which is the demand for
81
00:10:50,000 --> 00:10:56,089
day three now this is again simplified and
the hundred and sixty is taken to the other
82
00:10:56,089 --> 00:11:02,649
side of the inequality to give us x one plus
x two plus x three plus y one greater than
83
00:11:02,649 --> 00:11:07,630
or equal to two forty
you can also see a pattern emerging in the
84
00:11:07,630 --> 00:11:14,490
constraints the first constraint had only
x one and the first day's demand the second
85
00:11:14,490 --> 00:11:20,850
constraint has x one plus x two and the sum
of two days demand the third constraint has
86
00:11:20,850 --> 00:11:27,060
x one plus x two plus x three plus another
y one the sum of three days demand so you
87
00:11:27,060 --> 00:11:34,670
can see a pattern emerging and you will see
that this pattern will continue now day four
88
00:11:34,670 --> 00:11:44,720
again has three sources now at the end of
day three if we have unused new napkins they
89
00:11:44,720 --> 00:11:57,069
can be used on day four new napkins bought
on day four napkins received from laundry
90
00:11:57,069 --> 00:12:04,400
on day four that were sent on day two so there
are three sources and we also have to bear
91
00:12:04,400 --> 00:12:13,100
in mind that the extra napkins that are available
unused napkins available at day three now
92
00:12:13,100 --> 00:12:20,699
can be new napkins can also be some of the
napkins that have come on the earlier day
93
00:12:20,699 --> 00:12:28,810
and have not been used so i have written here
day four's demand can be met in three ways
94
00:12:28,810 --> 00:12:36,210
extra napkins available for use at the end
of day three now we don't really worry at
95
00:12:36,210 --> 00:12:40,069
this point whether they are new or they have
come from the laundry the inequality will
96
00:12:40,069 --> 00:12:49,220
tell us that these number are extra napkins
new napkins bought on day four and napkins
97
00:12:49,220 --> 00:12:56,560
that have come on day four morning or before
the dinner and these have been sent at the
98
00:12:56,560 --> 00:13:01,949
end of day two
so again there are types of supplies and these
99
00:13:01,949 --> 00:13:09,660
three are written as from the previous constraint
x one plus x two plus x three plus y one are
100
00:13:09,660 --> 00:13:15,850
the napkins available for use on day three
that has to be greater than or equal to two
101
00:13:15,850 --> 00:13:23,430
forty so if there is an excess so x one plus
x two plus x three plus y one minus two forty
102
00:13:23,430 --> 00:13:30,550
is what is carried from day three to day four
which represents the extra napkins from day
103
00:13:30,550 --> 00:13:38,529
three to day four so x one plus x two plus
x three plus x y one again repeating is the
104
00:13:38,529 --> 00:13:44,759
number of napkins available for use in day
three now that is greater than or equal to
105
00:13:44,759 --> 00:13:50,010
two forty and with that we meet the demand
of day three in addition to day two and day
106
00:13:50,010 --> 00:13:57,990
one now this inequality if x one plus x two
plus x three plus y one exceeds two forty
107
00:13:57,990 --> 00:14:04,570
then a balance of x one plus x two plus x
three plus y one minus two forty is carried
108
00:14:04,570 --> 00:14:11,480
over to the fourth day and that represents
the extra napkins from day three x four is
109
00:14:11,480 --> 00:14:19,379
bought on the fourth day and y two are received
before the dinner on the fourth day and y
110
00:14:19,379 --> 00:14:26,709
two are the number of napkins sent at the
end of the second day to the laundry so these
111
00:14:26,709 --> 00:14:33,410
available napkins for the day four are x one
plus x two plus x three plus y one minus two
112
00:14:33,410 --> 00:14:40,139
forty plus x four plus y two should be greater
than or equal to ninety which is the demand
113
00:14:40,139 --> 00:14:45,920
for the fourth day
now this is rewritten as x one plus x two
114
00:14:45,920 --> 00:14:53,540
plus x three plus x four plus y one plus y
two greater than or equal to three thirty
115
00:14:53,540 --> 00:15:01,400
x one plus x two plus x three plus x four
plus y one plus y two is greater than or equal
116
00:15:01,400 --> 00:15:07,139
to three thirty now consistent with the pattern
you can now see the first constraint as x
117
00:15:07,139 --> 00:15:13,879
one and first days' demand the second constraint
has x one plus x two and it has sum of two
118
00:15:13,879 --> 00:15:21,930
days demand the third constraint has x one
plus x two plus x three and a y one and three
119
00:15:21,930 --> 00:15:28,709
days demand the fourth constraint has x one
plus x two plus x three plus x four which
120
00:15:28,709 --> 00:15:36,620
is new napkins but on four days plus y one
plus y two napkins that are coming in and
121
00:15:36,620 --> 00:15:44,560
then greater than or equal to sum of the four
days demand so you can see that pattern emerging
122
00:15:44,560 --> 00:15:51,089
we now move to the fifth day so again the
fifth day will have three types of supplies
123
00:15:51,089 --> 00:15:57,880
the excess napkins available at the end of
the fourth day the new napkins bought on the
124
00:15:57,880 --> 00:16:04,430
fifth day and the napkins received from the
laundry just before dinner on the fifth day
125
00:16:04,430 --> 00:16:11,300
and these have been sent to the laundry at
the end of the third day so we write this
126
00:16:11,300 --> 00:16:17,970
the expression becomes longer so we could
go back to the previous one and say that now
127
00:16:17,970 --> 00:16:23,589
this is the day four constraint so x one plus
x two plus x three plus x four plus y one
128
00:16:23,589 --> 00:16:31,139
plus y two minus three hundred and thirty
are the extra napkins carried from day four
129
00:16:31,139 --> 00:16:39,110
to day five so x one plus x two plus x three
plus x four plus y one plus y two minus three
130
00:16:39,110 --> 00:16:44,589
hundred and thirty is what is carried this
long expression is what is carried from day
131
00:16:44,589 --> 00:16:51,439
four to day five
and then we buy another x five on day five
132
00:16:51,439 --> 00:16:57,389
and then we have the other supply of y three
which has come before dinner on the fifth
133
00:16:57,389 --> 00:17:05,380
day and this y three had been sent to the
laundry at the end of the third day so this
134
00:17:05,380 --> 00:17:11,410
should be greater than or equal to seventy
which is the requirement for the fifth day
135
00:17:11,410 --> 00:17:16,439
now this is again simplified to the three
hundred and thirty is taken to the other side
136
00:17:16,439 --> 00:17:22,900
of the inequality so x one plus x two plus
x three plus x four plus x five plus y one
137
00:17:22,900 --> 00:17:28,350
plus y two plus y three is greater than or
equal to four hundred and consistent with
138
00:17:28,350 --> 00:17:34,710
the pattern you realize that x one to x five
is appearing in the fifth constraint y one
139
00:17:34,710 --> 00:17:41,060
to y three is appearing in the fifth constraint
and the sum of demands of all five days are
140
00:17:41,060 --> 00:17:50,020
appearing now this is happening largely because
we could carry the excess napkins on a certain
141
00:17:50,020 --> 00:17:57,300
day for use on a subsequent day because we
are modeling this we get the constraint of
142
00:17:57,300 --> 00:18:07,030
this type where for each day finally the constraint
is the sum of the demands of upto that day
143
00:18:07,030 --> 00:18:14,250
so we have now written all the five constraints
to meet the demand on all the five days now
144
00:18:14,250 --> 00:18:21,470
we also have some limits on the number of
napkins that can be sent to laundry now these
145
00:18:21,470 --> 00:18:27,460
are y one less than equal to hundred y two
less than equal to sixty and y three less
146
00:18:27,460 --> 00:18:34,200
than or equal to eighty this is because the
demand for day one is hundred and therefore
147
00:18:34,200 --> 00:18:41,420
at the end of day one we can have a maximum
of hundred soiled napkins and we will assume
148
00:18:41,420 --> 00:18:48,540
that all these hundred are used by the people
and therefore poses a limit on what can be
149
00:18:48,540 --> 00:18:54,930
sent to the laundry at the end of day one
so y one less than equal to hundred y two
150
00:18:54,930 --> 00:19:01,650
less than equal to sixty and y three less
than or equal to eighty
151
00:19:01,650 --> 00:19:09,540
so these three constraints give the limit
on the napkins sent to the laundry and the
152
00:19:09,540 --> 00:19:19,420
objective function now will be to minimize
the costs the new napkin cost sixty and we
153
00:19:19,420 --> 00:19:26,550
are buying x one plus x two plus x three plus
x four plus x five amount of new napkins on
154
00:19:26,550 --> 00:19:33,300
days one to five so the new napkin cost is
sixty into x one plus x two plus x three plus
155
00:19:33,300 --> 00:19:41,830
x four plus x five y one plus y two plus y
three is the number of napkins sent to laundry
156
00:19:41,830 --> 00:19:49,650
taking into account all the three days the
laundry cost is twenty per napkin so twenty
157
00:19:49,650 --> 00:19:55,750
into y one plus y two plus y three so the
objective function is to minimize the total
158
00:19:55,750 --> 00:20:05,300
cost which is the cost of new napkins and
also the cost of sending these napkins to
159
00:20:05,300 --> 00:20:13,370
the laundry we also have the non negativity
restriction where we have all the x variables
160
00:20:13,370 --> 00:20:23,320
and the y variables to be greater than or
equal to zero we also summarize this by giving
161
00:20:23,320 --> 00:20:29,210
a general formulation
so x one be the number of new napkins bought
162
00:20:29,210 --> 00:20:35,400
on day i x i be the number of new napkins
bought on day i the number of napkins sent
163
00:20:35,400 --> 00:20:43,560
to laundry at the end of day i be y i c is
the cost of the new napkin a is the laundry
164
00:20:43,560 --> 00:20:50,490
cost d is the demand and p is the number of
days it takes in the laundry so our objective
165
00:20:50,490 --> 00:20:58,780
function will be the sum of the new napkin
cost and the laundry cost now x i is the new
166
00:20:58,780 --> 00:21:06,940
napkins bought on day i i i equal to one to
n so x one to x n and c is this cost now the
167
00:21:06,940 --> 00:21:15,760
y variable will be from one to n minus p in
our example we looked at five days total and
168
00:21:15,760 --> 00:21:22,300
two days for the laundry so only the first
three days we set therefore we will have y
169
00:21:22,300 --> 00:21:29,430
i i equal to one to n minus p
a a typical constraint would look like on
170
00:21:29,430 --> 00:21:37,480
on a particular day i the sum of the new napkins
upto i plus the sum of the napkins that have
171
00:21:37,480 --> 00:21:44,110
come from laundry upto that day is greater
than or equal to sum of the demands upto that
172
00:21:44,110 --> 00:21:52,560
day so this was our five constraints that
we had for each of these five days the limit
173
00:21:52,560 --> 00:22:00,580
on putting the napkins to laundry is y i less
than or equal to d i so each day i can put
174
00:22:00,580 --> 00:22:07,880
only the maximum demand to the laundry x i
y i greater than or equal to zero is a general
175
00:22:07,880 --> 00:22:15,360
formulation of the napkins problem we have
seen a slightly simpler version of this problem
176
00:22:15,360 --> 00:22:19,950
in many instances you would observe that there
will be two types of laundries there will
177
00:22:19,950 --> 00:22:26,450
be a fast and a slow laundry but just to make
the problem simple i have used only one type
178
00:22:26,450 --> 00:22:33,290
of laundry so this napkins problem or the
caterer problem is a very important formulation
179
00:22:33,290 --> 00:22:38,340
in linear programming
in the next class we will look at two more
180
00:22:38,340 --> 00:22:41,350
formulations related to linear programming