Integer Programming
Integer Programming
053/8
Take some more tea, the March Hare said to Alice, very earnestly. Ive had nothing yet, Alice replied in an offended tone, so I cant take more.
You mean you cant take less, said the Hatter. Its very easy to take more than nothing. -- Lewis Carroll in Alice in Wonderland
2
Integer programming
INPUT: a set of variables x1, , xn and a set of linear inequalities and equalities, and a subset of variables that is required to be integer. FEASIBLE SOLUTION: a solution x that satisfies all of the inequalities and equalities as well as the integrality requirements. OBJECTIVE: maximize i ci xi maximize subject to 3x + 4y 5x + 8y 24 x, y 0 and integer
3
Example:
Overview of Lecture
Some modeling tricks and techniques with integer programming Logical constraints
Rule of thumb: integer programming can model any of the variables and constraints that you really want to put into an LP, but cant. More realistic More flexibility
Disadvantages
Some very large IPs can be solved e.g., 50,000 columns 2 million non-zeros
Very unpredictable!
Running Running time for solving IPs (CPLEX) using CPLEX time to optimality
1,000,000
< 1 Hour
> 1 hour
number of columns
100,000
10,000
number of rows
0 xj 1 and xj integer.
8
Nooz has just won 14 IHTFP points. We now join the quiz show to see what the 14 points are worth.
iPad 5 points
7points points 7
4 points
15.053 6 points
10
5 points
16 utils
7 points
22 utils
4 points 12 utils
3 points 8 utils
6.041
15.053
Nooz determines what each prize is worth to him. He measure everything in utils on a scale from 1 to 25.
4 points 11 utils
6 points 19 utils
11
1 5 16
2 7 22
3 4 12
4 3 8
5 4 11
6 6 19
1 Let x i 0
13
You have n items to choose from to put into your knapsack. Item i has weight wi, and it has value ci. The maximum weight your knapsack (or you) can hold is b. Formulate the knapsack problem.
14
e.g. y1 7 or y2 9 or both.
e.g., f(y3) = 0 if y3 = 0, and it is 10 + 5 y3 if y3 > 0.
15
The feasible region for our problem and for the integer program is the same. Sometimes, we need to create new variables in order to make this happen.
16
Logical Constraints 1
Constraint 1. If you select the iPad, you cannot select 6.041 x1 = 1 if iPad x5 = 1 if 6.041 x1 x5
MIP Constraint:
x1 + x5 1
17
2x1 + 2x5 3 x1 + x5 1 x1 + x5 1
Either A or B?
Logical Constraints 2
Constraint 2. If Prize 1 is selected then Prize 2 must be selected. x1 = 1 if iPad x2 = 1 if server x2
x1
MIP Constraint:
x1 x 2
19
x1 x2 x1 x2
B.
C.
(1 x1) + x2 1
D.
Either A or C?
Logical Constraints 3
x2 x1 = 1 if iPad x2 = 1 if server Constraint 3. You must select Prize 1 or Prize 2 or both MIP Constraint:
x1 + x2 1
21
5
4 3 2
y1, y2 integer.
How can we model:
1 0 0 1 2 3 4 5 y1
22
y1 3 or y2 4 or both
A. B.
It cant be done. Of course it can be done, and we shall soon see how.
Typically, we create an IP such that the set of feasible solutions for the IP is the same as the set of feasible solutions for the original problem.
25
y1 3 or y2 4 or both
0 y1 5 0 y2 5 5 4 3 y2
y1 3 3w
y2 4 4 (1-w). y1, y2 integer. w {0, 1}.
2
1
Note: if w = 0, then
y1 3 y2 0.
y1
26
y1 3 or y2 4 or both
0 y1 5 0 y2 5 y2
5
4 3 2 1 0 5 0 1 2 3 4 The feasible set if w = 1. y1
27
y1 3 3w
y2 4 4 (1-w). y1, y2 integer. w {0, 1}.
Note: If w = 1, then
y1 0 y2 4.
y1 3 or y2 4 or both
0 y1 5 0 y2 5 y2
5
4 3 2 1 0 0 1 2 3 4 5 y1
28
y1, y2 integer.
y1 3 3w y2 4 4 (1-w). w {0, 1}. The set of y1 and y2 that are feasible for some choice of w.
y1 3 or y2 4 or both.
If w = 1, then
w {0, 1}.
If w = 0, then
y1 -997
y2 4.
redundant constraint
y1 3
y2 -453 redundant constraint
29
y1 30 30w
y2 45 45(1-w). w {0, 1}.
y1, y2 integer.
Model:
Also valid:
y1 30 or y2 45 or both
y1 30 1000w
y2 45 500(1-w). w {0, 1}.
30
y1, y2 integer.
Model:
y1 60 or y2 75 or both
31
0 y1 1000
0 y2 2000 y1 60
0 y1 60 0 y2 2000
y2 2075
If w = 1, then 0 y1 1000 0 y2 2000 y1 1060 y2 75
32
y1 60 + 1000w
y2 75 + 2000(1-w). w {0, 1}.
0 y1 1000 0 y2 75
y1 200 - Mw
y2 125 + M(1-w).
w {0, 1}.
33
Modeling
x1 + 2x2 12 or 4x2 10x3 1.
Logical constraints.
Suppose that xi is bounded for all i.
or constraints
x1 + 2x2 12 M(1-w) 4x2 10x3 1 + Mw.
IP constraints. Suppose that M is very large.
To show: The logical constraints are equivalent to the IP constraints. Suppose that (x, w) is feasible, for the IP. If w = 1, then x1 + 2x2 12
x1 + 2x2
12
4x2 10x3 1.
the other constraint is redundant
There are often multiple ways of modeling the same integer program.
Solvers for integer programs are extremely sensitive to the formulation. (not true for LPs)
36