You are on page 1of 22

CO327 Deterministic OR Models (2021-Spring)

p-median problem and introduction to mixed integer program

Instructor: Andersen Ang


Guest lecturer: Mariia Sobchuk msobchuk@uwaterloo.ca

Combinatorics and Optimization, U.Waterloo, Canada


msxang@uwaterloo.ca, where x = bπc
Homepage: angms.science

First draft: April 14, 2021 Last update: June 10, 2021
What is the p-median problem

I A facility location problem


I A mixed integer program
I some variables are real number
I some variables are integer

I A NP-hard problem: very difficult to solve efficiently for large problem size.

I What is the problem: determine where to place the facilities to minimize the total
transportation cost of serving all customers.
I Related to previous lectures :
I the lecture on “Tower defence”.
I the lecture on “Set covering, location decision and urban planning”.

2 / 22
Problem setting
I There are n customers who are geographically apart.

I We want to determine the locations of p number of facilities to serve these customers.

I Each facility is assumed to have infinite service capacity. That is, we can simply assign
each customer to exactly one facility. Our objective is to minimize the weighted sum of
transportation cost to serve all customers.

3 / 22
Problem setting

You are given

I I = {1, 2, . . . , m}, the set of candidate locations for facilities

I J = {1, 2, . . . , n}, the set of customer locations

I p, the number of facilities to introduce


m!
Choose p out of m: p!(m−p)! , NP-hard

I d1 , d2 , . . . , dj , the size of demand at customer j ∈ J

I cij , the transportation cost from facility location i ∈ I to the customer location j ∈ J

Model this problem as a Mixed Integer Program (MIP).

4 / 22
How to model: formulate the decision variables
I Identify the goal: “minimizing the total transportation cost from facility location i to the
customer location”
I There are TWO decisions:
I Which customer to go to WHICH facility
I HOW MUCH the demand of the customer is served by the facility.

I Propose TWO decision variables


I xij : the fraction of demand from customer j ∈ J being served by facility location i ∈ I.
I A continuous variable.
I Fraction: 0 ≤ xij ≤ 1
I Note: total number of demand of each customer is dj
I yi : location variable, yi = 1 if a facility is introduced at candidate location i ∈ I and yi = 0
otherwise.
I yi = {0, 1}
I Binary decision.

5 / 22
How to model: formulate the cost
I xij : the fraction of demand from customer j ∈ J being served by facility location i ∈ I

I cij : the unit transportation cost from facility location i ∈ I to the customer location
j∈J

I cij xij : the transportation cost from facility location i ∈ I to the customer location j ∈ J
for serving the fraction of demand

I dj , the size of demand at customer j ∈ J

I dj cij xij : the transportation cost from facility location i ∈ I to the customer location
j ∈ J for serving all the demand

I Total cost between all customer and all facility location on full demand
XX
dj cij xij
i∈I j∈J

6 / 22
How to model: formulate the constraints
I Demand served cannot be negative

xij ≥ 0 for all i ∈ I, j ∈ J

I All facilities together has to satisfy all the demand of customer j


X
xij = 1
i∈I

I There are totally p facilities X


yi = p.
i∈I

I x cannot over y (demand served ≤ supply limit)

xij ≤ yi

7 / 22
The p-median problem
XX
min dj cij xij
i∈I j∈J

s.t. xij ≥ 0 for all i ∈ I, j ∈ J


yi ∈ {0, 1} for all i
X
xij = 1 for all i ∈ I, j ∈ J
i∈I
X
yi = p
i∈I
xij ≤ yi for all i ∈ I, j ∈ J
A linear mixed integer program !
Q: what does the last constraint do?

8 / 22
The p-median problem: why not this formulation?

XX
min dj cij xij
i∈I j∈J

s.t. xij ≥ 0 for all i ∈ I, j ∈ J


yi ∈ {0, 1} for all i
X
xij = 1 for all i ∈ I, j ∈ J
i∈I
X
yi = p
i∈I
X
xij ≤ |J |yi for all i
j

9 / 22
Sample 2-median problem

