, Volume 80, Issue 1, pp 155–184 | Cite as

Colored Bin Packing: Online Algorithms and Lower Bounds

  • Martin Böhm
  • György Dósa
  • Leah Epstein
  • Jiří Sgall
  • Pavel VeselýEmail author


In the Colored Bin Packing problem a sequence of items of sizes up to 1 arrives to be packed into bins of unit capacity. Each item has one of at least two colors and an additional constraint is that we cannot pack two items of the same color next to each other in the same bin. The objective is to minimize the number of bins. In the important special case when all items have size zero, we characterize the optimal value to be equal to color discrepancy. As our main result, we give an (asymptotically) 1.5-competitive algorithm which is optimal. In fact, the algorithm always uses at most \(\lceil 1.5\cdot OPT \rceil \) bins and we can force any deterministic online algorithm to use at least \(\lceil 1.5\cdot OPT \rceil \) bins while the offline optimum is \( OPT \) for any value of \( OPT \ge 2\). In particular, the absolute competitive ratio of our algorithm is 5 / 3 and this is optimal. For items of arbitrary size we give a lower bound of 2.5 on the asymptotic competitive ratio of any online algorithm and an absolutely 3.5-competitive algorithm. When the items have sizes of at most 1 / d for a real \(d \ge 2\) the asymptotic competitive ratio of our algorithm is \(1.5+d/(d-1)\). We also show that classical algorithms First Fit, Best Fit and Worst Fit are not constant competitive, which holds already for three colors and small items. In the case of two colors—the Black and White Bin Packing problem—we give a lower bound of 2 on the asymptotic competitive ratio of any online algorithm when items have arbitrary size. We also prove that all Any Fit algorithms have the absolute competitive ratio 3. When the items have sizes of at most 1 / d for a real \(d \ge 2\) we show that the Worst Fit algorithm is absolutely \((1+d/(d-1))\)-competitive.


Online algorithms Bin packing Worst-case analysis Colored bin packing Black and white bin packing 



