1
00:00:04,490 --> 00:00:06,160
One of the most
powerful properties

2
00:00:06,160 --> 00:00:09,280
of integer optimization
is the ability

3
00:00:09,280 --> 00:00:13,240
to add what we call
logical constraints.

4
00:00:13,240 --> 00:00:15,990
These use binary
variables to implement

5
00:00:15,990 --> 00:00:17,700
different restrictions.

6
00:00:17,700 --> 00:00:20,140
Let's look at a few examples.

7
00:00:20,140 --> 00:00:23,730
Suppose we want to add the
constraint that A and B can't

8
00:00:23,730 --> 00:00:27,140
play in both weeks 3 and 4.

9
00:00:27,140 --> 00:00:33,940
We can do this by adding the
constraint x_AB3 + x_AB4 less

10
00:00:33,940 --> 00:00:35,710
than or equal to 1.

11
00:00:35,710 --> 00:00:39,090
What are feasible values
for these two variables,

12
00:00:39,090 --> 00:00:41,600
given this constraint?

13
00:00:41,600 --> 00:00:46,910
Both variables can be 0, or
one or the other can be 1.

14
00:00:46,910 --> 00:00:51,620
A solution with both variables
equal to 1 would be infeasible.

15
00:00:51,620 --> 00:00:54,340
So this constraint
models the restriction

16
00:00:54,340 --> 00:00:59,310
that teams A and B can't
play in both weeks 3 and 4.

17
00:00:59,310 --> 00:01:02,260
Note that this only works
because the variables only

18
00:01:02,260 --> 00:01:05,310
take values 0 or 1.

19
00:01:05,310 --> 00:01:07,930
Let's look at another example.

20
00:01:07,930 --> 00:01:10,310
Suppose we want to
add the restriction

21
00:01:10,310 --> 00:01:13,340
that if A and B
play in week 4, then

22
00:01:13,340 --> 00:01:16,140
they must also play in week 2.

23
00:01:16,140 --> 00:01:21,390
We can do this by adding the
constraint x_AB2 greater than

24
00:01:21,390 --> 00:01:24,140
or equal to x_AB4.

25
00:01:24,140 --> 00:01:28,130
Let's consider feasible
solutions to this constraint.

26
00:01:28,130 --> 00:01:35,440
If x_AB4 equals 1, then
x_AB2 must also equal 1.

27
00:01:35,440 --> 00:01:39,970
But if x_AB4 equals
0, then x_AB2

28
00:01:39,970 --> 00:01:42,590
can be equal to either 0 or 1.

29
00:01:42,590 --> 00:01:45,430
So this constraint exactly
models the restriction

30
00:01:45,430 --> 00:01:47,610
we wanted.

31
00:01:47,610 --> 00:01:53,530
Lastly, suppose that teams C and
D must play in week 1 or 2 --

32
00:01:53,530 --> 00:01:56,960
they can't play both
games in weeks 3 and 4.

33
00:01:56,960 --> 00:02:04,130
We can model this constraint
with x_CD1 + x_CD2 greater than

34
00:02:04,130 --> 00:02:05,890
or equal to 1.

35
00:02:05,890 --> 00:02:09,539
Feasible solutions are
both variables equal to 1,

36
00:02:09,539 --> 00:02:12,340
or one variable equal to 1.

37
00:02:12,340 --> 00:02:15,820
Both variables can't equal 0.

38
00:02:15,820 --> 00:02:19,000
These are just a few examples
of logical constraints

39
00:02:19,000 --> 00:02:22,750
that we can implement
using binary variables.

40
00:02:22,750 --> 00:02:25,990
Let's go into LibreOffice
now and add these constraints

41
00:02:25,990 --> 00:02:28,030
to our model.

42
00:02:28,030 --> 00:02:30,210
In our spreadsheet,
let's scroll down

43
00:02:30,210 --> 00:02:33,410
to the bottom of our
constraints list.

44
00:02:33,410 --> 00:02:36,180
We wand to add in
three new constraints.

45
00:02:36,180 --> 00:02:42,010
The first is that teams A and
B can't play in both weeks

46
00:02:42,010 --> 00:02:44,870
3 and 4.

47
00:02:44,870 --> 00:02:50,020
The second is that if teams
A and B play in week 4,

48
00:02:50,020 --> 00:02:52,970
then they have to
play in week 2.

