0% found this document useful (0 votes)
49 views

Binary Variable Models

Uploaded by

ankita mazumdar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Binary Variable Models

Uploaded by

ankita mazumdar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 73

Modeling Business Logic (slide 1)

Modeling Business Logic: Using Binary Variables

Milind G. Sohoni

Operations Management
The Indian School of Business, Gachibowli, Hyderabad

© Milind G. Sohoni 1 / 67
Modeling Business Logic (slide 2)
Outline

Topics

Introduction to modeling with integer variables

Modeling logical constraints

Applications: A classification problem

Applications: Capacitated facility location problem

Applications: Modeling piecewise linear functions

Applications: Locating facilities to provide services

Appendix

© Milind G. Sohoni 2 / 67
Modeling Business Logic (slide 2)
Outline

Topics

Introduction to modeling with integer variables

Modeling logical constraints

Applications: A classification problem

Applications: Capacitated facility location problem

Applications: Modeling piecewise linear functions

Applications: Locating facilities to provide services

Appendix

© Milind G. Sohoni 2 / 67
Modeling Business Logic (slide 2)
Outline

Topics

Introduction to modeling with integer variables

Modeling logical constraints

Applications: A classification problem

Applications: Capacitated facility location problem

Applications: Modeling piecewise linear functions

Applications: Locating facilities to provide services

Appendix

© Milind G. Sohoni 2 / 67
Modeling Business Logic (slide 2)
Outline

Topics

Introduction to modeling with integer variables

Modeling logical constraints

Applications: A classification problem

Applications: Capacitated facility location problem

Applications: Modeling piecewise linear functions

Applications: Locating facilities to provide services

Appendix

© Milind G. Sohoni 2 / 67
Modeling Business Logic (slide 2)
Outline

Topics

Introduction to modeling with integer variables

Modeling logical constraints

Applications: A classification problem

Applications: Capacitated facility location problem

Applications: Modeling piecewise linear functions

Applications: Locating facilities to provide services

Appendix

© Milind G. Sohoni 2 / 67
Modeling Business Logic (slide 2)
Outline

Topics

Introduction to modeling with integer variables

Modeling logical constraints

Applications: A classification problem

Applications: Capacitated facility location problem

Applications: Modeling piecewise linear functions

Applications: Locating facilities to provide services

Appendix

© Milind G. Sohoni 2 / 67
Modeling Business Logic (slide 2)
Outline

Topics

Introduction to modeling with integer variables

Modeling logical constraints

Applications: A classification problem

Applications: Capacitated facility location problem

Applications: Modeling piecewise linear functions

Applications: Locating facilities to provide services

Appendix

© Milind G. Sohoni 2 / 67
Modeling Business Logic (slide 3)
Introduction to modeling with integer variables

Integer/Binary models: A brief introduction

© Milind G. Sohoni 3 / 67
Modeling Business Logic (slide 4)
Introduction to modeling with integer variables

Why integer programming?

Advantages of restricting variables to take on integer values:


1. More realistic (economic indivisibility).
2. More flexibility (use of binary variables, logical constraints).

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

Binary integer variables


Binary integer variables can take values of 0 or 1. Typically, a decision
variable, say xj , which is binary is represented in a formulation in any one
of the following ways:
I xj ∈ {0, 1}, or
I 0 ≤ xj ≤ 1 and integer.

Binary variables are very useful in modeling several business situations.


Particularly,
I Logical constraints, e.g., if-then-else, go-no/go decisions,
I Application areas include supply-chain optimization models (for
example, transportation, facility location), financial models (for
example, budget models, auctions), marketing models (for example,
consumer choice), and many more.

© Milind G. Sohoni 5 / 67
Modeling Business Logic (slide 6)
Introduction to modeling with integer variables

The integer programming (IP) mystery

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

Why are IPs sometimes extremely hard to solve?

© Milind G. Sohoni 7 / 67
Modeling Business Logic (slide 8)
Introduction to modeling with integer variables

Representing an integer program (2-D problem)

Consider the following example:

(P) max 3x1 + 4x2


s.t. 5x1 + 8x2 ≤ 24,
x1 , x2 ≥ 0 and integer.

