Integer Programming Models: Input
Integer Programming Models: Input
053
Introduction
Integer programming
Example: maximize 3x + 4y
subject to 5x + 8y ≤ 24
x, y ≥ 0 and integer
2
Why integer programs?
– More realistic
– More flexibility
l Disadvantages
– More difficult to model
– Can be much more difficult to solve
l Very unpredictable!
4
Running Running
time for solving
time IPs (CPLEX)
to optimality using CPLEX
< 1 Hour > 1 hour Not yet solved
1,000,000
number of columns
100,000
10,000
6
The Knapsack Problem
Show a picture of
Nooz.
8
optimizatio
n software
5 points 7 points 4 points
MIT water
fountain Probability 15.053
optimizatio
n software
MIT water
fountain Probability 15.053
Points 5 7 4 3 4 6
Utility 16 22 12 8 11 19
1 if prize i is selected
Let x i =
0 otherwise
11
12
Knapsack or Capital Budgeting
xi ∈{0,1} for i = 1 to n. 13
Examples:
l If you select Prize 1, you cannot select Prize 5.
l If Prize 1 is selected then Prize 2 must be selected.
l You must select Prize 1 or Prize 2 or both
l e.g. y1 ≤ 7 or y2 ≤ 9 or both.
l e.g., f(y3) = 0 if y3 = 0, and it is 10 + 5 y3 if y3 > 0.
14
On formulating integer programs
Examples:
l If you select Prize 1, you cannot select Prize 5.
l If Prize 1 is selected then Prize 2 must be selected.
l You must select Prize 1 or Prize 2 or both
l e.g. y1 ≤ 7 or y2 ≤ 9 or both.
l e.g., f(y3) = 0 if y3 = 0, and it is 10 + 5 y3 if y3 > 0.
15
16
Formulating logical constraints
(restricted to binary variables)
17
If-then constraints
(1) If you select Prize 1, you must select Prize 3.
⎧⎪ 1 if prize i is selected
xi = ⎨
⎩⎪ 0 if prize i is not selected
x5
x3 = 1 x3 = 0
x1 = 1 T F
x1 = 0 T T
x1
MIP Constraint:
x 1 + x5 ≤ 1
18
If-then constraints
⎧⎪ 1 if prize i is selected
xi = ⎨
⎪⎩ 0 if prize i is not selected
x3 = 1 x3 = 0
x1 = 1 T F
x1 = 0 T T
If-then constraints
⎧⎪ 1 if prize i is selected
xi = ⎨
⎪⎩ 0 if prize i is not selected
x3
1 x1 - x3 ≤ 0
0 x1
0 1 20
If-then constraints
⎧⎪ 1 if prize i is selected
xi = ⎨
⎪⎩ 0 if prize i is not selected
x3
1 x1 + x5 ≤ 1
0 x1
0 1 21
1 x1 - x2 = 0
0 x1
0 1 22
“Or” constraints
⎧⎪ 1 if prize i is selected
xi = ⎨
⎪⎩ 0 if prize i is not selected
x3
1 x1 + x5 ≥ 1
0 x2
0 1 23
x3
1 x1 + x5 = 1
0 x2
0 1 24
How to guarantee a constraint is
redundant: intro to big M method
25
On redundant constraints
A constraint is redundant if deleting the constraint
does not change the feasible region.
Suppose that
0 ≤ y1 ≤ 3
y2
0 ≤ y2 ≤ 4
4
y1 + y2 ≤ 6 not redundant
3
y1 + y2 ≤ 7 redundant
2
y1 + y2 ≤ M redundant for all M ≥ 7.
1
0 y1
0 1 2 3 26
On redundant constraints and “big M”
Suppose that
0 ≤ y1 ≤ 3 y1 - 2y2 ≤ 3
0 ≤ y2 ≤ 4
y2 not redundant
(y1 = 4, y2 = 0 is infeasible.)
4 y1 - 2y2 ≤ 4
3 redundant
2 y1 - 2y2 ≤ M
0 y1
0 1 2 3 27
Suppose that a y 1 + b y2 ≤ M
0 ≤ y1 ≤ 3
0 ≤ y2 ≤ 4
y2 a y1 + b y2 ≥ -M
0 y1
0 1 2 3 29
30
Modeling “or” constraints for
mixed integer linear programming.
31
3
How can we model:
2
“y1 ≥ 3 or y2 ≥ 4 or both”
1
0 y1
0 1 2 3 4 5
The feasible region is not convex. It will not be the
feasible region of any LP. 32
Technique: add a binary variable w
if w = 0, then y1 ≥ 3
if w = 1, then y2 ≥ 4.
33
y1 ≥ 3w 4
y2 ≥ 4w 3
With these 1
constraints, y1 is
always ≥ 3. 0 y1
0 1 2 3 4 5
34
Making it work
if w = 0, then y1 ≥ 3 y2
if w = 1, then y2 ≥ 4.
5
y1 ≥ 3(1-w) 4
y2 ≥ 4w 3
0 y1
0 1 2 3 4 5
35
Case 1: w = 0
if w = 0, then y1 ≥ 3 y2
if w = 1, then y2 ≥ 4.
5
y1 ≥ 3(1-w) 4
y2 ≥ 4w 3
w=0
2
y1 ≥ 3 1
y2 ≥ 0
0 y1
w=0 0 1 2 3 4 5
36
Case 2: w = 1
if w = 0, then y1 ≥ 3 y2
if w = 1, then y2 ≥ 4.
5
y1 ≥ 3(1-w) 4
y2 ≥ 4w 3
w=1
2
y1 ≥ 0 redundant 1
y2 ≥ 4
0 y1
w=0 0 1 2 3 4 5
37
y1 ≥ 3(1-w) 4
y2 ≥ 4w 3
Either w = 0 1
Or w=1 0 y1
0 1 2 3 4 5
38
Modeling “or” constraints using
the big M method
39
40
Bounded variables
Example 2: The variables are x1, x2, x3, and
2x1 + 5 x2 + 10 x3 ≤ 20 (1)
xj ≥ 0 for j = 1, 2, 3 (2)
(1) and (2) imply that x1 ≤ 10, x2 ≤ 4, x3 ≤ 2.
x1 + 2x2 ≥ 12 (1)
or Logical constraints.
4x2 – 10x3 ≤ 1. (2)
x1 + 2x2 ≥ 12 – M(1-w)
IP constraints.
4x2 – 10x3 ≤ 1 + Mw.
43
44
Modeling “or constraints”.
Assume that x1, x2, and x3 are all bounded.
If w1 = 1, then x1 ≥ 12
If w2 = 1, then x2 ≤ 8
If w3 = 1, then -x1 + x3 ≥ 4
If x1 ≤ 12, then x2 + 5 x3 ≤ 25
is logically equivalent to
x1 > 12 or x2 + 5 x3 ≤ 25 x1 ≥ 13 - M(1-w4)
x2 + 5 x3 ≤ 25 + Mw4
and also equivalent to
w4 ∈ {0,1}
x1 ≥ 13 or x2 + 5 x3 ≤ 25 Integer program
If w4 = 1, then x2 + 5 x3 ≤ 25.