Online Bin Packing with Predictions

Spyros Angelopoulos, Shahin Kamali, Kimia Shadkami

Abstract

Bin packing is a classic optimization problem with a wide range of applications, from load balancing to supply chain management. In this work, we study the online variant of the problem, in which a sequence of items of various sizes must be placed into a minimum number of bins of uniform capacity. The online algorithm is enhanced with a (potentially erroneous) prediction concerning the frequency of item sizes in the sequence. We design and analyze online algorithms with efficient tradeoffs between the consistency (i.e., the competitive ratio assuming no prediction error) and the robustness (i.e., the competitive ratio under adversarial error), and whose performance degrades near-optimally as a function of the prediction error. This is the first theoretical and experimental study of online bin packing under competitive analysis, in the realistic setting of learnable predictions.

Introduction

Bin packing is a foundational optimization problem: a sequence of items of various sizes must be packed into the minimum number of bins of a fixed capacity. In the online version, items arrive one by one, and a placement decision must be made immediately without knowledge of future arrivals.

Traditional online algorithms, such as First Fit or Best Fit, are designed for worst-case scenarios, often leading to overly cautious and inefficient performance in practice. Conversely, stochastic models assume perfectly known distributions, which rarely hold in evolving real-world data. This research addresses the gap by asking: How can we use potentially erroneous, machine-learned predictions to beat worst-case bounds without risking performance collapse if the predictions are wrong?

The Profile-Based Approach

The core innovation of this work is treating item frequency as a learnable prediction. Unlike previous models requiring omniscient oracles, this approach uses a "profile set"—a multiset of items representing the predicted frequencies of different sizes. This is a "natural" prediction because it can be learned from a small sample of data (PAC-learning).

An example of a predicted frequency distribution $f'_x$ for item sizes $x \in \{1, \dots, 10\}$.

PROFILEPACKING

The algorithm PROFILEPACKING uses this profile to compute an optimal offline packing, which then serves as a global "blueprint." When an item arrives, the algorithm attempts to fit it into a "placeholder" defined by this template. If no placeholder exists—either due to prediction error or the arrival of an unexpected item—it falls back to a standard heuristic like First Fit.

Comparison of two packing profiles, $P_1$ and $P_2$, illustrating how different predicted item frequencies lead to distinct bin templates.

Balancing Consistency and Robustness

To manage the inherent uncertainty of predictions, the authors propose two additional strategies:

  1. HYBRID($\lambda$): This algorithm uses a parameter $\lambda$ to serve a fraction of items using the optimistic PROFILEPACKING and the remainder using a robust, standard online algorithm. This allows for a tunable tradeoff between consistency (performance with perfect predictions) and robustness (performance under adversarial error).
  2. ADAPTIVE(w): For dynamic environments where item distributions shift, this heuristic updates frequency predictions using a sliding window of the last $w$ items.

Key Results and Insights

Theoretical analysis reveals that the performance of PROFILEPACKING degrades linearly with the prediction error, measured as the $L_1$ distance between predicted and actual frequencies. When predictions are error-free, the algorithm achieves a near-optimal competitive ratio of $1 + \epsilon$.

Experimental evaluations using Weibull distributions and the BPPLIB (Bin Packing Library) benchmarks demonstrate that these predictive algorithms consistently outperform traditional heuristics. Even when predictions are generated from a very small prefix of the input sequence, the algorithms maintain high efficiency. Furthermore, the ADAPTIVE heuristic proved capable of recovering performance in non-stationary environments where the underlying data distribution changes over time.

Conclusion

This work provides the first comprehensive framework for learning-augmented online bin packing. By bridging the gap between worst-case competitive analysis and average-case stochastic modeling, it offers a practical path for utilizing machine learning in resource allocation and cloud scheduling. Future work may extend these "profile" concepts to multi-dimensional vector packing and other complex scheduling environments.

Summary updated

BibTeX
@article{angelopoulos2022online,
  author = {Spyros Angelopoulos and Shahin Kamali and Kimia Shadkami},
  title = {{Online Bin Packing with Predictions}},
  journal = {J. Artif. Intell. Res.},
  year = {2022},
  doi = {10.1613/jair.1.14820},
}
Figure