15.
053/8
February 27, 2014
Introduction to Integer Programming
Integer programming models
Quotes of the Day
Somebody who thinks logically is a nice contrast to the real world. -- The Law of Thumb
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
Integer programs vs linear programs
Some modeling tricks and techniques with integer programming Logical constraints
Why integer programs?
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
More difficult to model
Can be much more difficult to solve
5
On computation for IPs
Much, much harder than solving LPs
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
Not yet solved
number of columns
100,000
10,000
Instances are taken from MIP Lib
1,000 1,000
10,000 100,000 1,000,000
7
number of rows
Types of Integer Programs
Mixed integer linear programs (MILPs or MIPs)
xj 0 and integer for some or all j.
Pure Integer Programs
xj 0 and integer for every j.
0-1 (binary) Integer Programs
xj {0,1} for every j.
0 xj 1 and xj integer.
8
Trading for Profit
Nooz is a contestant on Trading for Profits. Its main slogan is
Trading for Profit
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
6.041 3 points 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
Prize Points Utility
1 5 16
2 7 22
3 4 12
4 3 8
5 4 11
6 6 19
Budget: 14 IHTFP points. Write Noozs problem as an integer program.
1 Let x i 0
if prize i is selected otherwise
12
Integer Programming Formulation
Objective and Constraints? Max 16x1+ 22x2+ 12x3+ 8x4+ 11x5+ 19x6 5x1+ 7x2+ 4x3+ 3x4+ 4x5+ 6x6 14
xj {0,1} for each j = 1 to 6
13
Knapsack or Capital Budgeting
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
On formulating integer programs
We often have constraints and objectives that are not expressed as linear constraints plus integrality constraints. (That is, it is not currently an IP) Examples:
If you select the iPad, you cannot select 6.041
If Prize 1 is selected then Prize 2 must be selected. You must select Prize 1 or Prize 2 or both
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
On formulating integer programs
We can figure out what is feasible and what is not feasible. When we form the integer program (IP), we want the following:
1. 2.
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
Which of the following is equivalent to the constraint: if x1 = 1, then x5 = 0?
A. B. C. D.
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
Which of the following is equivalent to the constraint: x1 = 0 or x2 = 1 (or both)?
A.
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
Logical constraints and the big M method
Constraint 4. Suppose that y1 and y2 are integer variables. 0 y1 5 0 y2 5 y2
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
Can we do it be adding linear constraints to this diagram?
How can we model 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.
On taking a problem and creating and verifying an IP formulation.
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.
Verification: often done in two steps.
Step 1. If a solution is feasible for the original problem, it is also feasible for the IP. Step 2. If a solution is feasible for the IP, then it is also feasible for the original problem.
24
On modeling using integer programming
The techniques look odd at first.
Similar techniques can be used for lots of different types of constraints.
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.
5 0 1 2 3 4 The feasible set if w = 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.
One can choose larger coefficients for w and 1-w.
The following is also a valid formulation of 0 y1 5 0 y2 5 0 y1 5 0 y2 5 y1 3 1000w y2 4 457(1-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
Generalizing to other or constraints
Constraint. Suppose that y1 and y2 are integer variables. 0 y1 1000 0 y2 2000 Create a new binary variable w.
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
Generalizing to other or constraints
Constraint. Suppose that y1 and y2 are integer variables. 0 y1 1000 0 y2 2000 Create a new binary variable w. y1 60 + 1000w y2 75 + 2000(1-w). w {0, 1}.
y1, y2 integer.
Model:
y1 60 or y2 75 or both
31
If w = 0, then 0 y1 1000 0 y2 2000 y1, y2 integer.
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
The big M method: an effective, but lazy approach to modeling or constraints.
Constraint. Suppose that y1 and y2 are integer variables and that y1 and y2 are bounded from above (by 1,000 or 10,000 or something.)
Create a new binary variable w. Choose a very large integer M.
Model: y1 200 or y2 125 or both
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
If w = 0, then 4x2 10x3 1 Therefore, the logical constraints are satisfied.
x1 + 2x2 12 or 4x2 10x3 1.
Logical constraints. Suppose that xi is bounded for all i.
x1 + 2x2 12 M(1-w) 4x2 10x3 1 + Mw.
IP constraints. Suppose that M is very large.
Suppose that x satisfies the logical constraints.
If x1 + 2x2 12, then let w = 1
Else 4x2 10x3 1 then let w = 0
x1 + 2x2
12
the other constraint is redundant
4x2 10x3 1.
the other constraint is redundant
In both cases, the IP constraints are satisfied.
Some Comments on IP models
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)
Next lecture: More IP models.
36