Springer Nature is making SARS-CoV-2 and COVID-19 research free. View research | View latest news | Sign up for updates

A GPU-based genetic algorithm for the p-median problem


The p-median problem is a well-known NP-hard problem. Many heuristics have been proposed in the literature for this problem. In this paper, we exploit a GPGPU parallel computing platform to present a new genetic algorithm implemented in CUDA and based on a pseudo-Boolean formulation of the p-median problem. We have tested the effectiveness of our algorithm using a Tesla K40 (2880 CUDA cores) on 290 different benchmark instances obtained from OR-Library, discrete location problems benchmark library, and benchmarks introduced in recent publications. The algorithm succeeded in finding optimal solutions for all instances except for two OR-library instances, namely pmed 30 and pmed 40, where better than 99.9% approximations were obtained.

This is a preview of subscription content, log in to check access.

Fig. 1
Fig. 2
Fig. 3


  1. 1.

    We shall use distance and cost interchangeably.


  1. 1.

    Cuda-C Programming Guide. http://docs.nvidia.com/cuda/cuda-c-programming-guide

  2. 2.

    Discrete location problems benchmark library, the p-median problem. www.math.nsc.ru/AP/benchmarks/P-median

  3. 3.

    NVIDIA (2015) CURAND Library. Programming guide. PG-05328-050_v7.5. NVIDIA

  4. 4.

    AlBdaiwi BF, Ghosh D, Glodengorin B (2011) Data aggregation for p-median problems. J Comb Optim 21:348–363

  5. 5.

    AlBdaiwi BF, Goldengorin B, Sierksma G (2009) Equivalent instances of the simple plant location problem. Comput Math Appl 57(5):812–820

  6. 6.

    Alp O, Erkut E (2003) An efficient genetic algorithm for the p-median problem. Ann Oper Res 122:21–42

  7. 7.

    Bargos FF, de Queiroz Lamas W, Bargos DC, Neto MB, Pardal PCPM (2016) Location problem method applied to sugar and ethanol mills location optimization. Renew Sustain Energy Rev 65:274–282

  8. 8.

    Beasley JE, OR-Library. http://people.brunel.ac.uk/~mastjjb/jeb/orlib/pmedinfo.html

  9. 9.

    Biesinger B, Hu B, Raidl G (2015) A hybrid genetic algorithm with solution archive for the discrete (r|p)-centroid problem. J Heuristics 21(3):391–431

  10. 10.

    Bozkaya B, Zhang J, Erkut E (2002) An efficient genetic algorithm for the p-median problem. Facil Locat Appl Theory 29: 179–205

  11. 11.

    Daskin MS, Maass KL (2015) The p-median problem. In: Laporte G, Nickel S, da Gama FS (eds) Location science, chapter 2. Springer, Berlin, pp 21–45

  12. 12.

    Drezner Z, Brimberg J, Mladenović N, Salhi S (2015) New heuristic algorithms for solving the planar p-median problem. Comput Oper Res 62:296–304

  13. 13.

    El-Mihoub TA, Hopgood AA, Nolle L, Battersby A (2006) Hybrid genetic algorithms: a review. Eng Lett 13(2):124–137

  14. 14.

    Farahani RZ, Hekmatfar M, Arabani AB, Nikbakhsh E (2013) Hub location problems: a review of models, classification, solution techniques, and applications. Comput Ind Eng 64(4):1096–1109

  15. 15.

    Goldengorin B, Kocheturov A, Pardalos PM (2014) A Pseudo-Boolean approach to the market graph analysis by means of the p-median model. In: Clusters, orders, and trees: methods and applications. Springer, pp 77–89

  16. 16.

    Goldengorin B, Krushinsky D, Pardalos P (2013) Cell formation in industrial engineering, theory, algorithms and experiments. Springer, Berlin

  17. 17.

    Hall M, Knuth DE (1965) Combinatorial analysis and computers. Am Math Mon 72(2):21–28

  18. 18.

    Hammer PL (1968) Plant location-a pseudo-Boolean approach. Isr J Technol 6(5):330–332

  19. 19.

    HP Inc. (2015) QuickSpecs. HP Z820 workstation. c04111526-DA-14264-Worldwide-Version 48. HP Inc., USA

  20. 20.

    Jaillet P, Song G, Yu G (1996) Airline network design and hub location problems. Locat Sci 4(3):195–212

  21. 21.

    Jaramillo JH, Bhadury J, Batta R (2002) On the use of genetic algorithms to solve location problems. Comput Oper Res 29(6):761–779

  22. 22.

    Kang S, Kim S-S, Won J, Kang Y-M (2016) GPU-based parallel genetic approach to large-scale travelling salesman problem. J Super Comput. doi:10.1007/s11227-016-1748-1

  23. 23.

    Kariv O, Hakimi S (1979) An algorithmic approach to network location problems. II: The p-medians. SIAM J Appl Math 37(3):539–560

  24. 24.

    Kazakovtsev LA, Orlov V, Stupina AA, Kazakovtsev V (2015) Modified genetic algorithm with greedy heuristic for continuous and discrete p-median problems. Facta Univ Ser Math Inform 30(1):89–106

  25. 25.

    Laporte G, Nickel S, da Gama FS (2015) Location science. Springer, Berlin

  26. 26.

    Lim G, Ma L (2013) GPU-based parallel vertex substitution algorithm for the p-median problem. Comput Ind Eng 64(1):381–388

  27. 27.

    Ma L, Lim G (2011) GPU-based parallel computational algorithms for solving p-median problem. In: IIE Annual Conference. Proceedings. Institute of Industrial Engineers-Publisher, p 1

  28. 28.

    McCaffrey J (2004) Generating the mth lexicographical element of a mathematical combination. CTAN. http://msdn.microsoft.com/en-us/library/aa289166, July 2004

  29. 29.

    Mitchell M (1998) An introduction to genetic algorithms. MIT Press, Cambridge

  30. 30.

    Mladenović N, Brimberg J, Hansen P, Moreno-Pérez JA (2007) The p-median problem: a survey of metaheuristic approaches. Eur J Oper Res 179(3):927–939

  31. 31.

    NVIDIA (2013) Tesla K40 active accelerator. Board specification. BD-06949-001_v03. NVIDIA

  32. 32.

    Rebreyend P, Lemarchand L, Euler R (2015) A computational comparison of different algorithms for very large p-median problems. In: 15th European Conference on Evolutionary Computation in Combinatorial Optimization. Springer, pp 13–24

  33. 33.

    Reese J (2006) Solution methods for the p-median problem: an annotated bibliography. Networks 48(3):125–142

  34. 34.

    Ren Y, Awasthi A (2015) Investigating metaheuristics applications for capacitated location allocation problem on logistics networks. In: Chaos modeling and control systems design. Springer, pp 213–238

  35. 35.

    Resende MGC, Werneck RF (2004) A hybrid heuristic for thep-median problem. J Heuristics 10(1):59–88

  36. 36.

    Stanimirović Z (2012) A genetic algorithm approach for the capacitated single allocation p-hub median problem. Comput Inform 29(1):117–132

  37. 37.

    Todosijević R, Urošević D, Mladenović N, Hanafi S (2015) A general variable neighborhood search for solving the uncapacitated r-allocation p-hub median problem. Optim Lett 23: 1–13

Download references

Author information

Correspondence to Bader F. AlBdaiwi.

Rights and permissions

Reprints and Permissions

About this article

Verify currency and authenticity via CrossMark

Cite this article

AlBdaiwi, B.F., AboElFotoh, H.M.F. A GPU-based genetic algorithm for the p-median problem. J Supercomput 73, 4221–4244 (2017). https://doi.org/10.1007/s11227-017-2006-x

Download citation


  • P-median problem
  • NP-hard
  • CUDA
  • Pseudo-Boolean formulation
  • Genetic algorithms
  • Heuristics