MSci 331- Integer Programming
Department of Management Sciences,
University of Waterloo
“most practical planning problems could be
reformulated as a system of linear inequalities.”
“ground rules for selecting good plans by general
• What skills should you expect to learn?
– Appreciate the importance of studying IP in
– Formulate IP models for real world problems
• What I expect from you?
– Be alert
– Do not hesitate to ask questions
– Target audience: Senior Undergrads
– Do not expect to understand everything on
– You will need to invest some time outside the
classroom to understand in-depth concepts
– IP is one of the most important topics in OR
• Why integer variables?
– Some variables must take integral values
– Some variables represent a state such as on
or off (opened or closed) i.e. binary
– Lets think of 5 situations – Integer Vs
Now he tells us…..
• Why LP ?
– LP can be solved efficiently – Polynomial Time
complexity (Kamarkar’s algorithm)
– IP problems can be extremely difficult to solve
– Mixed Integer Programs - problems which have both
integer and continuous variables.
– So is IP = LP ?!?!?!?
Let us consider a few problems that we encounter in real-life
and attempt to model them as linear programming problems:
1. The problem is to assign N jobs to N people. The cost
of performing job j using person i is given by Cij-. Each
person gets exactly one job and each job goes to exactly
one person. The problem is to find the least cost
assignment of jobs to people.
2. Given N cities, a person has to travel each city once and
only once and should return to the starting point. The
distance matrix among the cities is given. The problem
is to find the tour that has least distance traveled.
3. Given N points and the distance matrix, the
problem is to group the points into p groups such
that points within each group are close to each
4. Given that the assembly of a product requires N
components, each having an assembly time tj. There
are also some precedence relationships that have to
be met. The problem is to assign them to minimum
number of workstations such that the precedence
relationships are satisfied and the cycle time of each
workstation does not exceed a given value.
5. N jobs are to be carried out in M machines.
Each job has a specific order of visiting the
machines. Job i has a processing time pij on
machine j. Each machine can process only
one job at a time and vice versa. The problem
is to schedule the jobs on machines to
minimize the total time at which all jobs have
Modeling Constraint Logic
• - And - Or
• Implication: if…..then
– X Y ( X implies Y )
– X Y ( X implies not Y )
• Double Implication
– X Y ( X if and only if Y) : XNOR operator
Constraint Logic contd..
• XOR: (XY)(XY)
– Either X or Y but not both
• Similarly NAND, NOR and other
conditions can be modeled with ease
• (X Y) Z
– Z must be true, If and only if X is true and Y is true
• (XA XB) (XC XD XE)
– If either XA or XB (or both) is(are) true, then atleast one of XC, XD
and XE must be true
( XA XB )
• XC + XD + XE
• Applying logic to constraints e.g. either
constraints or C2 should be valid
depending on an outcome.
• Suppose C1: X + Y 3
C2: 2X + 5Y 12
• X + Y 3 + M( 1 – Z )
• 2X + 5Y 12 + MZ
The problem is to assign N jobs to N people. The cost of performing
job j using person i is given by C ij -. Each person gets exactly one
job and each job goes to exactly one person. The problem is to find
the least cost assignment of jobs to people.
Let X ij = 1 if job i goes to person j.
ij X ij
ij 1 i (1)
ij 1 j (2)
X ij [0,1] i, j (3)
• The objective function minimizes the total cost of
• The constraints (2) and (3) ensure that each job goes to
only one person and that each person gets only one
• There is a zero-one restriction on the variables, given
by constraint (4).
• Due to unimodularity of the coefficient matrix, LP
solutions will satisfy the zero-one restriction.
• We solve the Assignment problem using the Hungarian
algorithm that uses principles from Linear Programming.
Allocation of coast guards on Canada’s
Each of the districts along the coast is assigned to one of a smaller
number of coast guard ships. Since the ships have different home
bases and different equipment and operating costs, the time and cost
of assigning any district varies considerably among the ships. Each
ship is available 50 weeks a year. The task is to find a minimum cost
Ship, j 1 2
Estevan Cost 130 30
Time (weeks) 30 50
Mackenzie Cost 460 150
Time (weeks) 10 20
• we are given the supplies at several plants and the demands at
several markets for a single commodity, and we are given the unit
costs of shipping the commodity from plants to markets.
• The economic question is: how much shipment should there be
between each plant and each market so as to minimize total
Traveling Salesman Problem (TSP) – An
infamous problem in OR
Given N cities, a person has to travel each city once and only once
and should return to the starting point. The distance matrix among
the cities is given. The problem is to find the tour that has least
X ij = 1, if the person visits city j immediately after visiting city i, 0
The objective function is to
Minimize d i j
ij X ij
ij 1 i (1)
ij 1 j (2)
X ij [0,1] i, j (3)
• Consider a 5 city TSP and X12 = X21 = X34 = X45 = X52 = 1
• This solution is infeasible to the TSP. There are two sub
tours 1-2-1 and 3-4-5-3.
• A feasible solution to the TSP is a tour and therefore the
formulation should have constraints to eliminate all the
• For a 5 city TSP, we could have sub tours of size 1 (say,
X11 =1), size 2, 3 or 4. Every sub tour will create at least
one more sub tour. The sub tours are eliminated as
follows using the following constraints
• If there is a sub tour of length 4, there has to be a sub
tour of length 1.
• If we eliminate all sub tours of length 1, we have
eliminated all sub tours of length 4.
• For every TSP, we set djj = so that Xjj does not figure
in the solution. By eliminating sub tours of size 1, we
have eliminates sub tours of size 4 and therefore sub
tours of size 4 need not be eliminated explicitly.
• If there is a sub tour of size 3, there has to be either a
sub tour of size 2 or two sub tours of size 1.
• We have already eliminated sub tours of size 1. If we
now eliminate sub tours of size 2, we have eliminated
sub tours of sizes 2 and 3. This is carried out by inserting
a constraint of the form
Xij + Xji 1 (2.8)
•This constraint would ensure that if Xij
=1, Xji has to be zero so that all sub tours of
size 2 are eliminated. It can happen that a
particular Xij need not be in the solution. 1
P – Median Problem
Given N points and the distance matrix, the problem is to group into p
groups such that points within the group are close to each other.
Let dij denote the known distance between points i and j.
Decision variables are:
= 1 if point j is chosen as a median point
X ij = 1 if point i is grouped with median j.
X ij = 0 otherwise
The objective function is Minimize d
ij X ij
ij 1 i (1)
ij p j ( 2)
X ij X jj i, j (3)
X ij [0,1] i, j ( 4)
• The objective function minimizes the distance ensuring
that points within a group are compact.
• Constraint (1) allocates one point to only one median.
• Constraint (2) chooses exactly p points as medians
thereby making exactly p groups.
• Constraint (3) ensures that every point is grouped
around a median point. A point i can join the group j (with
median j) only when point j is chosen as a median.
• The zero-one constraints are given in (4).
Fixed Charge Problem – Facilities Location
Choose p among m points as locations where plants can be located.
Let there be n demand points each having demand bj. Plant i can
produce ai quantity of the product. There is a transportation cost of dij
between plant i and destination j. There is a fixed cost fi of setting a
plant in location i.
Let Yi = 1 if point i is chosen as a plant location,
X ij be the quantity transported from plant at i to
demand point j.
Minimize fiYi dij X ij
i i j
i p (1)
ij Yi ai i ( 2)
ij bj j (3)
X ij , Yi [0,1] i, j ( 4)
Fixed Charge Problem Contd…
• This problem is called the fixed charge problem.
• The objective function minimizes the sum of the fixed
costs of setting up the facilities and the costs of
transporting the items.
• Constraint (1) ensures that exactly p facilities are
• Constraint (2) ensures that supply is possible only from a
point chosen for setting up the facility and that the total
amount transported from a chosen facility is less than
• Constraint (3) ensures that the demand constraints are
• zero-one constraints are modeled in constraint (4).
• A toy manufacturer is planning to produce new toys. The setup cost of the
production facilities and the unit profit for each toy are given below. :
Toy Setup cost (£) Profit (£)
1 45000 12
2 76000 16
The company has two factories that are capable of producing these toys.
In order to avoid doubling the setup cost only one factory could be used.
• The production rates of each toy are given below (in units/hour):
Toy 1 Toy 2
Factory 1 52 38
Factory 2 42 23
Factories 1 and 2, respectively, have 480 and 720 hours of production time
available for the production of these toys.
The manufacturer wants to know which of the new toys to produce, where
and how many of each (if any) should be produced so as to maximize the
Constraint Programming (CP) and
Operations Research (OR)
• Logic can be modeled in IP constraints using
• This is the strength of CP – Declarative
• CP is the main competitor to integer
Inferences from integer programming
1. Most real-life problems are formulated as integer
programming problems in addition to being formulated as
linear programming problems.
2. Most allocation problems are formulated as zero-one
3. Some formulations are of the mixed type involving
combinations if zero-one, continuous and integer variables
4. Problem characteristics such as precedence can give rise to
a large number of constraints
5. Modeling is an art and it can only be improved through