You are on page 1of 8

SENSITIVITY ANALYSIS FOR CAPACITATEDFACILITY LOCATION PROBLEM (CFL)

Sciences des données

Hiba EL HOUDI
Haitam Dhaibi
Basma BOUHOUAR
Hajar El MAATAOUI
CAPACITATED FACILITY LOCATION MODEL (CFL)

Consider a company with three potential sites for installing its warehouses and five
demand points to serve.
Which one(s) of the warehouses should be opened to minimize total fixed opening and
shipping costs such that the demands of all customers are assigned?
Assume that each site i has a yearly fixed cost fi =2000 and capacity=500.
Additionally, there is a transportation cost of 𝑐𝑖𝑗 per unit serviced from facility i to the
demand point j
The base data is given in the Table below.
Customer
1 2 3 4 5
(Demand node) j
Annual Demand j 80 270 250 160 180
Facility i
1 4 5 6 8 10
2 6 4 3 5 8
3 9 7 4 3 4

1. Formulation of the problem as a capacitated facility location model


(CFL)
An annual leasing expense that is incurred for using it, independently of the volume it
services. This volume is limited to a given maximum amount that may be handled yearly, Ai.
Define continuous variables xij≥0 as the amount serviced from facility i to demand point j.
Define binary variables yi =1 if a facility is established at location j, yi =0 otherwise.
Mathematical optimization model
3 5 3
Minimize ∑ fi yi+∑ ∑ cij xij
i=1 j=1 i=1

3
Subject to: ∑ xij = Dj for j= 1,2,3,4,5
i=1

∑ xij ≤ Ai yi for i = 1,2,3


j=1

xij ≤ Dj yi for i = 1,2,3 ; for i = 1,2,3


xij ≥ 0 for i = 1,2,3 ; for i = 1,2,3
yi ∈{0 ,1 } for i = 1,2,3

The objective of the problem is to total fixed opening and shipping costs such that the
demands of all customers are assigned.

The first constraints require that each customer’s demand must be satisfied
The capacity of each facility i is limited by the second constraints: if facility i is activated, its
capacity restriction is observed; if it is not activated, the demand satisfied by i is zero.
Third constraints provide variable upper bounds.

2. Coding the problem in PuLP-Python and solving it by calling an


appropriate solver
Code :
from pulp import *
import pandas as pd
from sensitivity import SensitivityAnalyzer

# Customers and Facilities


J = [1,2,3,4,5]
I = [1,2,3]

# Demands? facilities and fixed cost at each facility


D = {1 : 80, 2 : 270, 3 : 250, 4 : 160, 5 : 180}
A = {1 : 500, 2 : 500, 3 : 500}
f = {1 : 2000, 2 : 2000, 3 : 2000 }

# Transportation cost from each facility to all the customers


c = {1 : {1 : 4, 2 : 5, 3 : 6, 4 : 8, 5 : 10},
2 : {1 : 6, 2 : 4, 3 : 3, 4 : 5, 5 : 8},
3 : {1 : 9, 2 : 7, 3 : 4, 4 : 3, 5 : 4}
}

# Setting the Problem


prob = LpProblem("Capacitated_Facility_Location_Problem", LpMinimize)

# Desicion Variables
y = LpVariable.dicts("Use_Facility",I, 0, 1, LpBinary)
x = LpVariable.dicts("Service", [(i,j) for j in J for i in I], 0)
# Objective Function
prob += lpSum(f[i]*y[i] for i in I) + lpSum(c[i][j]*x[(i,j)] for i in I for j
in J)

# Costraints
for j in J:
prob += lpSum(x[(i,j)] for i in I) == D[j]

for i in I:
prob += lpSum(x[(i,j)] for j in J) <= A[i]*y[i]

for j in J:
for i in I:
prob += x[(i,j)] <= D[j]*y[i]

prob.solve()

print("Solution Status = ", LpStatus[prob.status])

# Establish Facility at site


Tolerance = 0.0001
for i in I:
if y[i].varValue > Tolerance:
print("Establish Facility at site = ", i)

# Solution of Continuous Decision Variables


for v in prob.variables():
print(v.name, "=", v.varValue)

# Total Cost
print("Total Cost = ", value(prob.objective))

3. Comment on the results