49
00:02:52,970 --> 00:02:55,860
And the third is
that team C and D

50
00:02:55,860 --> 00:03:01,420
have to play in
weeks 1 and/or 2.

51
00:03:01,420 --> 00:03:05,080
So, to add the first
constraint, our left hand side

52
00:03:05,080 --> 00:03:09,510
should be equal to the sum
of the variables for A and B

53
00:03:09,510 --> 00:03:14,050
in weeks 3 and 4.

54
00:03:14,050 --> 00:03:16,880
Our sign is less
than or equal to

55
00:03:16,880 --> 00:03:20,110
and our right hand side is 1.

56
00:03:20,110 --> 00:03:23,110
Our second constraint,
the left hand side,

57
00:03:23,110 --> 00:03:26,920
is equal to the decision
variable for teams A and B

58
00:03:26,920 --> 00:03:29,210
in week 2.

59
00:03:29,210 --> 00:03:32,100
The sign is greater
than or equal to,

60
00:03:32,100 --> 00:03:35,410
and the right hand side is
equal to the decision variable

61
00:03:35,410 --> 00:03:39,410
for teams A and B in week 4.

62
00:03:39,410 --> 00:03:42,240
For our third constraint,
the left hand side

63
00:03:42,240 --> 00:03:46,190
is equal to the decision
variables for teams C and D

64
00:03:46,190 --> 00:03:52,130
in weeks 1 and 2, the sign
is greater than or equal to,

65
00:03:52,130 --> 00:03:54,230
and the right hand side is 1.

66
00:03:57,160 --> 00:04:00,740
We can see here that our current
optimal solution violates

67
00:04:00,740 --> 00:04:03,410
every single one of
these constraints.

68
00:04:03,410 --> 00:04:05,470
So, let's go ahead
and resolve our model

69
00:04:05,470 --> 00:04:07,260
to get a new solution.

70
00:04:07,260 --> 00:04:11,810
So go to the Tools
menu and select Solver.

71
00:04:11,810 --> 00:04:14,520
Now, let's add in
our new constraints.

72
00:04:14,520 --> 00:04:17,230
So in the third
cell reference box,

73
00:04:17,230 --> 00:04:18,890
go ahead and select
the left hand side

74
00:04:18,890 --> 00:04:20,720
for the first constraint.

75
00:04:20,720 --> 00:04:23,510
Make sure the operator
is less than or equal to,

76
00:04:23,510 --> 00:04:26,740
and select the right
hand side for the value.

77
00:04:26,740 --> 00:04:29,050
Then in the fourth
cell reference box,

78
00:04:29,050 --> 00:04:32,310
select both of the left hand
sides for the other constraints

79
00:04:32,310 --> 00:04:35,340
because they're both greater
than or equal to constraints,

80
00:04:35,340 --> 00:04:38,100
change the operator to
greater than or equal to,

81
00:04:38,100 --> 00:04:41,670
and for the value select
the two right hand sides.

82
00:04:41,670 --> 00:04:44,490
And go ahead and click Solve.

83
00:04:44,490 --> 00:04:47,470
The solving result says
"Solving successfully finished.

84
00:04:47,470 --> 00:04:48,810
Result 20."

85
00:04:48,810 --> 00:04:51,370
Select Keep Result.

86
00:04:51,370 --> 00:04:53,920
Let's look at our new solution.

87
00:04:53,920 --> 00:04:56,580
The objective value
is now 20 which

88
00:04:56,580 --> 00:04:58,950
is less than it was before.

89
00:04:58,950 --> 00:05:03,200
But now we have teams A and
B playing in weeks 2 and 4

90
00:05:03,200 --> 00:05:06,960
and teams C and D
playing in weeks 2 and 4.

91
00:05:06,960 --> 00:05:08,540
So, depending on
your preferences

92
00:05:08,540 --> 00:05:12,610
as a decision-maker, you might
prefer the previous solution

93
00:05:12,610 --> 00:05:15,920
which had a slightly higher
objective or this solution

94
00:05:15,920 --> 00:05:18,350
which is a little more balanced.

95
00:05:18,350 --> 00:05:22,260
In the next video, we'll discuss
how additional constraints

96
00:05:22,260 --> 00:05:24,870
often make the problems
harder to solve

97
00:05:24,870 --> 00:05:26,830
and how large
integer optimization

98
00:05:26,830 --> 00:05:29,680
problems are solved in practice.