07 Integer Programming I
07 Integer Programming I
07 Integer Programming I
Business
Lecturer
Mario Guajardo
[email protected]
2
Outline Lecture 7
Integer linear programming and
Mixed integer linear programming
- Fixed cost problem
- Knapsack problem
- Facility location problem
- Assignment problem
Literature
- Chapter 20: “Integer linear programs” in AMPL book.
- Chapter 13: “Integer programming models” in Optimization textbook.
3
Integer programming
An integer programming (IP) problem is a
problem where one or several variables are
restricted to integer values or, more
precisely, to discrete values (countable set).
xj ∈ {0,1,2,3,4}
1 2 3 Note by defining yj = 4xj, the new
xj ∈ 0, , , , 1
4 4 4 variable yj can only take integer values
Example
Max z = x1 + x2
s.t. 11x1 - 8x2 ≤ 22
11x1 - 12x2 ≥ 0
x1, x2 ≥ 0, integer
5
Feasible set: Max z = x1 + x2
{(0,0);(1,0);(2,0);(2,1);(3,2);(4,3)}
s.t. 11x1 - 8x2 ≤ 22
11x1 - 12x2 ≥ 0
x1, x2 ≥ 0, integer
Optimal solution:
x1* = 4
x2* = 3
6
LP relaxation
If we remove the integer requirements on
the variables, we get a linear programming
problem which is called the LP relaxation of
the integer programming problem.
Max z = x1 + x2
Keep the same O.F.
s.t. 11x1 - 8x2 ≤ 22 and constraints
11x1 - 12x2 ≥ 0
Replace integer for
x 1, x 2 ≥ 0 continuous condition
(Of course, the integer points that were
feasible in the IP are also contained in the
feasible region of this relaxed problem)
7
The feasible region of the LP
Max z = x1 + x2
relaxation is delimited by the s.t. 11x1 - 8x2 ≤ 22
triangle in this figure
Optimal solution of the LP 11x1 - 12x2 ≥ 0
relaxation: x 1, x 2 ≥ 0
x1* = 6; x2* = 5.5
z* = 11.5
Optimal solution of the IP:
x1* = 4
x2* = 3
8
IP and LP relaxation
In the LP relaxation all variables may take
fractional values, while the IP requires only integer
values.
The objective function of the LP is continuous,
while the one of the IP, in general, is not.
The feasible region of the LP behaves more
smoothly (it is convex), while the feasible area of
the IP is a set of discrete points (non-convex).
The optimal solution to an LP can always be found
in a corner point of the feasible area (intersection
of constraint lines), while the solution to the IP will
rarely lie in a corner. 9
IP solution
It is harder to solve an integer linear model than a
continuous linear model.
Rounding the solution of the LP relaxation to the
closest integer might be reasonable only in some
(few) cases. In general, the rounded solution may
not even be feasible.
10
Optimal solution of the LP
relaxation:
Max z = x1 + x2
x1* = 6; x2* = 5.5
s.t. 11x1 - 8x2 ≤ 22
11x1 - 12x2 ≥ 0
x 1, x 2 ≥ 0
13
Why studying integer models?
Two main reasons.
1) Variables are “naturally” integer, then it is
not reasonable to get a solution by rounding
the solution to the LP relaxation.
If x is a variable to decide the kg of apples to
transport from supply to demand point, and the
optimal solution to the LP relaxation is 1530.2, it
sounds reasonable to round this to x = 1530.
If y is a variable to decide the number of certain type
of machines to use in a refinery and the optimal
solution to the LP relaxation is y = 2.7, it is perhaps
less reasonable to round this solution. 14
Why studying integer models?
Two main reasons.
1) Variables are “naturally” integer, then it is
not reasonable to get a solution by rounding
the solution to the LP relaxation.
If x is a variable to decide how much to deposit in a
bank account and the optimal solution to the LP
relaxation is 1,500,000.25 NOK, it sounds
reasonable to round this to x = 1,500,000 NOK.
If y is a variable to decide whether to implement a
project or not (not possible to implement a fraction of
the project) and the optimal solution to the LP
relaxation is 0.4, it is less reasonable to round. 15
Why studying integer models?
Two main reasons.
2) Binary 0/1 variables help to improve the
model ability.
Modelling fixed cost.
Modelling Yes/No decisions.
Logical restrictions.
e.g. if A happens, then B cannot happen and vice
versa. xA + xB ≤ 1
When only a discrete set of values is allowed.
e.g. if w can only take one of the values 0, 4, 7 or 10 can be modelled as
w = 4x + 7y + 10z, where x + y + z ≤ 1 and x, y, z ∈{0,1} 16
Solving IP models
AMPL coding
Syntax remains the same as for continuous
problems, except for definition of variables:
18
Fixed cost
f + cx if x > 0
Total cost
Total cost =
0 if x = 0
f + cx
f
25
Constraints
• Targets of pollutant reduction must be satisfied
30
Knapsack problem
J : set of objects
cj : benefit added by object j if it is chosen
aj : weight of object j (amount of resource it uses)
b : maximum weight (or resource available)
Decision variables
For each object j we define a binary variable:
1 if item j is chosen
xj =
0 otherwise
31
Knapsack problem
Objective function
Maximize total benefit
� 𝑎𝑎𝑗𝑗 𝑥𝑥𝑗𝑗 ≤ 𝑏𝑏
𝑗𝑗∈𝐽𝐽
Decision variables
For each object j we define a binary variable:
1 if item j is chosen
xj =
0 otherwise
33
Knapsack with multiple resources
Objective function
Maximize total benefit
𝑥𝑥𝑗𝑗 ∈ 0,1 𝑗𝑗 = 1, … , 4
42
43
Mixed integer linear
programming model
45
Facility location problem: extension (p.333)
47
Assignment problem
1 if object i ∈ I is assigned object j ∈ J
xij =
0 otherwise
� 𝑥𝑥𝑖𝑖𝑖𝑖 = 1 ∀ 𝑖𝑖 ∈ 𝐼𝐼
𝑗𝑗∈𝐽𝐽
� 𝑥𝑥𝑖𝑖𝑖𝑖 = 1 ∀ 𝑗𝑗 ∈ 𝐽𝐽
𝑖𝑖∈𝐼𝐼
50