Integer Programming Formulation Examples
Integer Programming Formulation Examples
OR-Notes
J E Beasley
OR-Notes are a series of introductory notes on topics that fall under
the broad heading of the field of
operations research (OR). They were originally
used by me in an introductory OR course I give at Imperial
College. They
are now available for use by any students and teachers interested in OR
subject to the
following conditions.
x1 + x2 = 1
Choose any one of these two variables (x1, say) and tabulate,
for each possible value of the chosen variable,
the meaning of the corresponding
mathematical and verbal descriptions as below.
Variable value Mathematical description Verbal description
x1 + x2 = 1 "either x1 = 1 or x2 = 1"
x1 = 0 x2 = 1 x2 = 1
x1 = 1 1 + x2 = 1 x2 = 0
i.e. x2 = 0
It is clear from this tabulation that the mathematical and verbal descriptions
are equivalent with the proviso
that we have interpreted the condition
"either x1 = 1 or x2 = 1" as meaning that
the case x1 = 1 and x2 = 1
(both projects
1 and 2 chosen) cannot occur. If this is not so (i.e. both projects 1 and
2 can be chosen) then
we replace the constraint x1 + x2
= 1 by the constraint x1 + x2 >= 1 (i.e. at least
one of projects 1 and 2 must
be chosen).
Other problems
people.brunel.ac.uk/~mastjjb/jeb/or/moreip.html 1/16
6/28/2021 Integer programming formulation examples
Blending problem
gram 90 50 20 2
Variables
Constraints
x1 + x2 + x3 = 1
nutrient constraints
people.brunel.ac.uk/~mastjjb/jeb/or/moreip.html 2/16
6/28/2021 Integer programming formulation examples
Objective
Give the complete MIP formulation of the problem with these two new
conditions added.
Solution
and
To cope with condition that need only satisfy three of the four nutrient
constraints we introduce four zero-one
variables zi (i=1,2,3,4)
where
= 0 otherwise
people.brunel.ac.uk/~mastjjb/jeb/or/moreip.html 3/16
6/28/2021 Integer programming formulation examples
The logic behind this change is that if a zi=1 then the constraint
becomes the original nutrient constraint
which needs to be satisfied. However
if a zi=0 then the original nutrient constraint becomes
which (for the four left-hand sides dealt with above) is always true
and so can be neglected - meaning the
original nutrient constraint need
not be satisfied. Hence the complete (MIP) formulation of the problem is
given by
subject to
x1 + x2 + x3 = 1
z1 + z2 + z3 + z4 >= 3
x2 <= y
zi = 0 or 1 i=1,2,3,4
y = 0 or 1
xi >= 0 i=1,2,3
In the planning of the monthly production for the next six months a
company must, in each month, operate
either a normal shift or an extended
shift (if it produces at all). A normal shift costs £100,000 per
month and
can produce up to 5,000 units per month. An extended shift costs
£180,000 per month and can produce up to
7,500 units per month. Note
here that, for either type of shift, the cost incurred is fixed by a union
guarantee
agreement and so is independent of the amount produced.
Solution
people.brunel.ac.uk/~mastjjb/jeb/or/moreip.html 4/16
6/28/2021 Integer programming formulation examples
Variables
Hence let:
xt = 1 if we operate a normal shift in month t (t=1,2,...,6)
= 0 otherwise
= 0 otherwise
In fact, for this problem, we can ease the formulation by defining three
additional variables - namely let:
= 0 otherwise
of month t (t=1,2,...,6)
= 0 otherwise (i.e. Pt = 0)
The motivation behind introducing the first two of these variables (zt,
It) is that in the objective function we
will need terms relating
to shift change cost and inventory holding cost. The motivation behind
introducing
the third of these variables (wt) is the production
constraint "either Pt = 0 or Pt >= 2000",
which needs a zero-
one variable so that it can be dealt with using the
standard trick for "either/or" constraints.
Constraints
We first express each constraint in words and then in terms of the variables
defined above.
xt + yt <= 1 t=1,2,...,6
Note here that we could not have made do with just one variable (xt
say) and defined that variable to be one
for a normal shift and zero for
an extended shift (since in that case what if we decide not to produce
in a
particular month?).
people.brunel.ac.uk/~mastjjb/jeb/or/moreip.html 5/16
6/28/2021 Integer programming formulation examples
Note here the use of addition in the right-hand side of the above equation
where we are making use of the
fact that at most one of xt and
yt can be one and the other must be zero.
no stockouts
It >= 0 t=1,2,...,6
we have that
It = It-1 + Pt - Dt t=1,2,...,6
As noted above this equation assumes that we can meet demand in the
current month from goods produced
that month. Any time lag between goods
being produced and becoming available to meet demand is easily
incorporated
into the above equation. For example for a 2 month time lag we replace
Pt in the above equation
by Pt-2 and interpret It
as the number of goods in stock at the end of month t which are available
to meet
demand i.e. goods are not regarded as being in stock until they
are available to meet demand. Inventory
continuity equations of the type
shown are common in production planning problems.
the amount in stock at the end of month 6 should be at least 2000 units
I6 >= 2000
Objective
Comments
A = BC
To see this we use the fact that as B and C take only zero-one values
there are only four possible cases to
consider:
0 0 A = 0 A <= 0 A >= -1
1 1 A = 1 A <= 1 A >= 1
Then, recalling that A can also only take zero-one values, it is clear
that in each of the four possible cases the
two linear constraints (A <=
(B+C)/2 and A >= B+C-1) are equivalent to the single non-linear constraint
(A=BC).
zt = xt-1yt
people.brunel.ac.uk/~mastjjb/jeb/or/moreip.html 7/16
6/28/2021 Integer programming formulation examples
Making this change transforms the non-linear integer program given before
into an equivalent linear integer
program.
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
Solution
Variables
We need to decide how many of each toy should be produced in each factory
so let xij be the number of toys
of type j (j=1,2) produced
in factory i (i=1,2) where xij >=0 and integer.
Constraints
Objective
people.brunel.ac.uk/~mastjjb/jeb/or/moreip.html 8/16
6/28/2021 Integer programming formulation examples
Note here that the question says that in order to avoid doubling the
setup costs only one factory could be
used. This is not a constraint. We
can argue that if it is only cost considerations that prevent us using
more
than one factory these cost considerations have already been incorporated
into the model given above and the
model can decide for us how many factories
to use, rather than we artificially imposing a limit via an explicit
constraint
on the number of factories that can be used.
What are the advantages and disadvantages of using this model for portfolio
selection?
Solution
Variables
Constraints
SUM{j=1,...,10}Cjxj <= Q
people.brunel.ac.uk/~mastjjb/jeb/or/moreip.html 9/16
6/28/2021 Integer programming formulation examples
x3 + x4 <= 1
x5 + x6 <= 1
x5 <= x3+ x4
x6 <= x3+ x4
x1 + x2 + x7 + x8 + x9
+ x10 >= 2
x1 + x2 + x7 + x8 + x9
+ x10 <= 4
Objective
maximise SUM{j=1,...,10}Pjxj
The model given above is a very small zero-one integer programming problem
with just 10 variables and 7
constraints and should be very easy to solve.
For example even by complete (total) enumeration there are just
210
= 1024 possible solutions to be examined.
The advantages and disadvantages of using this model for portfolio selection
are:
Vegetable oil:
VEG1
VEG2
Non-vegetable oil:
OIL1
OIL2
OIL3
The prices for buying each oil are given below (in £/tonne)
VEG1 VEG2 OIL1 OIL2 OIL3
The final product sells at £180 per tonne. Vegetable oils and
non-vegetable oils require different production
lines for refining. It
is not possible to refine more than 210 tonnes of vegetable oils and more
than 260 tonnes
people.brunel.ac.uk/~mastjjb/jeb/or/moreip.html 10/16
6/28/2021 Integer programming formulation examples
It is required to determine what to buy and how to blend the raw oils
so that the company maximises its
profit.
The following extra conditions are imposed on the food manufacture problem
stated above as a result of the
production process involved:
Solution
Variables
Constraints
x1 + x2 <= 210
x3 + x4 + x5 <= 260
hardness of the final product must lie between 3.5 and 6.2
Objective
maximise 180(x1 + x2 + x3 + x4
+ x5) - 115x1 - 128x2 - 132x3
- 109x4 - 114x5
Integer program
Variables
Constraints
x1 <= 210y1
x2 <= 210y2
x3 <= 260y3
x4 <= 260y4
x5 <= 260y5
y1 + y2 + y3 + y4 + y5
<= 3
xi >= 30yi
i=1,...,5
if either of VEG1 or VEG2 are used then OIL2 must also be used
y4 >= y1
y4 >= y2
Objective
No. of units produced per hour worked 100 250 190 150
To assist in planning the production for the next week the following
data is available:
Current Demand (units) for each day of the week
Product stock 1 2 3 4 5 6 7
people.brunel.ac.uk/~mastjjb/jeb/or/moreip.html 12/16
6/28/2021 Integer programming formulation examples
(units)
Solution
Variables
In fact, for this problem, we can ease the formulation by defining two
additional variables - namely let:
Constraints
no stockouts
Iit >= 0 i=1,...,4 t=1,...,7
I10 = 5000
I20 = 7000
I30 = 9000
I40 = 8000
Note here that we assume that we can meet demand in month t from goods
produced in month t and also that
the opening stock in month t = the closing
stock in month t-1.
people.brunel.ac.uk/~mastjjb/jeb/or/moreip.html 13/16
6/28/2021 Integer programming formulation examples
production constraint
A = BC
= 0 otherwise
Then
Zt = x2tx1t-1 t=1,...,7
closing stock
Objective
people.brunel.ac.uk/~mastjjb/jeb/or/moreip.html 14/16
6/28/2021 Integer programming formulation examples
Note here that this program may not have a feasible solution, i.e. it
may simply not be possible to satisfy all
the constraints. This is irrelevant
to the process of constructing the model however. Indeed one advantage
of
the model may be that it will tell us (once a computational solution
technique is applied) that the problem is
infeasible.
1 10 1.0
2 22 2.0
3 35 3.7
4 19 2.4
5 55 4.5
6 10 0.7
7 115 9.5
Formulate the problem of how many units (if any) of each product to
produce next week as an integer
program in which all the constraints are
linear.
Solution
maximise
10x1 + 22x2 + 35x3 + 19x4 + 55x5 + 10x6 + 115x7
subject to
Let
z7 = 1 if produce product 7 (x7 >= 1)
= 0 otherwise
then
Hence
people.brunel.ac.uk/~mastjjb/jeb/or/moreip.html 15/16
6/28/2021 Integer programming formulation examples
x7 <= (720/9.5)z7
x2 <= 100
y2 >= 0 integer
and amend the work-time constraint to be 1.0x1 + [2.0x2
+ 3.0y2] + 3.7x3 + 2.4x4 + 4.5x5
+ 0.7x6 +
9.5x7 <= 720
and add +22y2 to the objective function.
Introduce
= 0 otherwise
= 0 otherwise
= 0 otherwise
and
i.e.
Z = z3z4
Z >= z3 + z4 - 1
Z <= (z3 + z4)/2
people.brunel.ac.uk/~mastjjb/jeb/or/moreip.html 16/16