Results :
Solution Status = Optimal
Establish Facility at site = 2
Establish Facility at site = 3
Service_(1,_1) = 0.0
Total Cost = 7610.0
Service_(1,_2) = 0.0
Total Cost = 7610.0
Service_(1,_3) = 0.0
Total Cost = 7610.0
Service_(1,_4) = 0.0
Total Cost = 7610.0
Service_(1,_5) = 0.0
Total Cost = 7610.0
Service_(2,_1) = 80.0
Total Cost = 7610.0
Service_(2,_2) = 270.0
Total Cost = 7610.0
Service_(2,_3) = 150.0
Total Cost = 7610.0
Service_(2,_4) = 0.0
Total Cost = 7610.0
Service_(2,_5) = 0.0
Total Cost = 7610.0
Service_(3,_1) = 0.0
Total Cost = 7610.0
...
Use_Facility_2 = 1.0
Total Cost = 7610.0
Use_Facility_3 = 1.0
Total Cost = 7610.0

The optimal solution obtained suggests establishing the facilities at Sites 2 and 3 only.
This solution incurs minimum total cost of 7610 for servicing all the demands.

4. Sensitivity analysis
Code :
o = [{'Name':name,'Constraint':c,'shadow price':c.pi,'slack': c.slack,} for
name, c in prob.constraints.items()]

analysis = pd.DataFrame(o)

analysis

Results :

Nam shadow
Constraint slack
e price

-
{Service_(1,_1): 1, Service_(2,_1): 1,
0 _C1 7.0 0.000000e+
Service...
00

1 _C2 {Service_(1,_2): 1, Service_(2,_2): 1, 7.0 -


Service... 0.000000e+
Nam shadow
Constraint slack
e price

00

-
{Service_(1,_3): 1, Service_(2,_3): 1,
2 _C3 4.0 0.000000e+
Service...
00

-
{Service_(1,_4): 1, Service_(2,_4): 1,
3 _C4 3.0 0.000000e+
Service...
00

-
{Service_(1,_5): 1, Service_(2,_5): 1,
4 _C5 4.0 0.000000e+
Service...
00

-
{Service_(1,_1): 1, Service_(1,_2): 1,
5 _C6 -3.0 0.000000e+
Service...
00

-
{Service_(2,_1): 1, Service_(2,_2): 1,
6 _C7 -1.0 0.000000e+
Service...
00

{Service_(3,_1): 1, Service_(3,_2): 1, 6.000000e+


7 _C8 0.0
Service... 01

-
8 _C9 {Service_(1,_1): 1, Use_Facility_1: -80} 0.0 0.000000e+
00

-
9 _C10 {Service_(2,_1): 1, Use_Facility_2: -80} 0.0 0.000000e+
00

1 8.000000e+
_C11 {Service_(3,_1): 1, Use_Facility_3: -80} 0.0
0 01

-
1 {Service_(1,_2): 1, Use_Facility_1: -
_C12 0.0 0.000000e+
1 270}
00

1 _C13 {Service_(2,_2): 1, Use_Facility_2: - -2.0 -


Nam shadow
Constraint slack
e price

0.000000e+
2 270}
00

1 {Service_(3,_2): 1, Use_Facility_3: - 2.700000e+


_C14 0.0
3 270} 02

-
1 {Service_(1,_3): 1, Use_Facility_1: -
_C15 0.0 0.000000e+
4 250}
00

1 {Service_(2,_3): 1, Use_Facility_2: - 1.000000e+


_C16 0.0
5 250} 02

1 {Service_(3,_3): 1, Use_Facility_3: - 1.500000e+


_C17 0.0
6 250} 02

-
1 {Service_(1,_4): 1, Use_Facility_1: -
_C18 0.0 0.000000e+
7 160}
00

1 {Service_(2,_4): 1, Use_Facility_2: - 1.600000e+


_C19 0.0
8 160} 02

-
1 {Service_(3,_4): 1, Use_Facility_3: -
_C20 0.0 0.000000e+
9 160}
00

-
2 {Service_(1,_5): 1, Use_Facility_1: -
_C21 0.0 0.000000e+
0 180}
00

2 {Service_(2,_5): 1, Use_Facility_2: - 1.800000e+


_C22 0.0
1 180} 02

2 {Service_(3,_5): 1, Use_Facility_3: - -2.842171e-


_C23 0.0
2 180} 14

For C1,C2,C3,C4,C5,C6,C7 and C13 are with a non null values of shadow price ,there fore a
change in the right hand value of the constraint by an unit with increase or decrease the
objective with the shadow price value.
The slack value gives the range within any change on the right hand value of the constraint
will not affect the objective.

You might also like