You are on page 1of 25

THE P-MEDIAN

PROBLEM

The P-median Problem


In the p-median problem we are interested in
finding the location of p facilities to serve demand
nodes so that the transportation cost is minimized.
The transportation cost is given by the product
of the demand at the demand node and the
distance between the demand node and the facility
that serves the demand node.

There are no capacity constraints at the


facilities.

The P-median Problem


15

10

15

12

22

18

E 5
25

12

20
F

24

15

11

30

16

19

25

22

J
22

19

24

12

12

16

24
18

18

22

13

19

K
19

21

L
20

The P-median Problem


Remarks
As there are no capacity constraints at the facilities,
it is optimal to satisfy the demand at a demand node
from a single facility.
An optimal solution can be found by restricting the
search to the demand nodes.

Fixed costs are assumed to be equal.


The number of possible solutions is

n!
p!n p !

The P-median Problem


For even moderate values of n and p the number of possible
solutions can be very large:
For example, if n=20 and p=5, there are 15,504 solutions.
If n=50 and p=10, the problem has more than 1010 possible
solutions.
If you could evaluate 1 million solutions per second, it will
take you 3 hours for total enumeration.

The P-median Problem


Inputs:
hi = demand at node i
dij = distance between demand node i and site j
p = number of facilities

Decision variables:
1 if a facility is located at site j
Xj
0 otherwise
1 if demand at node i is served by a facility at site j
Yij
0 otherwise

The P-median Problem


min

h d Y
Y 1
X p
i

subject to

ij

ij

ij

for all i

Yij X j
Yij 0,1
X j 0,1

for all i, j
for all i, j
for all j

The P-median Problem


Distance matrix for the network
Site j
Node i
A
B
C
D
E
F
G
H
I
J
K
L

A
0
15
37
55
24
60
18
33
48
40
58
67

B
15
0
22
40
38
52
33
48
42
55
61
61

C
37
22
0
18
16
30
41
28
20
58
39
39

D
55
40
18
0
34
12
59
46
24
62
43
34

E
24
38
16
34
0
36
25
12
24
47
37
43

F
60
52
30
12
36
0
57
42
12
50
31
22

G
18
33
41
59
25
57
0
15
45
22
40
61

H
33
48
28
46
12
42
15
0
30
37
25
46

I
48
42
20
24
24
12
45
30
0
38
19
19

J
40
55
58
62
47
50
22
37
38
0
19
40

K
58
61
39
43
37
31
40
25
19
19
0
21

L
67
61
39
34
43
22
61
46
19
40
21
0

The P-median Problem


Cost (demand x distance) matrix for the network
hi x dij
Demand
Node i
A
A
0
B
150
C
444
D
990
E
120
F
1440
G
198
H
528
I
624
J
880
K
1102
L
1340

Site j
B
225
0
264
720
190
1248
363
768
546
1210
1159
1220

C
555
220
0
324
80
720
451
448
260
1276
741
780

D
825
400
216
0
170
288
649
736
312
1364
817
680

E
360
380
192
612
0
864
275
192
312
1034
703
860

F
900
520
360
216
180
0
627
672
156
1100
589
440

G
270
330
492
1062
125
1368
0
240
585
484
760
1220

H
495
480
336
828
60
1008
165
0
390
814
475
920

I
720
420
240
432
120
288
495
480
0
836
361
380

J
600
550
696
1116
235
1200
242
592
494
0
361
800

K
870
610
468
774
185
744
440
400
247
418
0
420

L
1005
610
468
612
215
528
671
736
247
880
399
0

The P-median Problem


Heuristic Algorithm

The P-median Problem


A
B
C
D
E
F
G
H
I
J
K
L

A
0
150
444
990
120
1440
198
528
624
880
1102
1340

B
225
0
264
720
190
1248
363
768
546
1210
1159
1220

C
555
220
0
324
80
720
451
448
260
1276
741
780

D
825
400
216
0
170
288
649
736
312
1364
817
680

E
360
380
192
612
0
864
275
192
312
1034
703
860

F
900
520
360
216
180
0
627
672
156
1100
589
440

G
270
330
492
1062
125
1368
0
240
585
484
760
1220

H
495
480
336
828
60
1008
165
0
390
814
475
920

I
720
420
240
432
120
288
495
480
0
836
361
380

J
600
550
696
1116
235
1200
242
592
494
0
361
800

K
870
610
468
774
185
744
440
400
247
418
0
420

L
1005
610
468
612
215
528
671
736
247
880
399
0

Total

7816

7913

5855

6457

5784

5760

6936

5971

4772

6886

5576

6371

serving all the demand from a facility at A

The P-median Problem


If we locate only one facility, it should be at site I with a
total cost of 4772.
What if we want to open a second facility?
A
B
C
D
E
F
G
H
I
J
K
L

A
0
150
444
990
120
1440
198
528
624
880
1102
1340

