1 00:00:04,500 --> 00:00:06,440 Let's look at how sports scheduling can 2 00:00:06,440 --> 00:00:11,000 be done with optimization by starting with a small example. 3 00:00:11,000 --> 00:00:14,060 Suppose we're trying to schedule a tournament between four 4 00:00:14,060 --> 00:00:19,390 teams-- Atlanta, Boston, Chicago, and Detroit. 5 00:00:19,390 --> 00:00:24,610 We'll call these teams A, B, C, and D. 6 00:00:24,610 --> 00:00:27,750 These teams are divided into two divisions. 7 00:00:27,750 --> 00:00:30,700 Atlanta and Boston are in one division, 8 00:00:30,700 --> 00:00:34,470 and Chicago and Detroit are in the second division. 9 00:00:34,470 --> 00:00:39,780 Each team plays one game a week for a total of four weeks. 10 00:00:39,780 --> 00:00:43,470 During the four weeks, each team plays the other team 11 00:00:43,470 --> 00:00:47,520 in the same division twice, and each team 12 00:00:47,520 --> 00:00:52,020 plays the teams in the other divisions once. 13 00:00:52,020 --> 00:00:54,880 The team with the most wins from each division 14 00:00:54,880 --> 00:00:57,650 will play in the championship game. 15 00:00:57,650 --> 00:01:03,060 For this reason, teams prefer to play divisional games later. 16 00:01:03,060 --> 00:01:07,280 If team A plays team C and D in the first two weeks 17 00:01:07,280 --> 00:01:12,350 and wins both games while team B also plays team C and D 18 00:01:12,350 --> 00:01:15,970 and loses both games, A knows that they only 19 00:01:15,970 --> 00:01:18,930 need to win one of the games against B 20 00:01:18,930 --> 00:01:22,110 to beat B in terms of wins and to go to the championship. 21 00:01:25,130 --> 00:01:29,850 We can schedule this tournament by using an optimization model. 22 00:01:29,850 --> 00:01:34,150 Our objective is to maximize team preferences, which 23 00:01:34,150 --> 00:01:38,130 are that teams would like to play divisional games later. 24 00:01:38,130 --> 00:01:41,140 Our decisions are which teams should 25 00:01:41,140 --> 00:01:43,539 play each other each week. 26 00:01:43,539 --> 00:01:46,759 And we have three types of constraints. 27 00:01:46,759 --> 00:01:49,590 Each team needs to play the other team in their division 28 00:01:49,590 --> 00:01:53,770 twice, each team needs to play the teams in the other division 29 00:01:53,770 --> 00:01:59,759 once, and each team should play exactly one team each week. 30 00:01:59,759 --> 00:02:03,220 Let's start by discussing our decision variables. 31 00:02:03,220 --> 00:02:07,630 We need to decide which teams will play each other each week. 32 00:02:07,630 --> 00:02:10,789 To do this, let's define decision variables 33 00:02:10,789 --> 00:02:14,660 which we'll call x_ijk. 34 00:02:14,660 --> 00:02:19,650 If team i plays team j in week k, 35 00:02:19,650 --> 00:02:23,140 then x_ijk will be equal to 1. 36 00:02:23,140 --> 00:02:27,360 Otherwise, x_ijk equals 0. 37 00:02:27,360 --> 00:02:33,400 As an example, suppose team A plays team C in week 2. 38 00:02:33,400 --> 00:02:38,470 Then x_AC2 would equal 1. 39 00:02:38,470 --> 00:02:42,570 Since A only plays C once, we should have then 40 00:02:42,570 --> 00:02:49,160 that x_AC1, or A playing C in week 1, should be equal to 0. 41 00:02:49,160 --> 00:02:58,520 Similarly, x_AC3 should equal 0, and x_AC4 should equal 0. 42 00:02:58,520 --> 00:03:01,980 This is called a binary decision variable 43 00:03:01,980 --> 00:03:03,850 since it's a decision variable that 44 00:03:03,850 --> 00:03:07,000 can only take two values, 0 and 1. 45 00:03:09,660 --> 00:03:12,050 This is a new type of decision variable, 46 00:03:12,050 --> 00:03:14,190 and it's what makes integer optimization 47 00:03:14,190 --> 00:03:17,040 different from linear optimization. 48 00:03:17,040 --> 00:03:20,440 The decision variables in integer optimization 49 00:03:20,440 --> 00:03:23,460 can only take integer values. 50 00:03:23,460 --> 00:03:26,520 This includes binary decision variables, 51 00:03:26,520 --> 00:03:31,480 like the ones we have here, that can only be either 0 or 1. 52 00:03:31,480 --> 00:03:33,850 These variables can model decisions 53 00:03:33,850 --> 00:03:36,010 like where to build a new warehouse, 54 00:03:36,010 --> 00:03:38,590 whether or not to invest in a stock, 55 00:03:38,590 --> 00:03:42,030 or assigning nurses to shifts. 56 00:03:42,030 --> 00:03:44,300 Integer optimization problems can also 57 00:03:44,300 --> 00:03:52,090 have integer decision variables that take values 1, 2, 3, 4, 5, 58 00:03:52,090 --> 00:03:53,530 etc. 59 00:03:53,530 --> 00:03:55,900 These variables can model decisions 60 00:03:55,900 --> 00:03:59,030 like the number of new machines to purchase, 61 00:03:59,030 --> 00:04:02,120 the number of workers to assign for a shift, 62 00:04:02,120 --> 00:04:05,830 and the number of items to stock in a store. 63 00:04:05,830 --> 00:04:08,920 Other than the new types of variables, integer optimization 64 00:04:08,920 --> 00:04:11,990 is exactly like linear optimization. 65 00:04:11,990 --> 00:04:15,920 But we'll see this week how integer optimization variables, 66 00:04:15,920 --> 00:04:19,510 and especially binary variables, can increase our modeling 67 00:04:19,510 --> 00:04:20,050 capabilities. 68 00:04:22,790 --> 00:04:25,870 Now let's go back to our formulation. 69 00:04:25,870 --> 00:04:28,750 As we said before, our decisions are 70 00:04:28,750 --> 00:04:33,320 which teams should play each other each week. 71 00:04:33,320 --> 00:04:36,630 We'll model this with the binary decision variables 72 00:04:36,630 --> 00:04:41,010 we just discussed-- x_ijk which equal 1 73 00:04:41,010 --> 00:04:45,190 if team i plays team j in week k. 74 00:04:45,190 --> 00:04:47,630 Now let's use these decision variables 75 00:04:47,630 --> 00:04:49,770 to form our constraints. 76 00:04:49,770 --> 00:04:52,860 The first constraint is that each team 77 00:04:52,860 --> 00:04:56,380 should play the other team in their division twice. 78 00:04:56,380 --> 00:04:59,659 So teams A and B should play each other twice 79 00:04:59,659 --> 00:05:01,850 in the four weeks. 80 00:05:01,850 --> 00:05:09,100 This can be modeled with the constraint x_AB1 + x_AB2 + 81 00:05:09,100 --> 00:05:14,780 x_AB3 + x_AB4 = 2. 82 00:05:14,780 --> 00:05:17,640 This will force two of these decision variables 83 00:05:17,640 --> 00:05:21,150 to be equal to 1, and the other two decision variables 84 00:05:21,150 --> 00:05:23,030 to be equal to 0. 85 00:05:23,030 --> 00:05:26,890 The ones that are equal to 1 will correspond to the weeks 86 00:05:26,890 --> 00:05:29,310 that A and B will play each other. 87 00:05:29,310 --> 00:05:33,930 We'll have a similar constraint for teams C and D. 88 00:05:33,930 --> 00:05:36,860 Our next constraint is that each team 89 00:05:36,860 --> 00:05:40,270 should play the teams in the other division once. 90 00:05:40,270 --> 00:05:43,550 So teams A and C should play each other once 91 00:05:43,550 --> 00:05:46,000 in the four weeks. 92 00:05:46,000 --> 00:05:53,130 This can be modeled with a constraint x_AC1 + x_AC2 + 93 00:05:53,130 --> 00:05:59,040 x_AC3 + x_AC4 = 1. 94 00:05:59,040 --> 00:06:02,450 This is very similar to the previous constraint, 95 00:06:02,450 --> 00:06:05,650 except this time only one of the decision variables 96 00:06:05,650 --> 00:06:07,620 will have value 1. 97 00:06:07,620 --> 00:06:11,250 We'll have similar constraints for teams A and D, 98 00:06:11,250 --> 00:06:18,020 teams B and C, and teams B and D. Our last type of constraint 99 00:06:18,020 --> 00:06:20,720 is that each team should play exactly one 100 00:06:20,720 --> 00:06:22,780 other team each week. 101 00:06:22,780 --> 00:06:29,160 This means that A should play B, C or D in week 1. 102 00:06:29,160 --> 00:06:33,210 This can be modeled with a constraint x_AB1 103 00:06:33,210 --> 00:06:39,470 + x_AC1 + x_AD1 = 1. 104 00:06:39,470 --> 00:06:43,710 Exactly one of these decision variables will be equal to 1, 105 00:06:43,710 --> 00:06:47,650 meaning that A will play that team in week 1. 106 00:06:47,650 --> 00:06:52,850 We'll have a similar constraint for every team and week pair. 107 00:06:52,850 --> 00:06:56,570 Now, let's model our objective. 108 00:06:56,570 --> 00:07:00,170 Let's assume that teams have a preference of 1 109 00:07:00,170 --> 00:07:05,080 for playing divisional games in week 1, a preference of 2 110 00:07:05,080 --> 00:07:09,790 for playing divisional games in week 2, a preference of 4 111 00:07:09,790 --> 00:07:14,060 for playing divisional games in week 3, and a preference of 8 112 00:07:14,060 --> 00:07:16,940 for playing divisional games in week 4. 113 00:07:16,940 --> 00:07:21,490 So the preference doubles with each later week. 114 00:07:21,490 --> 00:07:33,980 Then we can model our objective as x_AB1 + 2*x_AB2 + 4*x_AB3 + 115 00:07:33,980 --> 00:07:46,950 8*x_AB4 + x_CD1 + 2*x_CD2 + 4*x_CD3 + 8*x_CD4. 116 00:07:50,150 --> 00:07:56,740 Then if team AB plays in week 3, we'll add 4 to our objective. 117 00:07:56,740 --> 00:07:59,110 If they play in week 1, then we'll 118 00:07:59,110 --> 00:08:01,870 only add 1 to our objective. 119 00:08:01,870 --> 00:08:05,270 If they don't play in a week, that term will be 0 120 00:08:05,270 --> 00:08:08,900 and will not contribute to the objective. 121 00:08:08,900 --> 00:08:10,780 Now that we've set up our problem, 122 00:08:10,780 --> 00:08:12,650 we're ready to solve it. 123 00:08:12,650 --> 00:08:15,750 In the next video, we'll set up and solve our problem 124 00:08:15,750 --> 00:08:17,290 in LibreOffice.