Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 1/34
C&O 370: Deterministic OR Models
Integer Programming – Modeling
Jochen Könemannhttp://www.math.uwaterloo.ca/∼jochen
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
Facility Location
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 2/34
What is an IP?
■ Linear programming allows for fractional values in solutions.Fractional values are not meaningful in many applications!
■ Sometimes, we are lucky and an LP model has integral basicfeasible solutions. But this is certainly not always the case.
■ A pure integer program looks like this
max cT x
s.t. Ax ≤ b
x ≥ 0
x integer
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
Facility Location
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 3/34
Visualization
■ The important difference to linear programming is that thesolution space is not any more convex:
max 3x1 + 2x2
s.t. x1 + 2x2 ≤ 6
x1, x2 ≥ 0
● What is an IP?
● Visualization
Stockco Investing
● Stockco: Investment Example
● Two out of Four
● Implications
● Exclusions
Fixed Charge Problems
Facility Location
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 4/34
Stockco Investing
● What is an IP?
● Visualization
Stockco Investing
● Stockco: Investment Example
● Two out of Four
● Implications
● Exclusions
Fixed Charge Problems
Facility Location
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 5/34
Stockco: Investment Example
■ Stockco is considering 4 investments:
Investment NPV Initial Cash Outflow
1 $16,000 $5,0002 $22,000 $7,0003 $12,000 $4,0004 $8,000 $3,000
■ Stockco has $14, 000 in cash available■ Want to maximize total NPV given available cash
● What is an IP?
● Visualization
Stockco Investing
● Stockco: Investment Example
● Two out of Four
● Implications
● Exclusions
Fixed Charge Problems
Facility Location
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 6/34
Stockco: Investment Example
■ Variable xi ∈ {0, 1} has value 1 if we invest in investmentoption i and 0 otherwise
■ Total NPV obtained by Stockco:
$16000x1 + $22000x2 + $12000x3 + $8000x4
■ Total amount invested
$5000x1 + $7000x2 + $4000x3 + $3000x4
and this needs to be at most $14000.
● What is an IP?
● Visualization
Stockco Investing
● Stockco: Investment Example
● Two out of Four
● Implications
● Exclusions
Fixed Charge Problems
Facility Location
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 7/34
Stockco: Investment Example
■ {0, 1}-IP model looks like:
max 16x1 + 22x2 + 12x3 + 8x4
s.t. 5x1 + 7x2 + 4x3 + 3x4 ≤ 14
x1, x2, x3, x4 ∈ {0, 1}
● What is an IP?
● Visualization
Stockco Investing
● Stockco: Investment Example
● Two out of Four
● Implications
● Exclusions
Fixed Charge Problems
Facility Location
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 8/34
Two out of Four
■ Stockco can invest in at most two of the four investmentoptions.
How do you model that?■ This is enforced by the constraint
x1 + x2 + x3 + x4 ≤ 2.
Remember: The xi are 0, 1-variables! All positive variableshave value 1. There can be at most two of those.
● What is an IP?
● Visualization
Stockco Investing
● Stockco: Investment Example
● Two out of Four
● Implications
● Exclusions
Fixed Charge Problems
Facility Location
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 9/34
Two out of Four
■ {0, 1}-IP model looks like:
max 16x1 + 22x2 + 12x3 + 8x4
s.t. 5x1 + 7x2 + 4x3 + 3x4 ≤ 14
x1 + x2 + x3 + x4 ≤ 2
x1, x2, x3, x4 ∈ {0, 1}
● What is an IP?
● Visualization
Stockco Investing
● Stockco: Investment Example
● Two out of Four
● Implications
● Exclusions
Fixed Charge Problems
Facility Location
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 10/34
Implications
■ If Stockco invests into investment option 2 they must alsoinvest in investment option 1?
■ How do we model this using linear constraints?■ Claim: The constraint
x2 ≤ x1
forces x1 = 1 whenever x2 = 1.■ Proof: x2 = 1 implies x1 must be at least 1. Since
x1 ∈ {0, 1} this means that x1 must take on value 1.
● What is an IP?
● Visualization
Stockco Investing
● Stockco: Investment Example
● Two out of Four
● Implications
● Exclusions
Fixed Charge Problems
Facility Location
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 11/34
Implications
■ {0, 1}-IP model looks like:
max 16x1 + 22x2 + 12x3 + 8x4
s.t. 5x1 + 7x2 + 4x3 + 3x4 ≤ 14
x1 + x2 + x3 + x4 ≤ 2
x2 ≤ x1
x1, x2, x3, x4 ∈ {0, 1}
● What is an IP?
● Visualization
Stockco Investing
● Stockco: Investment Example
● Two out of Four
● Implications
● Exclusions
Fixed Charge Problems
Facility Location
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 12/34
Exclusions
■ If Stockco invests into investment option 2 they cannot investin investment option 4?
■ How do we model this using linear constraints?■ Claim: The constraint
x2 + x4 ≤ 1
forces x4 = 0 whenever x2 = 1.■ Proof: x2 = 1 implies x4 must be at most 0. Since
x4 ∈ {0, 1} this means that x4 must take on value 0.
● What is an IP?
● Visualization
Stockco Investing
● Stockco: Investment Example
● Two out of Four
● Implications
● Exclusions
Fixed Charge Problems
Facility Location
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 13/34
Exclusions
■ {0, 1}-IP model looks like:
max 16x1 + 22x2 + 12x3 + 8x4
s.t. 5x1 + 7x2 + 4x3 + 3x4 ≤ 14
x1 + x2 + x3 + x4 ≤ 2
x2 ≤ x1
x2 + x4 ≤ 1
x1, x2, x3, x4 ∈ {0, 1}
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
● Gandhi Cloth Company
● Resource constraints
● Fixed Charge
● Big-M Constraints
● Gandhi’s Profit
● IP Formulation
Facility Location
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 14/34
Fixed Charge Problems
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
● Gandhi Cloth Company
● Resource constraints
● Fixed Charge
● Big-M Constraints
● Gandhi’s Profit
● IP Formulation
Facility Location
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 15/34
Gandhi Cloth Company
■ Gandhi produces shirts, shorts, and pants.◆ Manufacturing each product requires renting a specific on
a weekly basis (fixed cost)◆ Producing a product uses resources labour and cloth◆ Producing a product incurs cost for labour and cloths
(variable cost)◆ Each product has a sales price
No Product Sales P. Fixed Var Labour(h) Cloth(m2)
1 Shirt 12 200 6 3 42 Shorts 8 150 4 2 33 Pants 15 100 8 6 4
■ Have 150h of labour and 160m2 of cloth available eachweek.
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
● Gandhi Cloth Company
● Resource constraints
● Fixed Charge
● Big-M Constraints
● Gandhi’s Profit
● IP Formulation
Facility Location
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 16/34
Resource constraints
■ Variables are no surprise: How much of each product isproduced?
x1, x2, x3 non-negative integers
■ Company has at most 150h of labour available each week:
3x1 + 2x2 + 6x3 ≤ 150
■ Also have 160m2 of cloth each week:
4x1 + 3x2 + 4x3 ≤ 160
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
● Gandhi Cloth Company
● Resource constraints
● Fixed Charge
● Big-M Constraints
● Gandhi’s Profit
● IP Formulation
Facility Location
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 17/34
Fixed Charge
■ The rental cost for production equipment for product i occursonly if we produce products of type i.It is independent of the produced quantity. This is called afixed charge.
■ Want to express the following:
We need to pay equipment rental for product i if we produceproduct i.
■ By implication: Introduce a new 0, 1-variable yi that hasvalue 1 if xi > 0.
■ Let M1, M2, M3 be large numbers:
xi ≤ Mi · yi
forces yi = 1 if xi > 0.
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
● Gandhi Cloth Company
● Resource constraints
● Fixed Charge
● Big-M Constraints
● Gandhi’s Profit
● IP Formulation
Facility Location
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 18/34
Fixed Charge
■ Let M1, M2, M3 be large numbers:
xi ≤ Mi · yi
forces yi = 1 if xi > 0.■ Constraints like this are often called big-M constraints.■ How do we choose Mi? Remember, yi is a 0, 1-variable.■ Need to have xi ≤ Mi in any feasible solution!■ Ex.: How many shirts can we produce per week at most?■ Gandhi has 150h of labour available each week. It takes 3h
of labour to produce a shirt: x1 is at most 50!
Can choose M1 = 50.
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
● Gandhi Cloth Company
● Resource constraints
● Fixed Charge
● Big-M Constraints
● Gandhi’s Profit
● IP Formulation
Facility Location
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 19/34
Big-M Constraints
■ Gandhi has 160 m2 of cloth available each week. It takes4m2 of cloths to produce a shirt: x1 is at most 40!
Can choose M1 = 40.■ A word of caution: Big-M constraints lead to week linear
programming relaxations.
Linear programming relaxations are used in IP solvers.
Choose Mi as small as possible!■ In the same way we derive that we can choose:
M1 = 40
M2 = 53
M3 = 25
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
● Gandhi Cloth Company
● Resource constraints
● Fixed Charge
● Big-M Constraints
● Gandhi’s Profit
● IP Formulation
Facility Location
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 20/34
Big- M Constraints
■ In summary, this leads to the following constraints:
x1 ≤ 40y1
x2 ≤ 53y2
x3 ≤ 25y3
■ What is the profit of Gandhi?■ Ex.: Shirts.
Consequences of producing x1 shirts:◆ Fixed cost of 200 for machine rental◆ Variable costs of 6 per shirt◆ Revenue from sales of 12 per shirt
■ Can you express Gandhi’s profit for shirts using x1 and y1?
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
● Gandhi Cloth Company
● Resource constraints
● Fixed Charge
● Big-M Constraints
● Gandhi’s Profit
● IP Formulation
Facility Location
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 21/34
Gandhi’s Profit
■ Ex.: Shirts.
Consequences of producing x1 shirts:◆ Fixed cost of 200 for machine rental◆ Variable costs of 6 per shirt◆ Revenue from sales of 12 per shirt
■ Can you express Gandhi’s profit for shirts using x1 and y1?■ Producing x1 shirts leads to profit
(12 − 6)x1 − 200y1 = 6x1 − 200y1
■ Similar for shorts and pants:
4x2 − 150y2
7x3 − 100y3
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
● Gandhi Cloth Company
● Resource constraints
● Fixed Charge
● Big-M Constraints
● Gandhi’s Profit
● IP Formulation
Facility Location
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 22/34
IP Formulation
max 6x1 + 4x2 + 7x3 − 200y1 − 150y2 − 100y3
s.t. 3x1 + 2x2 + 6x3 ≤ 150
4x1 + 3x2 + 4x3 ≤ 160
x1 ≤ 40y1
x2 ≤ 53y2
x3 ≤ 25y3
y1, y2, y3 ∈ {0, 1}
x1, x2, x3 ≥ 0 and integer.
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
Facility Location
● Introduction
● Reachability
● Enforce Reachability
● IP Formulation
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 23/34
Facility Location
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
Facility Location
● Introduction
● Reachability
● Enforce Reachability
● IP Formulation
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 24/34
Introduction
■ The county of Kilroy has 6 cities. We want to build firestations in some of these cities.
■ Objectives:◆ Each city should be reachable from a fire station within 15
minutes◆ It costs money to build fire stations! We therefore want to
build as few as possible.■ Distance-Map:
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
Facility Location
● Introduction
● Reachability
● Enforce Reachability
● IP Formulation
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 25/34
Reachability
■ Can reach city 1 only from cities 1 and 2 within 15 minutes.■ Cities and possible fire stations for them
City Fire Stations City Fire Stations
1 1,2 4 3,4,52 1,2,6 5 4,5,63 3,4 6 2,5,6
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
Facility Location
● Introduction
● Reachability
● Enforce Reachability
● IP Formulation
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 26/34
Enforce Reachability
City Fire Stations City Fire Stations
1 1,2 4 3,4,52 1,2,6 5 4,5,63 3,4 6 2,5,6
■ For each city i we need to have a fire station in a city that canreach i within 15 minutes. How can we do this with an IP?
■ Have a 0, 1-variable xi that is 1 if we build a fire station in cityi and 0 otherwise.
■ Reachability constraint for city 3:
x3 + x4 ≥ 1
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
Facility Location
● Introduction
● Reachability
● Enforce Reachability
● IP Formulation
Either-Or Constraints
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 27/34
IP Formulation
min x1 + x2 + x3 + x4 + x5 + x6
s.t. x1 + x2 ≥ 1
x1 + x2 + x6 ≥ 1
x3 + x4 ≥ 1
x3 + x4 + x5 ≥ 1
x4 + x5 + x6 ≥ 1
x2 + x5 + x6 ≥ 1
xi ∈ {0, 1} for all 1 ≤ i ≤ 6
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
Facility Location
Either-Or Constraints
● Introduction
● Logical Constraints
● Either or for Small Cars
● Either or for Other Types
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 28/34
Either-Or Constraints
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
Facility Location
Either-Or Constraints
● Introduction
● Logical Constraints
● Either or for Small Cars
● Either or for Other Types
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 29/34
Introduction
■ Dorian Auto manufactures three types of cars: compact,mid-size and large
■ Producing a car requires steel and labour and selling a caryields a certain profit:
Resource Compact Mid-size Large
Steel 1.5 tons 3 tons 5 tonsLabour 30h 25h 40h
Profit 2,000 3,000 4,000
■ Dorian has 6,000 tons of steel and 60,000h of labouravailable
■ For production of a type of car to be economically feasibleDorian needs to produce at least 1000 cars of that type.
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
Facility Location
Either-Or Constraints
● Introduction
● Logical Constraints
● Either or for Small Cars
● Either or for Other Types
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 30/34
Introduction
■ Almost looks like a standard production problem: variablesare xs, xm, xl for production levels of small, mid-size andlarge cars.
■ Dorian’s profit is
2, 000 · xs + 3, 000 · xm + 4, 000 · xl
■ Resource constraints are also straight-forward.
Steel: 1.5 · xs + 3 · xm + 5 · xl ≤ 6, 000
Labour: 30 · xs + 25 · xm + 40 · xl ≤ 60, 000
■ But then we also want either xj ≤ 0 or xj ≥ 1000 for allj ∈ {s, m, l}. How?
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
Facility Location
Either-Or Constraints
● Introduction
● Logical Constraints
● Either or for Small Cars
● Either or for Other Types
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 31/34
Logical Constraints
■ Sounds like a logical constraint... either I produce a certaintype of car or I don’t.
■ Once again, use 0, 1-variables! Introduce variable yj ∈ {0, 1}for all j ∈ {s, m, l}.
Let yj = 1 if Dorian produces cars of type j and 0 otherwise.■ Example: Small cars. How many small cars can Dorian
produce at most?■ Building a small car uses 1.5 tons of steel and 30 hours of
labour. Dorian has 6,000 tons of steel and 60,000h of labouravailable. Therefore:
1.5xs ≤ 6, 000 and
30 · xs ≤ 60, 000
Therefore xs ≤ min{4000, 2000}.
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
Facility Location
Either-Or Constraints
● Introduction
● Logical Constraints
● Either or for Small Cars
● Either or for Other Types
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 32/34
Either or for Small Cars
■ Building a small car uses 1.5 tons of steel and 30 hours oflabour. Dorian has 6,000 tons of steel and 60,000h of labouravailable. Therefore:
1.5xs ≤ 6, 000 and
30 · xs ≤ 60, 000
Therefore xs ≤ min{4000, 2000}.■ Choose Ms = 2000 and add constraint
xs ≤ Ms · ys
■ If Dorian produces small cars (ys = 1) then this constraint isalways satisfied!
■ If Dorian does not produce small cars (ys = 0) then alsoxs = 0 and the constraint holds as well.
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
Facility Location
Either-Or Constraints
● Introduction
● Logical Constraints
● Either or for Small Cars
● Either or for Other Types
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 33/34
Either or for Small Cars
■ Also want: If Dorian produces small cars (ys = 1) then atleast 1000 cars are produced.
■ One way of doing that is like this
xs ≥ 1, 000 · ys
■ This is trivially satisfied if Dorian does not manufacture smallcars and therefore ys = 0.
● What is an IP?
● Visualization
Stockco Investing
Fixed Charge Problems
Facility Location
Either-Or Constraints
● Introduction
● Logical Constraints
● Either or for Small Cars
● Either or for Other Types
Jochen Könemann, March 14, 2007 CO 370 – Deterministic Operations Research Models - p. 34/34
Either or for Other Types
■ We also get that Dorian produces at most 2,000 mid-sizeand at most 1,200 large cars.
■ Full production model looks like:
max 2, 000 · xs + 3, 000 · xm + 4, 000 · xl
s.t. 1.5 · xs + 3 · xm + 5 · xl ≤ 6, 000
30 · xs + 25 · xm + 40 · xl ≤ 60, 000
xs ≤ 2000 · ys
xs ≥ 1000 · ys
xm ≤ 2000 · ym
xm ≥ 1000 · ym
xl ≤ 1200 · yl
xl ≥ 1000 · yl
yj ∈ {0, 1}, xj ≥ 0 and integer, for all j ∈ {s, m, l}