B
225
0
264
720
190
1248
363
768
546
1210
1159
1230

...

I
720
420
240
432
120
288
495
480
0
836
361
380

A
B
C
D
E
F
G
H
I
J
K
L

A
0
150
240
432
120
288
198
480
0
836
361
380

B
225
0
240
432
120
288
363
480
0
836
361
380

The P-median Problem


A
B
C
D
E
F
G
H
I
J
K
L

A
0
150
240
432
120
288
198
480
0
836
361
380

B
225
0
240
432
120
288
363
480
0
836
361
380

C
555
220
0
324
80
288
451
448
0
836
361
380

D
720
400
216
0
120
288
495
480
0
836
361
380

E
360
380
192
432
0
288
275
192
0
836
361
380

F
720
420
240
216
120
0
495
480
0
836
361
380

G
270
330
240
432
120
288
0
240
0
484
361
380

H
495
420
240
432
60
288
165
0
0
814
361
380

I
720
420
240
432
120
288
495
480
0
836
361
380

J
600
420
240
432
120
288
242
480
0
0
361
380

K
720
420
240
432
120
288
440
400
0
418
0
380

L
720
420
240
432
120
288
495
480
0
836
361
0

Total

3485

3725

3943

4296

3696

4268

3145

3655

4772

3563

3858

4392

It is best to open the second facility at site G.

The P-median Problem


Results for first five locations (medians)
Location Number

1
2
3
4
5

Site

Total cost

I
G
F
J
A

4772
3145
2641
2157
1707

Now, given the location of five facilities, each demand node


should be assigned to the nearest facility.

The P-median Problem


Site j
Node i
A
B
C
D
E
F
G
H
I
J
K
L

A
0
15
37
55
24
60
18
33
48
40
58
67

B
15
0
22
40
38
52
33
48
42
55
61
61

Assign nodes

C
37
22
0
18
16
30
41
28
20
58
39
39

D
55
40
18
0
34
12
59
46
24
62
43
34

E
24
38
16
34
0
36
25
12
24
47
37
43

A, B, E*
D, F
G, H
C, I, K*, L
J

F
60
52
30
12
36
0
57
42
12
50
31
22

G
18
33
41
59
25
57
0
15
45
22
40
61

H
33
48
28
46
12
42
15
0
30
37
25
46

to facility

I
48
42
20
24
24
12
45
30
0
38
19
19

J
40
55
58
62
47
50
22
37
38
0
19
40

A
F
G
I
J

K
58
61
39
43
37
31
40
25
19
19
0
21

L
67
61
39
34
43
22
61
46
19
40
21
0

The P-median Problem


15

10

15

B
24

12

22

18

18

16
5

12

20

18

25

24
12

15

11

30

19

25

22
J
22

19

12

16

24

22

13

19
K
19

21

L
20

The P-median Problem


Note that the optimal solution had a total cost of 1444
whereas the heuristic solution provides a total cost of 1707.
This means that we can improve the solution obtained by
the heuristic. Therefore we apply an improvement
algorithm.
For each facility site, this algorithm identifies the set of
demand nodes that are served from the facility called as the
neighborhood.
Within each neighborhood, the optimal 1-median is found.

The P-median Problem

The P-median Problem


15

10

15

B
24

12

22

18

18

C
16

12

20

18

25

24
12

15

11

30

19

25
J
22

19

24

12

16

22
change=-75

22

13

19
K
19

21

L
20

The P-median Problem


15

10

15

12

22

18

18

16

24

12

20
5 E

18

25

24
12

15

11

30

change=-60

19

25

22
J
22

19

12

16

24

22

13

19
K
19

21

L
20

The P-median Problem


The new solution has a cost of 1707-135=1572.
Because of a limitation in this heuristic, some relocations
which are beneficial in a global (but not local or
neighborhood) sense are not considered.
This leads us to consider an exchange algorithm as an
improvement procedure.

The P-median Problem


15

10

15

12

22

18

18

16

24

12

20
18

25

24
12

15

11

30

19

25

22
J
22

19

12

16

24

22

13

19
K
19

21

L
20

The P-median Problem


Summary of Exchange Opportunities from Neighborhood
Search Solution (Facilities at sites A, F, H, I and J with a
total cost of 1572)
Remove

Replace
With

Total
Cost

Change

A
F
H
I
J

B
D
E
L
K

1647
1620
1689
1444
1629

75
48
117
-128
57

The P-median Problem


15

10

A*

15

12

22

18

18

16

24

12

20
18

25
12

30

15 H*

11

19

25
J*
22

19

12

16

22

F* 24

24

22

13

19
K
19

21

L*
20

The P-median Problem


Summary of Exchange Opportunities from Improved
Solution (Facilities at sites A, F, H, J and L with a total
cost of 1444)
Remove

Replace
With

Total
Cost

Change

A
F
H
J
L

B
D
E
K
K

1447
1487
1465
1501
1503

3
43
21
57
59

You might also like