What is the optimal solution this problem?

© Milind G. Sohoni 8 / 67
Modeling Business Logic (slide 9)
Introduction to modeling with integer variables

Representation of the feasible region


4

5 x1 + 8 x2 ‡ 24
x2

0
0 1 2 3 4 5

x1

Figure: Integer feasible region for (P).

© Milind G. Sohoni 9 / 67
Modeling Business Logic (slide 10)
Introduction to modeling with integer variables

Finding the optimal solution via LP relaxation


4

5 x1 + 8 x2 ‡ 24
x2

LP optimal = 4.8
0
0 1 2 3 4 5

x1

Figure: LP solution to (P) – It’s not integral valued.

© Milind G. Sohoni 10 / 67
Modeling Business Logic (slide 11)
Introduction to modeling with integer variables

Truncating and rounding-up may not help


4 4

3 3

5 x1 + 8 x2 ‡ 24 5 x1 + 8 x2 ‡ 24
x2

x2
2 2

1 1

Truncation, not optimal! HObj = 12L Round up infeasible! HObj = 15L


0 0
0 1 2 3 4 5 0 1 2 3 4 5

x1 x1

(a) Truncating (not optimal). (b) Rounding-up (infeasible).

Figure: Finding an integer solution by truncating or rounding-up a LP solution


may not work.

© Milind G. Sohoni 11 / 67
Modeling Business Logic (slide 12)
Introduction to modeling with integer variables

Finding the optimal solution via LP relaxation


4

Same solution! HObj = 12L


3

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

The IP optimal solution


4

x2 5 x1 + 8 x2 ‡ 24
2

Optimal solution! HObj = 13L


1

0
0 1 2 3 4 5

x1

Figure: Unfortunately, the IP optimal solution is not at a “corner” point of the


original LP feasible region. It is much harder to find.

© Milind G. Sohoni 13 / 67
Modeling Business Logic (slide 14)
Modeling logical constraints

Representing logical conditions in optimization


models

© Milind G. Sohoni 14 / 67
Modeling Business Logic (slide 15)
Modeling logical constraints

Simple logical conditions

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

Simple logical conditions


Let us consider the potential logical conditions linking H and M, their
binary representations, and the corresponding constraints.

Logical condition Logical constraint How/Why does the constraint


work?
Notice both the binary decision
The firm must locate at variables are forced to take a value
x1 + x2 = 2
H and M. of 1, implying both locations will be
chosen.
Notice at least one of the binary
The firm must locate at
decision variables is forced to take a
least at one of the x1 + x2 ≥ 1
value of 1, implying either H, or M,
locations (or).
or both are chosen.

The firm must not


x1 = 0 H will never be chosen.
locate at H.

© Milind G. Sohoni 16 / 67
Modeling Business Logic (slide 17)
Modeling logical constraints

Simple logical conditions


Let us consider the potential logical conditions linking H and M, their
binary representations, and the corresponding constraints.
Logical condition Logical constraint How/Why does the constraint
work?
The only way to satisfy the
Choose exactly one constraint is if one of the
option between H and x1 + x2 = 1 variables equals 1 and the other
M (xor). is 0. Implying either we locate
of H or at M, but not both.
If x1 = 1, i.e., H is chosen, then
the constraint forces x2 to also
If the firm locates at H take a value of 1, implying the
then it must locate at x1 ≤ x2 firm must locate at M too.
M (implication). However, if x1 = 0 then the
constraint does not impose any
condition on x2 .

© Milind G. Sohoni 17 / 67
Modeling Business Logic (slide 18)
Modeling logical constraints

Simple logical conditions

Let us consider the potential logical conditions linking H and M, their


binary representations, and the corresponding constraints.
Logical condition Logical constraint How/Why does the constraint
work?
If H is not chosen, i.e., x1 = 0
then the constraint forces
Whatever is done at H
x2 = 0, i.e., M is not chosen
must be done at M x1 = x2
either. Similarly, if H is chosen
(equivalence).
then the constraint forces M to
be chosen too.

© Milind G. Sohoni 18 / 67
Modeling Business Logic (slide 19)
Modeling logical constraints

An example

Consider the following problem. StockCo is considering investing in