We would like to thank anonymous reviewers for careful reading and many useful suggestions.


  1. 1.
    Babel, L., Chen, B., Kellerer, H., Kotov, V.: Algorithms for on-line bin-packing problems with cardinality constraints. Discrete Appl. Math. 143, 238–251 (2004)MathSciNetCrossRefzbMATHGoogle Scholar
  2. 2.
    Balogh, J., Békési, J., Dósa, G., Epstein, L., Kellerer, H., Tuza, Z.: Online results for black and white bin packing. Theory Comput. Syst. 56(1), 137–155 (2015)MathSciNetCrossRefzbMATHGoogle Scholar
  3. 3.
    Balogh, J., Békési, J., Dósa, G., Kellerer, H., Tuza, Z.: Black and white bin packing. In: Approximation and Online Algorithms. LNCS, vol. 7846, pp. 131–144. Springer, Berlin (2013)Google Scholar
  4. 4.
    Balogh, J., Békési, J., Galambos, G.: New lower bounds for certain classes of bin packing algorithms. Theor. Comput. Sci. 440–441, 1–13 (2012)MathSciNetCrossRefzbMATHGoogle Scholar
  5. 5.
    Balogh, J., Békési, J., Dósa, G., Sgall, J., van Stee, R.: The optimal absolute ratio for online bin packing. In: Proceedings of the 26th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pp 1425–1438. ACM-SIAM (2015)Google Scholar
  6. 6.
    Böhm, M., Sgall, J., Veselý, P.: Online colored bin packing. In: Approximation and Online Algorithms. LNCS, vol. 8952, pp. 35–46. Springer, Berlin (2015)Google Scholar
  7. 7.
    Chrobak, M., Sgall, J., Woeginger, G.J.: Two-bounded-space bin packing revisited. In: European Symposium on Algorithms (ESA). LNCS, vol. 6942, pp. 263–274. Springer, Berlin (2011)Google Scholar
  8. 8.
    Coffman Jr, E., Csirik, J., Galambos, G., Martello, S., Vigo, D.: Bin packing approximation algorithms: survey and classification. In: Pardalos, P.M., Du, D.-Z., Graham, R.L. (eds.) Handbook of Combinatorial Optimization, pp. 455–531. Springer, Berlin (2013)CrossRefGoogle Scholar
  9. 9.
    Csirik, J., Johnson, D.S.: Bounded space on-line bin packing: best is better than first. Algorithmica 31(2), 115–138 (2001)MathSciNetCrossRefzbMATHGoogle Scholar
  10. 10.
    Dósa, G., Epstein, L.: Colorful bin packing. In: Algorithm Theory SWAT. LNCS, vol. 8503, pp. 170–181. Springer, Berlin (2014)Google Scholar
  11. 11.
    Dósa, G., Epstein, L.: Online bin packing with cardinality constraints revisited. arXiv:1404.1056
  12. 12.
    Dósa, G., Sgall, J.: First Fit bin packing: A tight analysis. 30th International Symposium on Theoretical Aspects of Computer Science (STACS), Volume 20 of Leibniz International Proceedings in Informatics (LIPIcs), pp. 538–549. Dagstuhl, Germany (2013)Google Scholar
  13. 13.
    Dósa, G., Sgall, J.: Optimal analysis of Best Fit bin packing. In: Automata, Languages, and Programming (ICALP). LNCS, vol. 8572, pp. 429–441. Springer, Berlin (2014)Google Scholar
  14. 14.
    Dósa, G., Tuza, Z., Ye, D.: Bin packing with “largest in bottom” constraint: tighter bounds and generalizations. J. Comb. Optim. 26(3), 416–436 (2013)MathSciNetCrossRefzbMATHGoogle Scholar
  15. 15.
    Epstein, L.: Online bin packing with cardinality constraints. SIAM J. Discrete Math. 20, 1015–1030 (2006)MathSciNetCrossRefzbMATHGoogle Scholar
  16. 16.
    Epstein, L.: On online bin packing with LIB constraints. Naval Res. Logist. 56(8), 780–786 (2009)MathSciNetCrossRefzbMATHGoogle Scholar
  17. 17.
    Finlay, L., Manyem, P.: Online LIB problems: heuristics for bin covering and lower bounds for bin packing. RAIRO Oper. Res. 39(3), 163–183 (2005)MathSciNetCrossRefzbMATHGoogle Scholar
  18. 18.
    Fujiwara, H., Kobayashi, K.: Improved lower bounds for the online bin packing problem with cardinality constraints. In: Computing and Combinatorics, LNCS, vol. 7936, pp. 518–530. Springer, Berlin (2013)Google Scholar
  19. 19.
    Johnson, D.: Near-Optimal Bin Packing Algorithms. Massachusetts Institute of Technology, Project MAC. Massachusetts Institute of Technology (1973)Google Scholar
  20. 20.
    Krause, K.L., Shen, V.Y., Schwetman, H.D.: Analysis of several task-scheduling algorithms for a model of multiprogramming computer systems. J. ACM 22, 522–550 (1975)MathSciNetCrossRefzbMATHGoogle Scholar
  21. 21.
    Lee, C.C., Lee, D.T.: A simple on-line bin-packing algorithm. J. ACM 32, 562–572 (1985)MathSciNetCrossRefzbMATHGoogle Scholar
  22. 22.
    Manyem, P.: Bin packing and covering with longest items at the bottom: online version. ANZIAM J. 43(E), E186–E232 (2002)MathSciNetCrossRefzbMATHGoogle Scholar
  23. 23.
    Manyem, P., Salt, R.L., Visser, M.S.: Approximation lower bounds in online LIB bin packing and covering. J. Automata Lang. Comb. 8(4), 663–674 (2003)MathSciNetzbMATHGoogle Scholar
  24. 24.
    Seiden, S.S.: On the online bin packing problem. J. ACM 49, 640–671 (2002)MathSciNetCrossRefzbMATHGoogle Scholar
  25. 25.
    Ullman, J.: The Performance of a Memory Allocation Algorithm. Technical Report 100 (1971)Google Scholar

Copyright information

© Springer Science+Business Media New York 2016

Authors and Affiliations

  • Martin Böhm
    • 1
  • György Dósa
    • 2
  • Leah Epstein
    • 3
  • Jiří Sgall
    • 1
  • Pavel Veselý
    • 1
    Email author
  1. 1.Computer Science Institute of Charles UniversityPragueCzech Republic
  2. 2.Department of MathematicsUniversity of PannoniaVeszprémHungary
  3. 3.Department of MathematicsUniversity of HaifaHaifaIsrael

Personalised recommendations