min 100 · 20xαS + 200 · 10xαK + ...


s.t. xαS ≥ 0, xαK ≥ 0, ....
yα , yη , yγ ∈ {0, 1}
X
xij = 1 for all i ∈ I, j ∈ J
i∈I
yα + yη + yγ = 2
xαS ≤ yα , xαK ≤ yα , ...

10 / 22
Examples of other optimal solutions

11 / 22
Special case: the 1-median problem
XX
min dj cij xij
i∈I j∈J

s.t. xij ≥ 0 for all i ∈ I, j ∈ J


yi ∈ {0, 1} for all i
X
xij = 1 for all i ∈ I, j ∈ J
i∈I
X
yi = 1
i∈I
xij ≤ yi for all i ∈ I, j ∈ J
I p = 1: only one facility.
I Application of this model: solve location problem for things that at most 1 can be build
I Decide where to place the capital
I Decide where to live (in this case the “facility” is your home)
12 / 22
Some applications of p-median problem

I Decide where to live

I Facility location

I Clustering

I Telecommunication industry: antenna location setup

I Politics and government administration

I Vehicle routing

I Computer network

13 / 22
Problem twists (more in assignment 3)

I We assumed all facilities have infinite capacity.


What if this is not true? → capacited p-median problem

I What if each location can build more than one facility?

I What if a demand can only be serviced by one facility?


For example, you hate to go to a specific hospital.

I What if we want to minimize the “maximum distance between the customer and facility
instead”?

14 / 22
Capacitated p-median problem

I ui : the upper bound on the capacity that facility i can fulfill

I binary yj indicating if a facility is opened at location j ∈ J

I xij fraction of demand of customer j ∈ J served by facility i ∈ I

I cij , dj

15 / 22
How to modify out p-median problem?

I Each facility cannot serve above its capacity


X
dj xij ≤ ui yi
j∈J

16 / 22
The formulation of capacitated p-median problem

XX
min dj cij xij
i∈I j∈J

s.t. xij ≥ 0 for all i ∈ I, j ∈ J


yi ∈ {0, 1} for all i
X
xij = 1 for all i ∈ I, j ∈ J
i∈I
X
yi = p for all i
i∈I
X
dj xij ≤ uj yj for all i ∈ I, j ∈ J
j∈J

17 / 22
What variant of the problem does this program model?

XX
min dj cij xij
i∈I j∈J

s.t. xij ∈ {0, 1} for all i, j


yi ∈ {0, 1} for all i
X
xij = 1 for all i, j
i∈I
X
yi = p for all i
i∈I
X
dj xij ≤ uj yj for all i ∈ I, j ∈ J
j∈J

18 / 22
Binary capacitated p-median problem

I Demand of each customer must be served by a unique facility

I ui , xij , cij , dj

19 / 22
NP-hardness of the problem
I A problem is in NP if a solution is polynomial-time verifiable.

Problem is NP-hard if an algorithm for solving it can be used to solve any problem in NP with
at most polynomial overhead. 20 / 22
NP-complete dominating set problem

Problem is NP-complete it is in NP and any other prob-


lem in NP can be reduced to it in polynomial time.
The Dominating set problem: Given a graph G =
(V, E) and a positive integer 1 ≤ p ≤ |V (G)|, does there
exist a subset Vp∗ of p vertices, such that each vertex of
G is either in Vp∗ or is adjacent to a vertex in Vp∗ ?
[Garey and Johnson, 1979]: Let G be the graph that is
planar of maximum degree 3 and 1 < p < n. Finding if
there is a dominating-set of cardinally p is NP-complete.

21 / 22
Reduction of p-median problem to Dominating set problem

I p-median problem is NP-hard even when the graph is planar of maximum degree 3, with
all edges of weight 1 and all demands 1.
I Can show that on such graph a problem of determining if there exists a dominating set of
size p is polynomial time reducible to the problem of finding a p-median in G.
I There exists a dominating set of cardinality p in G if and only if the otimal solution to the
p-median problem gives objective value n − p.

22 / 22

You might also like