possible 6 stocks. The cash required for each investment, as well as the
NPV of the investment, is given in the table below. The cash available
for the investments is $14,000. Stockco wants to maximize its NPV.
What is the optimal strategy? Note that, an investment can be selected
or not, i.e., one cannot select a fraction of an investment.

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

The Stockco example


Let us define a binary decision variable xi that denotes if Stockco invests
in stock i or not. That is,
(
1 : if Stockco invests in stock i,
xi =
0 : otherwise.

Stockco’s optimization problem, of maximizing the NPV subject to a


budget constraint, can be written as follows:

max 16x1 + 22x2 + 12x3 + 8x4 + 11x5 + 19x6


s.t. 5x1 + 7x2 + 4x3 + 3x4 + 4x5 + 6x6 ≤ 14, (Budget constraint)
x1 , x2 , . . . , x6 ∈ {0, 1} .

© Milind G. Sohoni 20 / 67
Modeling Business Logic (slide 21)
Modeling logical constraints

The Stockco example

Develop the following constraints:

1. Exactly 3 stocks are selected.


2. If stock 2 is selected, then so is stock 1.
3. If stock 1 is selected, then stock 3 is not selected.
4. Either stock 4 is selected or stock 5 is selected, but not both.

© Milind G. Sohoni 21 / 67
Modeling Business Logic (slide 22)
Modeling logical constraints

Geometric representation of the 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

Geometric representation of the cuts


1.0

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

Extending our understanding of building logical constraints


Let us go back to our earlier example of building simple logical
constraints (the warehouse location constraints). Suppose there are more
than 2 locations and we represent the decision of locating a warehouse at
location i with a binary variable xi . Consider the following logical
business conditions.

Logical condition Logical constraint


At least k warehouses must be built ?
Must build warehouse 3 if both 1 and 2 are built ?
Must build warehouse 3 if either 1 or 2 is built ?
Must build 3 if either 1 or 2 is built but not both ?
Cannot build warehouse 3 if both 1 and 2 are built ?

© Milind G. Sohoni 24 / 67
Modeling Business Logic (slide 25)
Applications: A classification problem

Classifying objects based on information revealed

© Milind G. Sohoni 25 / 67
Modeling Business Logic (slide 26)
Applications: A classification problem

Knights, knaves, and werewolves


The information we have:

I Knights always tell the truth and knaves always lie


I Of the three inhabitants you interview, exactly one of them is a
werewolf.
I Each of three inhabitants interviewed is either a knight or a knave,
and could be a werewolf too.

The statements made:


A: I am a werewolf.
B: I am a werewolf.
C: At most one of us is a knight.

© Milind G. Sohoni 26 / 67
Modeling Business Logic (slide 27)
Applications: A classification problem

Knights, knaves, and werewolves

I What are our decision variables?


I How many decision variables do we have?

I What are the constraints?

I What is the objective?


I More importantly, when can we guarantee that a person is not a
werewolf?

© Milind G. Sohoni 27 / 67
Modeling Business Logic (slide 28)
Applications: Capacitated facility location problem

Capacitated facility location problem

© Milind G. Sohoni 28 / 67
Modeling Business Logic (slide 29)
Applications: Capacitated facility location problem

The capacitated facility location problem


I This problem is a frequently encountered problem in supply chain
management while designing “facility networks”.
I Some times it is also referred to as the “fixed charge problem”.
I Instances of the fixed charge problem are seen in several applications
including product line selection, portfolio design, and others.

I Let us consider the same set up we discussed earlier while studying


the transportation model. However, now we have an additional
challenge:
I It costs us to keep a supply (production) facility open. This cost is
independent of the the demand that will be served from the supply
facility – hence it is a fixed cost. Of course, we can only serve any
demand from a supply location if it is open, else we neither incur the
fixed cost nor any operating costs.

© 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 ($)

City ↓ Atlanta Boston Chicago Denver Omaha Portland (000’s) ↓ (000’s) ↓

(A) (B) (C) (D) (O) (P)

Baltimore (L) 1675 400 685 1630 1160 2800 18 7650

Cheyenne (H) 1460 1940 970 100 495 1200 24 3500

Salt Lake (S) 1925 2400 1425 500 950 800 27 5000

Memphis (M) 380 1355 543 1045 665 2321 22 4100

Wichita (W) 922 1646 700 508 311 1797 31 2200

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

The capacitated facility location model formulation

I What are our decision variables?


I How many decision variables do we have?
I What is the type of each decision variable?

I What are the constraints?

I What is the objective?

© Milind G. Sohoni 31 / 67
Modeling Business Logic (slide 32)
Applications: Capacitated facility location problem

The decision variables


Decision variables:
Let i represent the i th supply location. That is i = L, H, S, M, W . Similarly, let j
represent the j th demand destination, i.e., j = A, B, C , D, O, P. There are two types of
decisions:
1. Whether to keep facility i open or not. This by definition is binary. Since we
have 5 supply locations, we have 5 such binary decision variables. Let us denote,
of each i = L, H, S, M, W

1 : if facility i is kept open,
yi =
0 : otherwise.

as the binary decision variable.


2. How much to supply from supply location i to demand center j. Just as in the
transportation problem we studied earlier, we have 5 × 6 = 30 such decision
variables. They are of the continuous type. Let us denote
xij = The amount shipped from supply location
i to demand center j,
for each combination of i, j.

© 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,

xLA + xHA + xSA + xMA + xWA ≥ 10, (1)


xLB + xHB + xSB + xMB + xWB ≥ 8,
xLC + xHC + xSC + xMC + xWC ≥ 14,
xLD + xHD + xSD + xMD + xWD ≥ 6,
xLO + xHO + xSO + xMO + xWO ≥ 7,
xLP + xHP + xSP + xMP + xWP ≥ 11.

© 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

xLA + xLB + xLC + xLD + xLO + xLP ≤ 18 yL , (2)


xHA + xHB + xHC + xHD + xHO + xHP ≤ 24 yH ,
xSA + xSB + xSC + xSD + xSO + xSP ≤ 27 yS ,
xMA + xMB + xMC + xMD + xMO + xMP ≤ 22 yM ,
xWA + xWB + xWC + xWD + xWO + xWP ≤ 31 yW .

© Milind G. Sohoni 34 / 67
Modeling Business Logic (slide 35)
Applications: Capacitated facility location problem

Constraints

Non negativity and binary variable constraints:


To ensure that we only ship non-negative amounts we impose the
non-negativity constraints on the xij variables, i.e.,

xij ≥ 0 for all i = L, H, S, M, W and j = A, B, C , D, O, P. (3)

Additionally, we need to impose that

yi ∈ {0, 1} for all i = L, H, S, M, W , (4)

to model our open/closure decisions.

© Milind G. Sohoni 35 / 67
Modeling Business Logic (slide 36)
Applications: Capacitated facility location problem

The objective function


The objective function:
The goal is to minimize total cost. Notice it is combination of the fixed cost incurred
by keeping a supply locations open and the operating cost of meeting the demand of
the demand centers from the supply locations that are open.
Operating costs:
Operating costs = (the cost per unit of shipping from i to j)× (number of units
shipped from i to j), summed over all 30 combinations of i, i = L, H, S, M, W and j,
j = A, B, C , D, O, P. That is,
XX
Operating cost = cij xij = 1675xLA + · · · + 3800xLP
i j

+ 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

The capacitated facility location model (CFLM)

The entire CFLM model can now be written as


X XX
(CFLM) min fi yi + cij xij
i i j

subject to constraint sets (1), (2), (3), and (4).

© 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

Atlanta Boston Chicago Denver Omaha Portland Open/


(A) (B) (C) (D) (O) (P) Closed
Baltimore (L) 0 8 2 0 0 0 1
Cheyenne (H) 0 0 0 6 7 11 1
Salt Lake (S) 0 0 0 0 0 0 0
Memphis (M) 10 0 12 0 0 0 1
Wichita (W) 0 0 0 0 0 0 0
Demand (000's) 10 8 14 6 7 11

Total cost (000's $) 47,401.0

© Milind G. Sohoni 38 / 67
Modeling Business Logic (slide 39)
Applications: Capacitated facility location problem

The single sourcing formulation


Suppose we want to model a single sourcing solution, i.e., when a
demand center can receive its shipment only from one single supply
location. However a supply location can ship to multiple demand
locations, as long as it ships the entire demand of a demand center.
I How do our decision variables change?
I Notice we no longer must decide how much to ship from i to j
because if we ship, we must ship the entire demand Dj at j. So our
transportation decision change to if we ship or not (binary in nature).

I
I How do the constraints change?

I And, the objective?

© Milind G. Sohoni 39 / 67
Modeling Business Logic (slide 40)
Applications: Capacitated facility location problem

The single sourcing formulation


Decision variables:
Shipping decisions: In this case the variables xij are re-defined as follows:
(
1 : if supply location i ships to demand location j,
xij =
0 : otherwise.

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

The single sourcing constraints


Demand constraints:
Given the redefined variables xij we now define the demand constraints as
follows. Every demand center
X must source its demand from exactly one
supply location, that is xij = 1 for all j = A, B, C , D, O, P.
i
Specifically,

xLA + xHA + xSA + xMA + xWA = 1, (5)


xLB + xHB + xSB + xMB + xWB = 1,
xLC + xHC + xSC + xMC + xWC = 1,
xLD + xHD + xSD + xMD + xWD = 1,
xLO + xHO + xSO + xMO + xWO = 1,
xLP + xHP + xSP + xMP + xWP = 1.

© Milind G. Sohoni 41 / 67
Modeling Business Logic (slide 42)
Applications: Capacitated facility location problem

The single sourcing constraints


Supply constraints:
Given theXredefined variables xij we now define the supply constraints as
follows. Dj xij ≤ Si × yi for all i = L, H, S, M, W . Specifically,
j

10xLA + 8xLB + 14xLC + 6xLD + 7xLO + 11xLP ≤ 18 yL , (6)


10xHA + 8xHB + 14xHC + 6xHD + 7xHO + 11xHP ≤ 24 yH ,
10xSA + 8xSB + 14xSC + 6xSD + 7xSO + 11xSP ≤ 27 yS ,
10xMA + 8xMB + 14xMC + 6xMD + 7xMO + 11xMP ≤ 22 yM ,
10xWA + 8xWB + 14xWC + 6xWD + 7xWO + 11xWP ≤ 31 yW .

© Milind G. Sohoni 42 / 67
Modeling Business Logic (slide 43)
Applications: Capacitated facility location problem

Constraints

The binary variable constraints:


We need to impose the following constraints to model our binary choices.

yi ∈ {0, 1} for all i = L, H, S, M, W , (7)


xij ∈ {0, 1} for all i = L, H, S, M, W , and j = A, B, C , D, O, P.

© Milind G. Sohoni 43 / 67
Modeling Business Logic (slide 44)
Applications: Capacitated facility location problem

The objective function


The objective function:
Just as before the goal is to minimize total cost. Notice it is combination of the fixed
cost incurred by keeping a supply locations open and the operating cost of meeting
the demand of the demand centers from the supply locations that are open.
Operating and fixed costs:
Operating costs = (Demand at j)× (the cost per unit of shipping from i to j)× (if i
ships to j), summed over all 30 combinations of i, i = L, H, S, M, W and j,
j = A, B, C , D, O, P. That is,
X X
Operating cost = Dj (cij xij ) = 10 × (1675xLA + 1460xHA + · · · + 922xWA )
j i

+ 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

The single sourcing capacitated facility location model


(CFLM-SS)

The entire CFLM model can now be written as


X X X
(CFLM-SS) min fi yi + Dj (cij xij )
i j i

subject to constraint sets (5), (6), and (7).

© Milind G. Sohoni 45 / 67
Modeling Business Logic (slide 46)
Applications: Capacitated facility location problem

Single sourcing solver solution


Atlanta Boston Chicago Denver Omaha Portland Supply Fixed cost
(A) (B) (C) (D) (O) (P) (000's) (000's)
Baltimore (L) 1,675 400 685 1,630 1,160 3,800 18 7650
Cheyenne (H) 1,460 1,940 970 100 495 1,200 24 3500
Salt Lake (S) 1,925 2,400 1,425 500 950 800 27 5000
Memphis (M) 380 1,355 543 1,045 665 2,321 22 4100
Wichita (W) 922 1,646 700 508 311 1,797 31 2200
Demand (000's) 10 8 14 6 7 11

Atlanta Boston Chicago Denver Omaha Portland Open/ Supply


(A) (B) (C) (D) (O) (P) Closed (000's)
Baltimore (L) 0 0 0 0 0 0 0 0
Cheyenne (H) 0 0 0 0 0 0 0 0
Salt Lake (S) 0 0 0 1 0 1 1 17
Memphis (M) 1 1 0 0 0 0 1 18
Wichita (W) 0 0 1 0 1 0 1 21
Demand (000's) 1 1 1 1 1 1
LHS Demand Ctr 1 1 1 1 1 1
RHS Demand Ctr 1 1 1 1 1 1

Total cost (000's $) 49,717.0

© Milind G. Sohoni 46 / 67
Modeling Business Logic (slide 47)
Applications: Modeling piecewise linear functions

Piecewise linear functions

© Milind G. Sohoni 47 / 67
Modeling Business Logic (slide 48)
Applications: Modeling piecewise linear functions

Modeling piecewise linear functions


Our goal is to build a simple costing model, using a set of linear
constraints, that computes the cost of a commodity exactly. Suppose, we
want to procure k units of the commodity and the marginal cost of
procurement is as follows:


|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.

We can procure at most 50 units. For example, if we procure k = 12


units of the commodity, the total cost would evaluate to

c(12) = (2, 000 × 10) + (1, 800 × 2)


= 20, 000 + 3, 600
= 23, 600.

© Milind G. Sohoni 48 / 67
Modeling Business Logic (slide 49)
Applications: Modeling piecewise linear functions

The marginal cost curve


cHkL

80 000

60 000

40 000

20 000

10 25 50
k
10 20 30 40 50

Our goal is to write a set of constraints that models the following


non-linear cost function
c(k) = 2000 min {k, 10}+1800 min {max {k − 10, 0} , 15}+1700 min {max {k − 25, 0} , 25} ,
where
k = x1 + x2 + x3
and x1 , x2 , and x3 are the number of units we procure at the three
marginal costs of 2000, 1800, and 1700 respectively.
© Milind G. Sohoni 49 / 67
Modeling Business Logic (slide 50)
Applications: Modeling piecewise linear functions

Constraints

Let x1 , x2 , and x3 be our decision variables, i.e., the number of units of


the commodity we procure at 2000, 1800, and 1700 respectively. Clearly,
we must have

0 ≤ x1 ≤ 10, 0 ≤ x2 ≤ 15, 0 ≤ x3 ≤ 25.

Now we wish to model the following statements:


1. If x1 < 10 then x2 = 0, and
2. If x2 < 15 then x3 = 0.

How should we model these statements?

© Milind G. Sohoni 50 / 67
Modeling Business Logic (slide 51)
Applications: Locating facilities to provide services

Set covering formulation

© Milind G. Sohoni 51 / 67
Modeling Business Logic (slide 52)
Applications: Locating facilities to provide services

Where to locate fire stations?


To illustrate this model, consider the following location problem: A city is
reviewing the location of its fire stations. The city is made up of a
number of neighborhoods, as illustrated in the figure below.

© Milind G. Sohoni 52 / 67
Modeling Business Logic (slide 53)
Applications: Locating facilities to provide services

Where to locate fire stations?

A fire station can be placed in any neighborhood. It is able to service


both its neighborhood and any adjacent neighborhood (any
neighborhood with a non-zero border with its home neighborhood). The
objective is to minimize the number of fire stations used.
I What are the decision variables?
I How many such decision variables?
I What are our constraints?
I What is the objective function?

Can you think of applications of this model in other settings?

© Milind G. Sohoni 53 / 67
Modeling Business Logic (slide 54)
Applications: Locating facilities to provide services

Decision variables and cover constraints


Decision variables:
Let i denote a city neighborhood. There are 11 such neighborhoods, that is,
i = 1, 2, . . . , 11. We define a binary variable as follows:

1 : if we locate a fire station in neighborhood i,
xi =
0 : otherwise.
Clearly, there are 11 such binary decision variables.
Constraints:
Notice that if we locate a fire station in neighborhood i not only does it service
neighborhood i, but it also services all neighborhoods that are “adjacent” (share a
common boundary) with i. For example, consider neighborhood i = 1. Its adjacent
neighborhoods are 2, 3, and 4. Similarly, the adjacent neighborhoods of i = 2 are 1, 3,
and 5. Let Ni denote the set of adjacent neighborhoods of i including itself. For
example, N1 = {1, 2, 3, 4} and N2 = {1, 2, 3, 5}. Clearly there are 11 such sets,
N1 ,. . ., N11 . We need to ensure that at least one neighborhood is chosen from every
such set to ensure that those adjacent neighborhoods (the ones in every set) are
covered (serviced). That is
X
xj ≥ 1 for each i = 1, . . . , 11.
j∈Ni

These constraints are called cover constraints.


© Milind G. Sohoni 54 / 67
Modeling Business Logic (slide 55)
Applications: Locating facilities to provide services

Objective and formulation


The objective is to minimize the number of fire stations located given by
11
X
xi .
i=1

Specifically, we can write these constraints as


min x1 +x2 +x3 +x4 +x5 +x6 +x7 +x8 +x9 +x10 +x11
s.t. x1 +x2 +x3 +x4 ≥1
2: x1 +x2 +x3 +x5 ≥1
3: x1 +x2 +x3 +x4 +x5 +x6 ≥1
4: x1 +x3 +x4 +x6 +x7 ≥1
5: x2 +x3 +x5 +x6 +x8 +x9 ≥1
6: x3 +x4 +x5 +x6 +x7 +x8 ≥1
7: x4 +x6 +x7 +x8 ≥1
8: x5 +x6 +x7 +x8 +x9 +x10 ≥1
9: x5 +x8 +x9 +x10 +x11 ≥1
10 : x8 +x9 +x10 +x11 ≥1
11 : x9 +x10 +x11 ≥1
xi ∈ {0, 1} for all i = 1, . . . , 11.

© Milind G. Sohoni 55 / 67
Modeling Business Logic (slide 56)
Applications: Locating facilities to provide services

Objective and formulation

One optimal solution to this problem is x3 = x8 = x9 = 1 and the rest


equal to 0.

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

Stockco logical constraints

Logical condition Logical constraint


6
X
Exactly 3 stocks are selected xi = 3
i=1
If stock 2 is selected, then so is stock 1 x2 ≤ x1
If stock 1 is selected then stock 3 is not selected x1 + x3 ≤ 1
Either stock 4 is selected or stock 5, but not both x4 + x5 = 1

© Milind G. Sohoni 58 / 67
Modeling Business Logic (slide 59)
Appendix

Extending our understanding of building logical constraints


Going back to the warehouse location problem discussed during building
simple logical constraints. Suppose there are more than 2 locations and
we represent the decision of locating a warehouse at location i with a
binary variable xi . Consider the following logical business conditions.

Logical condition Logical constraint


n
X
At least k warehouses must be built xi ≥ k
i=1
Must build warehouse 3 if both 1 and 2 are built x1 + x2 ≤ 1 + x3
Must build warehouse 3 if either 1 or 2 is built x1 ≤ x3 and x2 ≤ x3
Must build 3 if either 1 or 2 is built but not both x1 + x3 ≥ x2 and x2 + x3 ≥ x1
Cannot build warehouse 3 if both 1 and 2 are built x1 + x2 ≤ 2 − x3

© Milind G. Sohoni 59 / 67
Modeling Business Logic (slide 60)
Appendix

Knights, knaves, and werewolves formulation


Decision variables:
Let i index over the three inhabitants (basically, represent the i th
inhabitant) who were interviewed, i.e., i = A, B, C . Let us define our
binary decision variables as follows:
 
1 : if inhabitant i is a knight, 1 : if inhabitant i is a werewolf,
xi = yi =
0 : if inhabitant i is a knave. 0 : if inhabitant i is not a werewolf.

There are 6 binary decision variables, i.e., xA , xB , xC and yA , yB , yC .


Constraints:
Inhabitant A said “I am werewolf”. If A is a knight, the statement made
must be true. In “English” this implies

If xA = 1 then yA = 1, else if xA = 0 then yA = 0.

Notice this is an “equivalence” relationship between xA and yA . Thus,


the constraint we develop is

xA = yA or xA − yA = 0. (8)

© Milind G. Sohoni 60 / 67
Modeling Business Logic (slide 61)
Appendix

Knights, knaves, and werewolves formulation


Constraints:
A similar argument can be made for inhabitant B. The corresponding
constraint is
xB − yB = 0. (9)
Inhabitant C says “At most one of us is a knight”. This can be expressed
as
xA + xB + xC ≤ 1.
Now, to develop our constraints, let us express the constraint in
“English”. If C is a knight, then the statement he made must be true,
i.e., if xC = 1 then xA + xB + xC ≤ 1. Equivalently,
If xC = 1 then xA + xB ≤ 0. (10)
Of course, if xC = 0 then the statement is false, which can be expressed
as if xC = 0 then xA + xB + xC > 1. Which further implies, if xC = 0
then xA + xB ≥ 2 (because of the “strict” inequality). Equivalently,
If xC = 0 then xA + xB ≥ 2. (11)
© Milind G. Sohoni 61 / 67
Modeling Business Logic (slide 62)
Appendix

Knights, knaves, and werewolves formulation


Constraints:
The constraints that model statements (10) and (11) respectively, can be
written as follows:
xA + xB ≤ 2 (1 − xC )or xA + xB + 2xC ≤ 2, (12)
xA + xB ≥ 2 (1 − xC )or xA + xB + 2xC ≥ 2. (13)
It is important to realize that when the condition in (10) does not hold,
i.e. xC 6= 1, then constraint (12) is true trivially, i.e. it becomes
redundant. That’s because, xA and xB are binary variables and their sum
can never exceed 2. This is important to note while developing
constraints for such “if ... then ...” type of statements. Similarly (13) is
redundant when the condition in (11) doesn’t hold (xC 6= 0). Both these
constraints in tandem model C ’s statement.
An astute reader will observe that constraints (12) and (13) together
imply
xA + xB + 2xC = 2. (14)

© Milind G. Sohoni 62 / 67
Modeling Business Logic (slide 63)
Appendix

Knights, knaves, and werewolves formulation


Constraints:
What is also known is that exactly one of A, B, and C is a werewolf.
This constraint can be modeled as
yA + yB + yC = 1. (15)
Objective function:
Notice that all we need is a classification – which is given by the
feasible region (defined by the constraints). We can use any
objective. However, for example if we wanted find if there was a
classification in which inhabitant A was a werewolf we could use
max yA ,
as an objective.
On the other hand, if we wanted to find if there existed a classification
where A is a knight, we could use
max xA .

© Milind G. Sohoni 63 / 67
Modeling Business Logic (slide 64)
Appendix

Knights, knaves, and werewolves formulation


The binary variable formulation:

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} .

Notice that, if at optimality yA? = 0, then we are guaranteed that there is


no classification (with the current set of information that we have) in
which A can be a werewolf. You can befriend him if you are confident
about the information you have!

© Milind G. Sohoni 64 / 67
Modeling Business Logic (slide 65)
Appendix

Constraints for piecewise linear functions


We know
0 ≤ x1 ≤ 10, 0 ≤ x2 ≤ 15, 0 ≤ x3 ≤ 25.
To model “If x1 < 10 then x2 = 0” let us define a binary variable w1 such that

0 : if x1 < 10,
w1 =
0/1 : otherwise.

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

Constraints for piecewise linear functions


We know
0 ≤ x1 ≤ 10, 0 ≤ x2 ≤ 15, 0 ≤ x3 ≤ 25.
To model “If x2 < 15 then x3 = 0” let us define a binary variable w2 such that

0 : if x2 < 15,
w2 =
0/1 : otherwise.

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

Modeling piecewise linear concave functions

The linear costing constraints can be written as follows:

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}.

The cost of k = x1 + x2 + x3 commodity units can then be computed as

2000x1 + 1800x2 + 1700x3 .

© Milind G. Sohoni 67 / 67

You might also like