EFIM20005:
Management Science
Live Lecture: LP III Binary Variables and
Their Application
Dr Bangdong Zhi
Lecturer in Operations Management and Analytics
1
Objectives of Today’s Lecture
By the end of this lecture, you should be able to:
• understand what is meant by binary variables;
• use binary variables to formulate BILP problems;
• solve BILP problems using Excel.
2
Binary Integer Linear Programming
• As special case of an integer variable is one that can only take the values of
0 or 1. This is referred to as a binary variable.
• Typically the one or zero correspond to “yes” or “no” in response to a
decision rather than a numerical interpretation
3
Example of BILP Problem: Capital
Budgeting
The Ice Cold Refrigerator Company is considering a variety of projects with varying capital
requirements over the next four years. Faced with limited capital resources, the company must
select the most profitable projects for the capital expenditures. All relevant data is given in the
table below. Find the expenditure strategy that maximises net present value (NPV).
4
BILP Formulation
5
Example of BILP Problem: Fixed Costs
GC Clothing is capable of manufacturing three types of clothing: shirts, shorts and trousers. To
manufacture each type of clothing requires GC Clothing to have available the appropriate type of
machinery. The rental cost (per week) of each type of machine is given in table. Each type of
clothing requires a certain number of employee hours and cloth. These figures are given in table
in addition to unit variable profit per item. Formulate the problem of finding GC Clothing’s
maximum weekly profit.
6
Formulation: Decision Variables
Clearly, we have decision variables for the number of each type of clothing produced:
• 𝑋1 = number of shirts produced each week;
• 𝑋2 = number of shorts produced each week;
• 𝑋3 = number of trousers produced each week.
But we also have decisions on whether or not to rent the appropriate machinery:
• 𝑌1 = 1 if shirt machinery is rented; 0 if not rented;
• 𝑌2 = 1 if shorts machinery is rented; 0 if not rented;
• 𝑌3 = 1 if trousers machinery is rented; 0 if not rented.
7
Formulation: Objective Function and
Explicit Constraints
The weekly profit function is given by
Maximize 𝑧 = 6𝑋1 + 4𝑋2 + 7𝑋3 – 200𝑌1 – 150𝑌2 – 100𝑌3
Also there are restrictions on the amount of cloth and hours available
Constraint 1: No more than 150 work hours are available
3𝑋1 + 2𝑋2 + 6𝑋3 ≤ 150
Constraint 2: No more than 160 square metres of cloth are available
4𝑋1 + 3𝑋2 + 4𝑋3 ≤ 160
8
Formulation: Implicit Constraints for Fixed
Costs
• There is a relationship between 𝑌1 and 𝑋1 (and the other pairs of 𝑌 and 𝑋 too)
• If we rent the machine (𝑌1 = 1) then we can manufacture shirts (𝑋1 ≥ 0);
• If we don’t rent the machine (𝑌1 = 0) then we can’t manufacture shirts (𝑋1 = 0)
• This is achieved with:
𝑋1 ≤ 𝑀1 𝑌1
• Where 𝑀1 is a large number
9
Formulation: How to find 𝑴𝟏
To find the maximum value of 𝑋1 , we consider what would happen if all available
resources were diverted into the production of this product. If all 150 work hours were
spent on shirts (which require 3 hours each), then the maximum number of shirts we
could produce is
150 / 3 = 50
Similarly, If all cloth was used on shirts, the maximum number we could produce is
160 / 4 = 40
So, if all resources were devoted to shirts, the largest value for 𝑋1 would be 40, because
we require both constraints to hold at the same time.
𝑋1 ≤ 40𝑌1
10
Formulation: Final Stages
We clearly need:
𝑋2 ≤ 𝑀2 𝑌2
𝑋3 ≤ 𝑀3 𝑌3
Show that:
𝑀2 = 53
𝑀3 = 25
The formulation is complete with:
𝑋𝑖 ≥ 0 𝑎𝑛𝑑 𝑌𝑖 𝑏𝑖𝑛𝑎𝑟𝑦 (𝑖 = 1,2,3)
11
Example of BILP Problem: Facility Location
• Ohio Trust Company is considering expanding its
operation into a 20 county region in NorthEastern
Ohio.
• Currently, Ohio Trust does not have a principal
place of business (PPB) in any of the 20 counties
under consideration.
• According to Banking Laws in Ohio, if a bank
establishes a PPB in any county, branch banks can
be established in that county and in any adjacent
county. Adjacent counties are given in the table.
• As an initial step in its planning, Ohio Trust
would like to determine the minimum number of
PPBs necessary to do business throughout the 20
county region.
12
Solution Approach
• Bank has to decide whether or not to place a PPB in each county (YES or
NO).
• Introduce a binary variable representing the YES/ NO decision for each
of the 20 counties individually.
• For each county:
➢Placing a PPB in this county or any of its adjacent counties would allow business
in that county;
➢At least one of the variables representing that set of counties needs to be 1.
13
Formulation of Facility Location Problem
Let 𝑋𝑖 = 1 if a PPB is established in county 𝑖; 0 otherwise. 𝑖 = 1,2,3, … , 20.
𝑀𝑖𝑛𝑖𝑚𝑖𝑧𝑒 𝑧 = 𝑋1 + 𝑋2 + 𝑋3 + ⋯ + 𝑋20
s.t. 𝑋1 + 𝑋2 + 𝑋12 + 𝑋16 ≥ 1 Ashtbula
𝑋1 + 𝑋2 + 𝑋3 + 𝑋12 ≥ 1 Lake
𝑋2 + 𝑋3 + 𝑋4 + 𝑋8 + 𝑋10 + 𝑋12 + 𝑋13 ≥ 1 Cuyahoga
𝑋11 + 𝑋14 + 𝑋19 + 𝑋20 ≥ 1 Carroll
And 𝑋𝑖 = 0,1 𝑖 = 1,2, … , 20
14
EFIM20005:
Management Science
Live Lecture: Modelling Constraints
with Binary Variables
Dr Bangdong Zhi
Lecturer in Operations Management and Analytics
1
Objectives of Today’s Lecture
By the end of this lecture, you should be able to:
Understand and use binary variables to model:
➢Choice constraints;
➢Conditional constraints;
➢Either … or constraints.
2
Choice Constraints
A choice constraint applies when we want to do a limited number of actions
from a complete set:
➢For example, one of limited warehouse expansion or extensive
warehouse expansion
➢Choose six modules to study from a programme of twelve.
3
Example
Suppose we have a situation where we have a set of four projects available from
which we have to make selections:
➢𝑋1 = 1 if project 1 selected; 0 otherwise;
➢𝑋2 = 1 if project 2 selected; 0 otherwise;
➢𝑋3 = 1 if project 3 selected; 0 otherwise;
➢𝑋4 = 1 if project 4 selected; 0 otherwise.
What constraints do we need if:
➢Exactly one project must be selected?
➢At most one project must be selected?
➢At least two projects must be selected?
4
Conditional and Corequsite Constraints
A conditional constraint applies when we have a situation where we must
have done an action first before we can do, or at least have a choice of doing, a
second action.
➢For example, in a problem of selecting modules from a programme, we can only to
study Advanced Corporate Finance if we have completed the study of Basic
Corporate Finance
A variant is a corequisite constraint. This means either both actions are done
or neither can be done.
➢For example, to install certain software on a PC, you either need to do a memory
upgrade and a storage capacity upgrade, otherwise you’d buy a new PC and not
bother to do either.
5
Example
• Building on the four project example on Slide 4:
• What constraints do we need if:
➢Project 2 is only available to us if Project 1 is selected?
➢Projects 1 and 2 must either both be done or neither be done.
6
Either .. Or Constraints
The third type of constraint is:
Either ..Or
➢For example, either we invest in oil industry stock or we invest in green
energy stock.
➢Either we put 200 hours into working on a project or we don’t start it (0 hours)
➢Either we put a limit of investing £20000 in bitcoin and Litecoin or we put a
limit on investing £25000 in Ethereum and Ripple. (Example continued on
Slide 9)
7
General Approach
Suppose we have two constraints where either the first or the second is active in the
formulation:
𝑓 𝑥1 , 𝑥2 , … , 𝑥𝑛 ≤ 0
𝑔 𝑥1 , 𝑥2 , … , 𝑥𝑛 ≤ 0
We replace these two constraints with:
𝑓 𝑥1 , 𝑥2 , … , 𝑥𝑛 ≤ 𝑀1 (1 − 𝑦)
𝑔 𝑥1 , 𝑥2 , … , 𝑥𝑛 ≤ 𝑀2 𝑦
Where 𝑦 is a binary variable which is
➢ 1 if 𝑓 is an active constraint
➢ 0 if 𝑔 is an active constraint
➢ 𝑀1 and 𝑀2 is a large number bigger than any value that any values in 𝑓 and 𝑔 can
take (to be determined from the context of problem)
8
Example (Cryptocurrency from Slide 7)
Let:
➢𝑋1 = amount invested in Bitcoin;
➢𝑋2 = amount invested in Ethereum;
➢𝑋3 = amount invested in Litecoin;
➢𝑋4 = amount invested in Ripple.
• Either 𝑋1 + 𝑋3 ≤ 20000
• Or 𝑋2 + 𝑋4 ≤ 25000
9
Example (cont.)
• Write each constraint as a “≤ 0” type of constraint with everything else on
the left-hand side:
➢Either 𝑋1 + 𝑋3 − 20000 ≤ 0
➢Or 𝑋2 + 𝑋4 − 25000 ≤ 0
• Introduce a new binary variable Y:
➢𝑌 = 1 if the first constraint applies to the problem and the second one doesn’t;
➢𝑌 = 0 if the second constraint applies to the problem and the first one doesn’t.
• Identify a value, 𝑀, that is big enough so that, as the RHS of either
constraint, it makes the constraint nonbinding.
10
Example (cont.)
• 𝑋1 + 𝑋3 − 20000 ≤ 𝑀1 (1 − 𝑌)
• 𝑋2 + 𝑋4 − 25000 ≤ 𝑀2 𝑌
• How does this work?
• If Y = 1, the first constraint is in its true form but the second:
𝑋2 + 𝑋4 ≤ 𝑀2 + 25000
• If 𝑀2 is, say, bigger than the available budget, then even though the
constraint is in the problem, we will guarantee it will be nonbinding
because of other constraints.
11
Refinement on 𝑴
𝑋1 + 𝑋3 − 20000 ≤ 𝑀1 (1 − 𝑌) (1)
𝑋2 + 𝑋4 − 25000 ≤ 𝑀2 𝑌 (2)
• There is advantage in setting M as small as possible, whilst being large
enough so that the inactive constraint is always redundant.
• Question: Examine the LHS of (1) and (2). If the budget is £100000 what is the
largest values they could possibly take?
12
Example (cont.)
• For (1), the largest value the LHS can take is:
100000 − 20000 = 80000
• For (2), the largest value the LHS can take is:
• 100000 − 25000 = 75000
• M needs to be chosen so that it is large enough to cover both constraints i.e.
80000.
• So the constraints would be:
• 𝑋1 + 𝑋3 + 80,000𝑌 ≤ 100000
• 𝑋2 + 𝑋4 − 75,000 𝑌 ≤ 25000
13
Exercise
A bank wants to determine where its assets should be invested during the current year. £2 million
is available for investments of the following types (figures in brackets are the annual returns):
bonds (6%), home loans (8%), equities (17.5%), personal loans (19%). The following restrictions
have been imposed for policy reasons.
1. The amount invested in home loans cannot exceed the amount invested in bonds.
2. No more than 30% of the total amount invested may be in personal loans
3. If there is any investment in equities then there must be investment in bonds
4. Because of high brokers’ charges on small transactions, if any investments are to be made in
bonds, they must be at least £250,000.
5. Either the total invested in bonds and home loans must be at least £250,000 or the investment
in personal loans must not exceed £750,000.
Formulate the problem of deciding how much to invest in each category to maximise annual
return.
14
Formulation
15
16
MS Linear Programming Questions for Week 22 Tutorial
Question 1
Spencer Enterprises is attempting to choose among a series of new investment alternatives.
The potential investment alternatives, the net present value of the future streams of returns,
the capital requirements, and the available capital funds over the next 3 years are summarized
as follows:
Question 2
The following questions refer to a Capital Budgeting problem with six projects represented
by 0-1 variables 𝑋1 , 𝑋2 , 𝑋3 , 𝑋4 , 𝑋5 , 𝑋6 . Each constraint should be considered in
isolation.Produce a solution to this problem in Excel and report the solution in a form suitable
for the manager.
a) Write a constraint modelling a situation in which two of the projects 1, 3, 5 and 6 must
be undertaken
b) Write a constraint modelling a situation in which projects 3 and 5 must be undertaken
simultaneously
c) Write a constraint modelling a situation in which projects 1 or 4 must be undertaken
but not both
d) Write constraints modelling a situation where project 4 cannot be undertaken unless
projects 1 and 3 are also undertaken
e) Revise the requirement in part (d) to accommodate the case in which, when projects 1
and 3 are undertaken, project 4 also must be undertaken
Question 3
Snow Cinemas is considering four options for the seating capacity of a new cinema: 100, 150,
250 and 400 seats. Let
𝑋1 = 1 if a seating capacity of 100 is selected; 0 otherwise
𝑋2 = 1 if a seating capacity of 150 is selected; 0 otherwise
𝑋3 = 1 if a seating capacity of 250 is selected; 0 otherwise
𝑋4 = 1 if a seating capacity of 400 is selected; 0 otherwise
a) Let z = capacity of the cinema that Snow Cinemas decide to build. Write constraints
that will ensure that the capacity chosen will be 100, 150, 250 or 400.
b) Write constraints that will ensure that the capacity of the chosen cinema will be 100,
150, 250 or 400 if a cinema is built or 0 if the company does not build the new cinema.
Question 4
London is considering the relocation of several police substations to obtain better enforcement
in high crime areas. The locations under consideration together with the areas that can be
covered from these locations are given in the following table.
Formulate a model that could be used to find the minimum number of locations necessary to
provide coverage to all areas.
Question 5
A company has three production plants, details of which are as follows.
The company wishes to produce 90,000 units per year at minimum total cost. How should it
do it? (Remember that if a plant produces zero, it incurs no fixed costs).
MS9 Tutorial Questions for Week 10 Solutions
Question 1
Let Xi = 1 if investment alternative i is selected (i=1,2,3,5; where 1= warehouse
expansion, 2 = test market new product; 3 = advertising campaign; 4 = basic research
5 = purchase new equipment
Max NPV = 4000X1 + 10500X2 + 4000X3 + 8000X4 + 3000X5
s.t. 3000X1 + 6000X2 + 2000X3 + 5000X4 + 1000X5 ≤ 10500 (year 1 investment)
1000X1 + 4000X2 + 1500X3 + 1000X4 + 500X5 ≤ 7000 (year 2 investment)
4000X1 + 5000X2 + 1800X3 + 4000X4 + 900X5 ≤ 8750 (year 3 investment)
And Xi binary (i=1,2,…,5)
Week 3 Question C: Capital Budgeting
Input Data
Warehouse Test Market Advertising Research Purchase Available Funds
Year 1 3000 6000 2000 5000 1000 10500
Year 2 6000 4000 1500 1000 500 7000
Year 3 2000 5000 1800 4000 900 8750
NPV (Return) 4000 10500 4000 8000 3000
Output Values
Decision Variables 0 1 1 0 1 Revenue
Objective function 0 10500 4000 0 3000 17500
Constraints
Capital Used
Year 1 9000
Year 2 6000
Year 3 7700
To maximize Return the company should test market the new product, launch an advertising campaign
and purchase new equipment. This gives a return of 17500
(Exactly the same structure as the Capital Budget problem where formulation was
explained in Video 1 of Week 1 and solved in Video 2 of Week 9)
Question 2
(a) X 1 + X 3 + X 5 + X 6 2 (note we have to deal with ambiguity in this question:
does two of the six mean EXACTLY two or AT LEAST two. I have assumed at least
2 as this will ensure 2 and then leave discretion for other constraints in the problem to
decide about the other variabbles)
(b) X 3 − X 5 = 0 (to show this think about setting the X values to 0 or 1; the only
valid combinations are both 0 or both 1 meaning they are either both done or both not
done)
(c) X 1 + X 4 = 1 (projects 1 or 4 must be done would imply their sum has to be at
least 1; however “not both” rules out > 1 leaving = 1)
(d) X 4 − X1 0 and X 4 − X 3 0 or X4 <= 0.5(X1 + X3)
Explanation of first pair: X4 ≤ X1. Observe what happens if X1 is set to 0 (not
done, which forces X4 ≤ 0, which means 0 as X vars can only be 0 or 1 by definition).
Alternatively if X1 is set to 1 (done) then X4 ≤ 1 i.e. X4 can be 0 or 1 (done or not
done). Same argument for X4 and X3
Explanation of second equation:
X1 X3 0.5(X1 + X3) Impact on X4
0 0 0 X4 = 0 (not done)
0 1 1/2 X4 ≤ 0.5 means X4 = 0 (not
done)
1 0 As above As above
1 1 1 X4 ≤ 1 means X4 = 0 or 1
(done or not done)
(e) If we have either of the formulations in (d) in place we are dealing with
preventing X4 from being done if X1 and X3 are not done. What we need is to
add a constraint which means that if both are 1 then this forces X4 to be 1
(done) WITHOUT forcing X4 must be done under any other values of X1 and
X3
The constraint links X4 on one side with some combination of X1 and X3 on
the other. Prevention constraints like (c) are typically of ≤ type whilst
compulsion constraints as we require here are typically of ≥ type.
So we know we want something like:
X4 ≥ X1 + X3
However that doesn’t work because:
X1 X3 (X1 + X3) Impact on X4
0 0 0 X4 = 0 (not done)
0 1 1 X4 = 1 (done)
1 0 1 X4= 1 (done)
1 1 2 X4 = 2 (meaningless)
The clue is in looking at the “impact on X4” column. It’s value is 1 to big in the
second, third and fourth rows. So what if we subtract 1 from the RHS? That would
work for those cases, but for X1 = X3 = 0 we end up with X4 ≥ -1. But this is ok as it
allows X4 to take the value 0.
So X4 ≥ X1 + X3 – 1
Will provide what we want.
This is an example of the type of logical deduction that modellers have to engage with
to create constraints that meet their specific requirement.
Question 3
(a)
Z = 100X1 + 150X2 + 250X3 + 400X4
s.t. X1 + X 2 + X 3 + X 4 = 1
Explanation: the objective function need to return the capacity of the cinema i.
100,150, 250, 400. The appropriate capacity will be added to Z is the corresponding
X variable is set to 1. However, we need a constraint that ensure that only one of the
capacities is chosen (as the cinema can’t simultaneously be different capacities)
(b) Let Y = 1 if cinema built; 0 otherwise
X1 + X 2 + X 3 + X 4 = Y
Explnation: we could explore the formal either… or constraint structure here.
However, a simpler formulation is available by experimentation. IF Y = 0 (cinema
not built) this will force all the X variables to be 0, which in turn will force Z to take
the value 0. If the cinema is built (Y = 1) then the constraint from (a) is repeated,
which forces one of the available capacities to be selected and added to the objective
function.
Question 4
Let A = 1 if Station located in A; 0 Otherwise
Similar definition for B,C,D,E,F and G
Minimize Z = A + B + C + D + E + F + G
E A+E+G >= 1
s.t. A + B + C + G ≥1 (Area 1 covered)
B + D ≥1 A+B+E+G>=1 (Area 2 covered)
A+ C + E ≥1 etc
D + E + F ≥1 B+D+E>=1
A + B + C + D + F + G ≥1 C+D+F>=1
E + F + G ≥1 D+E+F>=1
A + B + G ≥1 A+E+F+G>=1
And A,B,C,D,E,F,G binary.
(Exactly the same structure as the Facility Location problem explained in the first
video lecture of Week 9)
Question 5
Let X1 = amount produced by plant 1
X2 = amount produced by plant 2
X3 = amount produced by plant 3
Y1 = 1 if plant one is used; 0 otherwise
Y2 = 1 if plant two is used; 0 otherwise
Y3 = 1 if plant three is used; 0 otherwise
Minimize Cost = 150X1 + 130X2 + 105X3 + 5000000Y1+ 7000000Y2 + 9000000Y3
s.t.
X1 + X2 + X3 = 90000 (produce exactly 90000 units)
X1 ≤ 20000Y1 (capacity constraint on plant 1 production if Y1
= 1 otherwise the production is set at 0))
X2 ≤ 40000Y2 etc
X3 ≤ 75000Y3 etc
And Xi ≥0, Yi binary i=1,2,3
(Exactly the same structure as the Fixed Cost problem explained in the first video
lecture of Week 9)