Professional Documents
Culture Documents
CO 250: Introduction To Optimization: Module 1: Formulations (IP Models)
CO 250: Introduction To Optimization: Module 1: Formulations (IP Models)
University
c of Waterloo 1 / 22
Recap: WaterTech
University
c of Waterloo 2 / 22
• Yes! max x1 + x2 + 2x4
s.t. x1 + x2 ≤ 1
An integer program is a linear
program with added integrality − x2 − x3 ≥ −1
constraints for some/all of the x1 + x3 = 1
variables. x1 , x2 , x3 ≥ 0
• We call an IP mixed if there are x1 , x3 integer.
integer and fractional variables,
and pure otherwise.
University
c of Waterloo 3 / 22
Can We Solve IPs?
University
c of Waterloo 4 / 22
Can We Solve IPs?
University
c of Waterloo 5 / 22
IP Models: Knapsack
University
c of Waterloo 6 / 22
KitchTech Shipping
Type 1 2 3 4 5 6
weight (lbs) 30 20 30 90 30 70
value ($) 60 70 40 70 20 90
• The total weight of crates shipped must not exceed 10,000 lbs.
University
c of Waterloo 7 / 22
IP Model
University
c of Waterloo 8 / 22
IP Model
University
c of Waterloo 9 / 22
KitchTech: Added Conditions
University
c of Waterloo 10 / 22
KitchTech: Added Conditions
Correctness:
max 60x1 + 70x2 + 40x3 +
• x4 ≥ 1 −→ new
constraint is redundant! 70x4 + 20x5 + 90x6
s.t. 30x1 + 20x2 + 30x3 +
• x4 = 0 −→ new
90x4 + 30x5 + 70x6 ≤ 10000
constraint becomes
x3 ≤ 10x4
x3 ≤ 0. 0 ≤ xi ≤ 10 (i ∈ [6])
xi integer (i ∈ [6])
University
c of Waterloo 11 / 22
KitchTech: One More Tricky Case
2. y = 0 −→ x5 + x6 ≥ 4.
Force y to take on the value
0 or 1.
University
c of Waterloo 12 / 22
KitchTech: One More Tricky Case
University
c of Waterloo 13 / 22
Binary Variables
University
c of Waterloo 14 / 22
IP Models: Scheduling
University
c of Waterloo 15 / 22
• The neighbourhood coffee shop
is open on workdays.
University
c of Waterloo 16 / 22
1. Variables: What do we need to decide on?
→ introduce variable xd for every d ∈ {M, T, W, T h, F } counting
the number of people to hire with starting day d.
min xM + xT + xW + xT h + xF .
xM + xW + xT h + xF .
University
c of Waterloo 17 / 22
Constraints
Monday: xM + xW + xT h + xF ≥ 3
Tuesday: xM + xT + xT h + xF ≥ 5
Wednesday: xM + xT + xW + xF ≥ 9
Thursday: xM + xT + xW + xT ≥ 2
Friday: xT + xW + xT h + xF ≥ 7
University
c of Waterloo 18 / 22
Scheduling LP
min xM + xT + xW + xT h + xF
s.t. xM + xW + xT h + xF ≥ 3
xM + xT + xT h + xF ≥ 5
xM + xT + xW + xF ≥ 9
xM + xT + xW + xT ≥ 2
xT + xW + xT h + xF ≥ 7
x ≥ 0, x integer
University
c of Waterloo 19 / 22
Quiz
Question
We are given an integer program with integer variables x1 , . . . , x6 . Let
• Add binary variables y127 , y289 , y1310 , y2754 , one for each i ∈ S.
University
c of Waterloo 20 / 22
Quiz
University
c of Waterloo 21 / 22
IP Models
Recap
• An integer program is obtained by adding integrality constraints for
some/all of the variables to an LP.
University
c of Waterloo 22 / 22