Binary Variable Models
Binary Variable Models
Milind G. Sohoni
Operations Management
The Indian School of Business, Gachibowli, Hyderabad
© Milind G. Sohoni 1 / 67
Modeling Business Logic (slide 2)
Outline
Topics
Appendix
© Milind G. Sohoni 2 / 67
Modeling Business Logic (slide 2)
Outline
Topics
Appendix
© Milind G. Sohoni 2 / 67
Modeling Business Logic (slide 2)
Outline
Topics
Appendix
© Milind G. Sohoni 2 / 67
Modeling Business Logic (slide 2)
Outline
Topics
Appendix
© Milind G. Sohoni 2 / 67
Modeling Business Logic (slide 2)
Outline
Topics
Appendix
© Milind G. Sohoni 2 / 67
Modeling Business Logic (slide 2)
Outline
Topics
Appendix
© Milind G. Sohoni 2 / 67
Modeling Business Logic (slide 2)
Outline
Topics
Appendix
© Milind G. Sohoni 2 / 67
Modeling Business Logic (slide 3)
Introduction to modeling with integer variables
© Milind G. Sohoni 3 / 67
Modeling Business Logic (slide 4)
Introduction to modeling with integer variables
Disadvantages:
1. More difficult to model.
2. Can be much more difficult to solve than LPs.
© Milind G. Sohoni 4 / 67
Modeling Business Logic (slide 5)
Introduction to modeling with integer variables
© Milind G. Sohoni 5 / 67
Modeling Business Logic (slide 6)
Introduction to modeling with integer variables
Some integer programs are easy (we can solve problems with millions of
variables)
I Can you think of some you have seen earlier?
Some integer programs are notoriously hard (even 100 variables can be
extremely challenging)
I It takes expertise and experience to know which is which
I Solving large IPs is an active area of research
© Milind G. Sohoni 6 / 67
Modeling Business Logic (slide 7)
Introduction to modeling with integer variables
© Milind G. Sohoni 7 / 67
Modeling Business Logic (slide 8)
Introduction to modeling with integer variables
© Milind G. Sohoni 8 / 67
Modeling Business Logic (slide 9)
Introduction to modeling with integer variables
5 x1 + 8 x2 24
x2
0
0 1 2 3 4 5
x1
© Milind G. Sohoni 9 / 67
Modeling Business Logic (slide 10)
Introduction to modeling with integer variables
5 x1 + 8 x2 24
x2
LP optimal = 4.8
0
0 1 2 3 4 5
x1
© Milind G. Sohoni 10 / 67
Modeling Business Logic (slide 11)
Introduction to modeling with integer variables
3 3
5 x1 + 8 x2 24 5 x1 + 8 x2 24
x2
x2
2 2
1 1
x1 x1
© Milind G. Sohoni 11 / 67
Modeling Business Logic (slide 12)
Introduction to modeling with integer variables
x2 5 x1 + 8 x2 24
2
0
0 1 2 3 4 5
x1
Figure: Had the truncated solution been optimal, the LP would have found it
at another corner point! That’s why it is not optimal.
© Milind G. Sohoni 12 / 67
Modeling Business Logic (slide 13)
Introduction to modeling with integer variables
x2 5 x1 + 8 x2 24
2
0
0 1 2 3 4 5
x1
© Milind G. Sohoni 13 / 67
Modeling Business Logic (slide 14)
Modeling logical constraints
© Milind G. Sohoni 14 / 67
Modeling Business Logic (slide 15)
Modeling logical constraints
Consider a business situation that has two options. For a more concrete
example, consider a firm deciding to locate warehouses at two sites,
Hyderabad (H) and Mumbai (M). To deal with various logical (business)
conditions involving locating warehouses at H and/or M, let us define two
binary decision variables as follows:
1 : if location H is chosen, 1 : if location M is chosen,
x1 = and x2 =
0 : otherwise. 0 : otherwise.
© Milind G. Sohoni 15 / 67
Modeling Business Logic (slide 16)
Modeling logical constraints
© Milind G. Sohoni 16 / 67
Modeling Business Logic (slide 17)
Modeling logical constraints
© Milind G. Sohoni 17 / 67
Modeling Business Logic (slide 18)
Modeling logical constraints
© Milind G. Sohoni 18 / 67
Modeling Business Logic (slide 19)
Modeling logical constraints
An example
Investment (i) 1 2 3 4 5 6
Cash required (000’s $) 5 7 4 3 4 6
NPV added (000’s $) 16 22 12 8 11 19
© Milind G. Sohoni 19 / 67
Modeling Business Logic (slide 20)
Modeling logical constraints
© Milind G. Sohoni 20 / 67
Modeling Business Logic (slide 21)
Modeling logical constraints
© Milind G. Sohoni 21 / 67
Modeling Business Logic (slide 22)
Modeling logical constraints
1.0 1.0
x1 - x2 ≥ 0
0.8 0.8 x1 + x3 ≤ 1
0.6 0.6
x2
x3
0.4 0.4
0.2 0.2
0.0 0.0
0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0
x1 x1
(a) x1 − x2 ≥ 0. (b) x1 + x3 ≤ 1.
Figure: Cuts generated for the Stockco model. How do they prune integer
points?
© Milind G. Sohoni 22 / 67
Modeling Business Logic (slide 23)
Modeling logical constraints
0.8 x4 + x5 1
0.6
x5
0.4
0.2
0.0
0.0 0.2 0.4 0.6 0.8 1.0
x4
Figure: x4 + x5 = 1.
© Milind G. Sohoni 23 / 67
Modeling Business Logic (slide 24)
Modeling logical constraints
© Milind G. Sohoni 24 / 67
Modeling Business Logic (slide 25)
Applications: A classification problem
© Milind G. Sohoni 25 / 67
Modeling Business Logic (slide 26)
Applications: A classification problem
© Milind G. Sohoni 26 / 67
Modeling Business Logic (slide 27)
Applications: A classification problem
© Milind G. Sohoni 27 / 67
Modeling Business Logic (slide 28)
Applications: Capacitated facility location problem
© Milind G. Sohoni 28 / 67
Modeling Business Logic (slide 29)
Applications: Capacitated facility location problem
© Milind G. Sohoni 29 / 67
Modeling Business Logic (slide 30)
Applications: Capacitated facility location problem
TelecomOptics data
Demand city
Supply Production and Transportation cost per 1000 units Capa- Fixed cost
city ($)
Salt Lake (S) 1925 2400 1425 500 950 800 27 5000
Demand (000’s) 10 8 14 6 7 11
Table: TelecomOptics’ production, shipping costs and plant location fixed costs.
© Milind G. Sohoni 30 / 67
Modeling Business Logic (slide 31)
Applications: Capacitated facility location problem
© Milind G. Sohoni 31 / 67
Modeling Business Logic (slide 32)
Applications: Capacitated facility location problem
© Milind G. Sohoni 32 / 67
Modeling Business Logic (slide 33)
Applications: Capacitated facility location problem
Constraints
Demand constraints:
Just as with the transportation problem we need to ensure that the
demand is met at each demand center. We use similar constraints in this
formulation too. Suppose, the demand
X at location j is Dj . We model the
demand constraints as follows: xij ≥ Dj for all j = A, B, C , D, O, P. .
i
That is,
© Milind G. Sohoni 33 / 67
Modeling Business Logic (slide 34)
Applications: Capacitated facility location problem
Constraints
Supply constraints:
We have to model the following constraint written in “English”: If a
supply location is open then it can ship at most up to its capacity, that
is, If yi = 1 then amount supplied from i should be at most capacity of i.
However, if yi = 0 then nothing should be supplied from i. Suppose, the
supply
X available at i is Si . We model the supply constraints as follows:
xij ≤ Si × yi for all i = L, H, S, M, W . That is,
j
© Milind G. Sohoni 34 / 67
Modeling Business Logic (slide 35)
Applications: Capacitated facility location problem
Constraints
© Milind G. Sohoni 35 / 67
Modeling Business Logic (slide 36)
Applications: Capacitated facility location problem
+ 1460xHA + · · · + 1200xHP
+ 1925xSA + · · · + 800xSP
+ 380xMA + · · · + 2321xMP
+ 922xWA + · · · + 1797xWP
Fixed costs:
Fixed costs are incurred by deciding to keep a facility open and are independent of the
transaction volume. Thus,
X
Fixed costs = fi yi = 7650yL + 3500yH + 5000yS + 4100yM + 2200yW .
i
© Milind G. Sohoni 36 / 67
Modeling Business Logic (slide 37)
Applications: Capacitated facility location problem
© Milind G. Sohoni 37 / 67
Modeling Business Logic (slide 38)
Applications: Capacitated facility location problem
Solver solution
Atlanta Boston Chicago Denver Omaha Portland Supply
(A) (B) (C) (D) (O) (P) (000's)
Baltimore (L) 1,675 400 685 1,630 1,160 3,800 18
Cheyenne (H) 1,460 1,940 970 100 495 1,200 24
Salt Lake (S) 1,925 2,400 1,425 500 950 800 27
Memphis (M) 380 1,355 543 1,045 665 2,321 22
Wichita (W) 922 1,646 700 508 311 1,797 31
Demand (000's) 10 8 14 6 7 11
© Milind G. Sohoni 38 / 67
Modeling Business Logic (slide 39)
Applications: Capacitated facility location problem
I
I How do the constraints change?
© Milind G. Sohoni 39 / 67
Modeling Business Logic (slide 40)
Applications: Capacitated facility location problem
where i = L, H, S, M, W and j = A, B, C , D, O, P.
Notice, ff the demand to be met at demand center j ,
j = A, B, C , D, O, P is denoted by Dj , then the amount shipped from i to
j can be represented as Dj · xij . If xij takes a value of 1, the shipment
amount is Dj else it is 0.
Just as in the earlier case we define
(
1 : if facility i is kept open,
yi =
0 : otherwise.
where i = L, H, S, M, W .
© Milind G. Sohoni 40 / 67
Modeling Business Logic (slide 41)
Applications: Capacitated facility location problem
© Milind G. Sohoni 41 / 67
Modeling Business Logic (slide 42)
Applications: Capacitated facility location problem
© Milind G. Sohoni 42 / 67
Modeling Business Logic (slide 43)
Applications: Capacitated facility location problem
Constraints
© Milind G. Sohoni 43 / 67
Modeling Business Logic (slide 44)
Applications: Capacitated facility location problem
+ 8 × (400xLB + · · · + 1646xWB )
+ 14 × (685xLC + · · · + 700xWC )
+ 6 × (1630xLD + · · · + 508xWD )
+ 7 × (1160xLO + · · · + 311xWO )
+ 11 × (2800xLP + · · · + 1797xWP )
X
Fixed costs = fi yi = 7650yL + 3500yH + 5000yS + 4100yM + 2200yW .
i
© Milind G. Sohoni 44 / 67
Modeling Business Logic (slide 45)
Applications: Capacitated facility location problem
© Milind G. Sohoni 45 / 67
Modeling Business Logic (slide 46)
Applications: Capacitated facility location problem
© Milind G. Sohoni 46 / 67
Modeling Business Logic (slide 47)
Applications: Modeling piecewise linear functions
© Milind G. Sohoni 47 / 67
Modeling Business Logic (slide 48)
Applications: Modeling piecewise linear functions
|2, 000 per unit
: for the first 10 units,
Marginal cost = |1, 800 per unit : for the next 15 units,
|1, 700 per unit : for the remaining 25 units.
© Milind G. Sohoni 48 / 67
Modeling Business Logic (slide 49)
Applications: Modeling piecewise linear functions
80 000
60 000
40 000
20 000
10 25 50
k
10 20 30 40 50
Constraints
© Milind G. Sohoni 50 / 67
Modeling Business Logic (slide 51)
Applications: Locating facilities to provide services
© Milind G. Sohoni 51 / 67
Modeling Business Logic (slide 52)
Applications: Locating facilities to provide services
© Milind G. Sohoni 52 / 67
Modeling Business Logic (slide 53)
Applications: Locating facilities to provide services
© Milind G. Sohoni 53 / 67
Modeling Business Logic (slide 54)
Applications: Locating facilities to provide services
© Milind G. Sohoni 55 / 67
Modeling Business Logic (slide 56)
Applications: Locating facilities to provide services
This is an example of the set covering problem. The set covering problem
is characterized by having binary variables, ≥ constraints each with a
right hand side of 1, and having simply sums of variables as constraints.
In general, the objective function can have any coefficients, though here
it is of a particularly simple form.
© Milind G. Sohoni 56 / 67
Modeling Business Logic (slide 57)
Appendix
Appendix
© Milind G. Sohoni 57 / 67
Modeling Business Logic (slide 58)
Appendix
© Milind G. Sohoni 58 / 67
Modeling Business Logic (slide 59)
Appendix
© Milind G. Sohoni 59 / 67
Modeling Business Logic (slide 60)
Appendix
xA = yA or xA − yA = 0. (8)
© Milind G. Sohoni 60 / 67
Modeling Business Logic (slide 61)
Appendix
© Milind G. Sohoni 62 / 67
Modeling Business Logic (slide 63)
Appendix
© Milind G. Sohoni 63 / 67
Modeling Business Logic (slide 64)
Appendix
max yA
s.t. xA − yA = 0,
xA − yA = 0,
xA + xB + 2xC = 2,
yA + yB + yC = 1,
xA , xB , xC , yA , yB , yC ∈ {0, 1} .
© Milind G. Sohoni 64 / 67
Modeling Business Logic (slide 65)
Appendix
Now we break the original “if . . . then” statement into two “if . . . then” statements
using w2 . That is
(a) If x1 < 10 then w1 = 0 and (b) If w1 = 0 then x2 = 0.
(a) can be modeled as
x1
w1 ≤ , (16)
10
and (b) can be modeled as
x2 ≤ 15w1 . (17)
Together, constraints (16) and (17) model the “If x1 < 10 then x2 = 0”.
© Milind G. Sohoni 65 / 67
Modeling Business Logic (slide 66)
Appendix
Now we break the original “if . . . then” statement into two “if . . . then” statements
using w2 . That is
(a) If x2 < 15 then w2 = 0 and (b) If w2 = 0 then x3 = 0.
(a) can be modeled as
x2
w2 ≤ , (18)
15
and (b) can be modeled as
x3 ≤ 25w2 . (19)
Together, constraints (18) and (19) model the “If x2 < 15 then x3 = 0”. Further,
notice that constraints (16), (17), (18) and (19) automatically imply that “If x1 < 10
then x3 = 0”.
© Milind G. Sohoni 66 / 67
Modeling Business Logic (slide 67)
Appendix
10w1 − x1 ≤ 0,
15w2 − x2 ≤ 0,
x2 − 15w1 ≤ 0,
x3 − 25w2 ≤ 0,
0 ≤ x1 ≤ 10, 0 ≤ x2 ≤ 15, 0 ≤ x3 ≤ 25,
w1 , w2 ∈ {0, 1}.
© Milind G. Sohoni 67 / 67