Manuscript Offprint
arXiv:2611.09611Online Timely Bin Packing Revisited: A Simpler Algorithm with Optimality in Special Cases
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
Online TIMELY BIN PACKING is a variant of classical online bin packing in which items arrive over time with sizes and deadlines. Packing an item may be deferred until its deadline, but once a collection of items is packed into a bin, the bin is closed and cannot be used again. The objective is to minimize the total number of bins used. The problem was introduced by Khattar in 2023. In 2025, Aminian proposed Discrete-Greedy, a deterministic online algorithm with a competitive ratio of exactly 2, which remains the best-known upper bound. Its analysis is particularly simple; however, the algorithm requires maintaining a fractional simulation internally and may leave usable space in some bins unfilled.
We propose Thrifty-Greedy, a simple deterministic online algorithm that does not require a fractional simulation. We prove that its competitive ratio is exactly 2, matching the best-known upper bound. At the same time, the algorithm automatically achieves the optimal competitive ratio on two natural classes of inputs: it is 1-competitive when all items have the same size, and 1.5-competitive when every item has size in . In contrast, Discrete-Greedy has a competitive ratio of at least 2 on both classes.
1 Introduction
In classical online BIN PACKING, items arrive one by one, with each item having a size . Upon arrival, each item must be assigned immediately and irrevocably to a unit-capacity bin, and the objective is to minimize the total number of bins used. Note that the model has no explicit notion of time beyond the order of arrivals.
A classical way to introduce explicit time constraints is DYNAMIC BIN PACKING, introduced by Coffman et al. in 1983 [3]. In this model, each item has an arrival time and a departure time. An arriving item must be assigned immediately to a bin; when the item later departs, the space it occupied becomes available again, while the bin itself remains in the system. This models persistent resources whose capacity can be reused over time, such as cloud servers that remain available while jobs arrive and depart.
In this paper, we study another way to introduce time constraints: online TIMELY BIN PACKING. This problem is introduced by Khattar in 2023 [4]. Here, an arriving item has a deadline, and the algorithm may defer packing it until any time no later than that deadline. When several items are packed together, the entire bin is closed at that time and cannot be used again. Thus, unlike in DYNAMIC BIN PACKING, items do not depart individually and leave reusable space; instead, the bin itself leaves the system.
A motivating example comes from logistics. Items arrive at a warehouse over time and may be stored temporarily before dispatch. Each item has a deadline by which it must be loaded onto a truck or container, and each truck has a fixed capacity. Several items can be dispatched
*Department of Computer Science, National Tsing Hua University, Taiwan. ivylingchiang@gmail.com †Department of Computer Science, National Tsing Hua University, Taiwan. wkhon@cs.nthu.edu.tw ‡Department of Computer Science, National Tsing Hua University, Taiwan. ereal3478@gmail.com §Department of Computer Science, National Tsing Hua University, Taiwan. breton0429@gmail.com together only if they all fit in the truck and are present at the warehouse when the truck departs. Because trucks are costly, the objective is to minimize the number of dispatched trucks. For simplicity, the model assumes that pending items can be stored at the warehouse without limit and at no cost; only the number of dispatched trucks is counted.
Let us now formally define online TIMELY BIN PACKING.
For each item , we need to pack it into some bin at some packing time such that . Unlike in classical online BIN PACKING, where an item must be packed immediately upon arrival, in online TIMELY BIN PACKING, the decision of when to pack an item may be deferred from its arrival until any time no later than its deadline. Yet, once the decision is made, it cannot be changed. An item that has arrived but has not yet been packed is called pending.
Formally, given an algorithm and an online input sequence , the output of is a collection of bins satisfying the following conditions:
-
Each bin is associated with a packing time .
-
Each item is assigned to exactly one bin whose packing time satisfies .
-
For every bin , the total size of the items assigned to is at most 1.
We measure the performance of an online algorithm using standard competitive analysis. The cost of an algorithm on input , denoted by , is the number of bins in its output, i.e., . Let OPT denote an optimal offline algorithm that knows the entire input in advance and, for every input , uses the minimum number of bins. For , we say that an online algorithm is -competitive if OPT() for every input . The competitive ratio of is the infimum of all such values . Our goal is to design an online algorithm that minimizes this ratio.
1.2 Prior Work
Khattar introduced online TIMELY BIN PACKING and proved that no deterministic online algorithm can have a competitive ratio below 1.2 [4, Theorem 3]. Khattar also proposed the Pack-at-Deadline algorithm and claimed that it is 2-competitive [4, Theorem 1]. Aminian subsequently showed that this claim is incorrect by proving that Pack-at-Deadline has a competitive ratio of at least 2.5 [1, Theorem 4.2.5].
Aminian also improved both the general lower and upper bounds. Aminian proved a lower bound of 1.5 for the competitive ratio of any deterministic online algorithm, even on inputs containing only items of sizes in [1, Theorem 4.5.12]. On the algorithmic side, Aminian introduced Discrete-Greedy, a 2-competitive deterministic online algorithm [1, Theorem 4.2.10]. A matching lower bound shows that Discrete-Greedy is no better than 2-competitive, so this analysis is tight [1, Theorem 4.2.11]. Aminian's thesis also studies several other variants, including uniform-size items, unit-length intervals, integer arrival times, randomized algorithms, advice, and the offline problem.
Because Discrete-Greedy is the main benchmark for our work, we next briefly review its definition and analysis.
The fractional relaxation. The definition and analysis of Discrete-Greedy are based on a fractional relaxation of the problem. In online FRACTIONAL TIMELY BIN PACKING, an item may be divided into arbitrarily many portions (intuitively, thinking of items as liquids), and different portions may be packed in different bins, as long as every portion is packed at a time within the original item's interval. Let denote the optimal offline cost in this fractional model. Since every feasible integral packing is also a feasible fractional packing, we have
Aminian first designed a simple earliest-deadline-first algorithm that produces an optimal packing in the fractional setting.
Greedy: At any time t when at least one pending item reaches its deadline, open a bin and consider all currently available pending items in nondecreasing order of deadline, breaking ties by item index. Pack the items in this order until no item remains or the next item would exceed the remaining capacity. In the latter case, split that item, place exactly the portion needed to fill the bin, and leave the remaining portion pending. Repeat at time t while some pending item has deadline t.
A standard exchange argument shows that Greedy is optimal even among offline fractional packings [1, Lemma 4.2.9]. The argument considers the first bin on which an optimal fractional packing differs from Greedy and exchanges portions of later-deadline items for equal-sized portions of earlier-deadline items, without increasing the number of bins. Repeating the exchange transforms the optimal packing into the one produced by Greedy. Consequently, for every input I,
Aminian then used Greedy to design a simple 2-competitive online algorithm for the integral problem.
Discrete-Greedy: Simulate Greedy. For each fractional bin produced by Greedy, pack the items that occur wholly in that bin into one integral bin, omitting fractional portions of items that were split elsewhere. If Greedy ends the fractional bin by splitting an item p, open an additional dedicated bin containing the whole item p and close it at the same time. Future fractional portions of p are omitted from the simulated packing.
Thus, each bin of Greedy projects to at most two bins of Discrete-Greedy. Together with (1), this immediately gives
The resulting analysis is very simple and straightforward. However, the dedicated-bin rule is deliberately conservative: an item split by the fractional simulation is placed alone, even when it could share a bin with other currently available items. Moreover, the integral algorithm must maintain the state of the fractional simulation, including any remaining fractional portions.
1.3 Our Contributions
The definition of Discrete-Greedy naturally raises the following question: if the next item in earliest-deadline order does not fit in the current bin, why should the algorithm immediately give this item its own bin? A more natural choice is to simply leave that item pending and continue trying to fill the remaining space of the current bin with other items. In this paper, we propose an algorithm based on this simple idea, which we call Thrifty-Greedy. Informally, whenever a pending item reaches its deadline, Thrifty-Greedy opens a bin for an earliest-deadline pending item and then scans the other pending items in earliest-deadline order, packing every item that fits and skipping those that do not. This simple heuristic avoids opening a dedicated bin for the skipped item and also eliminates the need to simulate a fractional packing internally. The formal definition is given in Section 2.
We analyze Thrifty-Greedy in the general setting and in two natural restricted settings. Our results show that this simple heuristic matches the competitive ratio of Discrete-Greedy in the general setting, while attaining the optimal competitive ratio on two restricted classes for which Discrete-Greedy is suboptimal. Notably, these two restricted guarantees are “opportunistic”: Thrifty-Greedy does not need to know in advance that the input belongs to either restricted class. The same general-purpose algorithm automatically attains the optimal competitive ratio whenever the input belongs to one of them.
General inputs. In Section 3.2, we show that Thrifty-Greedy is 2-competitive, matching Discrete-Greedy. However, Thrifty-Greedy is not better than Discrete-Greedy in the general setting: we also give a lower-bound construction showing that Thrifty-Greedy is no better than 2-competitive.
The projection argument used for Discrete-Greedy no longer applies directly, because bins of Thrifty-Greedy do not correspond locally to bins of Greedy. Nevertheless, we show that we can still prove the analogous global inequality Thrifty-Greedy( ) Greedy( ) by strong induction on the number of items in . At a high level, we show that we can always select two bins produced by Thrifty-Greedy and remove their entire contents from the input so that the removed items contain the entire contents of at least one bin produced by Greedy. Thus, the number of bins used by Thrifty-Greedy decreases by two, while the number of bins used by Greedy decreases by at least one. Applying the induction hypothesis to the remaining input yields the desired factor of 2.
Uniform-size items. In Section 3.1, we show that Thrifty-Greedy is 1-competitive when all items have the same size, i.e., it uses the same number of bins as any optimal offline algorithm. In fact, on uniform-size inputs, Thrifty-Greedy follows the same strategy as Aminian's Greedy-on-Deadline algorithm, which was defined specifically for this class of inputs and was shown to be optimal [1, Observation 4.5.1]. For completeness, we provide a proof using a standard exchange argument. In contrast, Discrete-Greedy has a competitive ratio of at least 2 even on uniform-size inputs; see Appendix A.
Items of sizes in . In Section 3.3, we show that Thrifty-Greedy is 1.5-competitive when all items have sizes in . This ratio is optimal for the class, since Aminian proved a lower bound of 1.5 for any deterministic online algorithm, even on inputs containing only items of these two sizes [1, Theorem 4.5.12]. Again, in contrast, Discrete-Greedy has a competitive ratio of at least 2 on this restricted class of inputs; see Appendix A.
The proof is rather involved, although the high-level idea is simple. Intuitively, we want to show that the bins produced by Thrifty-Greedy are 2/3-full on average. A 2/3-full or full bin already has sufficient utilization, and pairing a 1/3-full bin with a full bin also gives an average load of 2/3. Thus, the problematic bins are the remaining unpaired 1/3-full bins. If there are x such bins, we would like to argue that an optimal packing must also contain at least x 1/3-full bins. Unfortunately, establishing such a lower bound directly appears difficult.
We therefore give an input-conversion procedure that successively modifies the intervals of some items, converting I into an input for which the desired lower bound is easier to establish. The complication is that these modifications may also change the packing produced by Thrifty-Greedy. We must therefore ensure throughout the conversion that Thrifty-Greedy does not use fewer bins on than on I. Maintaining this guarantee while creating the structure needed for the lower bound is the main reason the proof becomes technical.
1.4 Other Related Work
Interestingly, the offline version of TIMELY BIN PACKING has been studied from a graph-theoretic perspective. Represent each item by the interval with weight . A set of items can share a bin exactly when their intervals have a common intersection and their total weight is at most 1. Equivalently, a feasible bin corresponds to a clique of total weight at most 1 in the associated weighted interval graph. The offline problem is therefore equivalent to partitioning a weighted interval graph into the minimum number of bounded-weight cliques.
Chen et al. [2] studied this problem under the name minimum clique partition with constrained bounds in weighted interval graphs. They proved that it is strongly NP-hard [2, Theorem 1] and cannot be approximated within a factor of , for any , unless [2, Theorem 2]. Myung [7] later gave a 2-approximation algorithm for the case of arbitrary weights, and an exact algorithm for the case of identical weights.
Thus, assuming , the currently best-known lower and upper bounds on the optimal polynomial-time approximation ratio for TIMELY BIN PACKING are 1.5 and 2, respectively. We remark that the same numerical gap remains in the online setting: the currently best-known lower and upper bounds on the optimal competitive ratio are also 1.5 and 2, respectively.
2 The Proposed Algorithm
In this section, we formally define Thrifty-Greedy. Recall that at any time , an item is pending if it has arrived but has not yet been packed.
Thrifty-Greedy: At any time at which at least one pending item reaches its deadline, repeat the following procedure until no pending item has deadline .
-
Choose a pending item with the earliest deadline (i.e., deadline ), breaking ties by item index. Open a new bin , assign it packing time , and pack into . We call the trigger item of .
-
Scan the remaining pending items in nondecreasing order of deadline, again breaking ties by item index. Whenever the current item fits in the remaining capacity of , pack it into ; otherwise, skip it and leave it pending. After every pending item has been considered, close and output .
For an input sequence of items , let denote the corresponding output sequence of bins. For each bin , let denote the total size of all items packed in . One reason the proposed algorithm works well is the following lemma.
Lemma 1. Let and be two distinct bins in , and let and denote their trigger items, respectively. If , then the intervals of and do not overlap.
Proof. Suppose, for contradiction, that the intervals of and overlap. Without loss of generality, assume the deadline of is within the interval of . Then, by the time is opened at the deadline of , the item is pending. Also, , so by our algorithm, would be packed into . Yet, is packed in another bin , a contradiction.
3 Performance Analysis
We analyze Thrifty-Greedy in three settings: uniform-size items, general inputs, and items with sizes in . The subsections are presented in increasing order of the technical complexity of their analyses.
3.1 Uniform-Size Items
Consider the special case where every item in the input has the same size. Let be the maximum number of items that a bin can hold. We show that Thrifty-Greedy uses the same number of bins as any optimal offline algorithm in this case.
Recall that our proposed algorithm is a greedy algorithm, where we will always (i) pick an item with the earliest deadline, say , to be packed in some bin , (ii) set 's packing time to , and (iii) add other items to (prioritized by their deadlines, the earlier the better) as many as possible. To show that our algorithm is optimal, we use the standard exchange argument for greedy algorithms. We first show that such a greedy choice is consistent with the choice of some optimal algorithm. Then, inductively, all the greedy choices we have made will be the same as the choices of some optimal algorithm.
Let OPT be an optimal algorithm. Let denote an item with the earliest deadline in input , and be its deadline. Let be the set of items that are available at time except item . That is, the arrival time of each item in is on or before . Also, let be the set of items in whose deadlines are the earliest, such that these items are exactly those packed in the same bin with in our greedy algorithm.
Consider how OPT would pack . Since has the earliest deadline, without loss of generality, we can assume that OPT sets the packing time of the bin containing , say , as . We have the following two scenarios:
-
If OPT packs with all the items of , done.
-
Else, there exists some item not packed with by OPT. If the bin containing still has vacant space for , we modify the choice of OPT by moving into . This change does not increase the number of bins used, so the resulting packing is also optimal; denote the corresponding optimal algorithm by OPT'. Repeating the above process, we can put more items of into , while maintaining optimality.
In the end, either all items of are now in , in which case we are done, or, there exists some in some bin other than . For the latter case, there must be some packed in , and we modify the choices of the optimal algorithm again, by exchanging and in their corresponding bins. Note that such a change is valid, for has a deadline earlier than or equal to , so that can be moved to (as its packing time is on or before ), while can be moved to (as its deadline is on or after ). Because this exchange does not increase the number of bins used, the resulting packing is still optimal. Repeating the above exchange process, we can put all items of into , while maintaining optimality.
The above discussion shows that there exists some optimal algorithm that makes exactly the same choice as we do, for packing items along with . Inductively, there exists some optimal algorithm that makes exactly the same choices as we do, for packing each of the items. This gives the following theorem.
Theorem 2. When all items have the same size, Thrifty-Greedy() = OPT() for every such input .
3.2 General Inputs
We now consider unrestricted item sizes and prove that Thrifty-Greedy is 2-competitive, with a matching lower bound of 2.
We first prove the upper bound. Recall from (1) that the fractional algorithm Greedy reviewed in Section 1.2 satisfies
for every input . Therefore, it suffices to establish the following comparison between Thrifty-Greedy and Greedy.
Lemma 3. For every input , Thrifty-Greedy() 2 Greedy().
Proof. We prove the lemma by strong induction on the length of the input .
Base Case: When , the input consists of a single item; both Thrifty-Greedy and Greedy will pack this item into one bin. Thus, Thrifty-Greedy() = Greedy() = 1, and the lemma holds.
Inductive Step: Assume the lemma holds for all inputs of length at most , for some . Consider an input with . Let us compare the sequences of bins produced by Thrifty-Greedy and Greedy on input , indexed by their packing orders. We scan the two sequences from left to right to find the first index , where the contents of their th bins differ. If no such index exists, the packings are identical, implying Thrifty-Greedy() = Greedy(), so the lemma holds. Otherwise, suppose the packings differ at the th bin. Since both algorithms pack pending items by increasing order of deadlines, they consider the same set of items in the same order. Therefore, the difference must arise because Greedy can split an item that fits only partially, whereas Thrifty-Greedy cannot.
Specifically, both algorithms pack a set of items into the th bin. The next item in the priority order, let us call it , does not fit entirely into the remaining space. Then, the corresponding actions of the two algorithms are as follows.
-
Thrifty-Greedy: Cannot split , so it skips and continues scanning for other items that fit. Let be the set of subsequent items that Thrifty-Greedy packs into the th bin. Thus, the th bin of Thrifty-Greedy contains .
-
Greedy: Splits into two pieces, and . It packs into the th bin, making it full. The remainder is left for subsequent bins. Thus, the th bin of Greedy contains .
Since Thrifty-Greedy skips at the th bin, it must pack into some later bin, say, the th bin (where ). Let denote the set of other items packed alongside in this th Thrifty-Greedy bin. Let us now construct a smaller input by removing all items contained in the th and th Thrifty-Greedy bins from the original input . Specifically, let .
Since and constitute the complete contents of two bins in Thrifty-Greedy, removing these items from the input does not affect the packing of the remaining bins (they are packed identically as before). Therefore, the total number of bins used by Thrifty-Greedy on decreases by exactly 2. Notice that the length of the new input is strictly shorter than (i.e., ), hence by the induction hypothesis we have
Next, consider the behavior of Greedy. Suppose we modify the original input by replacing item with its two split pieces, and (where both inherit the same arrival time and deadline as ). Since Greedy operates in the fractional setting and the packing order depends only on arrival times and deadlines, this replacement does not change the original packing. Also, since constitutes the complete content of one bin in the Greedy packing, we can apply a removal argument similar to the one used for Thrifty-Greedy. Thus, removing those items from the input does not affect the packing of the remaining bins, so that:
Our final step is to show that . To establish this, we use the following notion of “monotonicity”. We say that an input dominates an input if can be obtained from by adding items, increasing their sizes, and/or restricting their intervals. An algorithm is monotone if whenever dominates . Intuitively, adding items, making them larger, or giving them narrower intervals should not make the packing easier.
Although one might expect this property to hold generally, many classical bin packing algorithms are not monotone [5, 6]. Moreover, the standard counterexample for the classical First-Fit heuristic from [6] can be adapted to show that Thrifty-Greedy is not monotone for online TIMELY BIN PACKING.
Consider an input dominated by . Notice that any fractional solution for is also a feasible fractional solution for , so we have . Since Greedy is optimal, we have . Thus, Greedy is monotone.
Next, we see that is dominated by . By the monotonicity of Greedy, we have . Combining the results in the above discussion, we have
Thus, the lemma holds for . This completes the inductive step.
We have thus proven that Thrifty-Greedy is 2-competitive. We now show that the above competitive analysis is indeed tight, i.e., Thrifty-Greedy is not better than 2-competitive.
Consider the following input. Let be a large integer and let . At time , items of size arrive with an arbitrarily late deadline. At each time , two items of size arrive: one with an immediate deadline at , and the other with a deadline at . Thrifty-Greedy packs the two -items together in one bin at each , and uses another separate bins for the large -items, using bins in total. In contrast, OPT can pack the immediate -item with a -item at each , and pack all remaining -items into a single bin at time , using only bins. As , this shows a lower bound of 2 for the competitive ratio of Thrifty-Greedy.
Summarizing, we have the following theorem.
Theorem 4. In the general setting, Thrifty-Greedy is 2-competitive, which is tight.
3.3 Items of Sizes in
We now consider the special case where every item has size in . We show that Thrifty-Greedy is 1.5-competitive in this setting, which is optimal.
Since every item has size 1/3 or 2/3, we classify the bins used by an algorithm into small, medium, and large bins, which respectively are 1/3-full, 2/3-full, and full. More precisely, let
be the number of small, medium, and large bins used by an optimal offline algorithm OPT on the original input I;
• be the number of small, medium, and large bins used by our algorithm Thrifty-Greedy on the original input ;
be the number of small, medium, and large bins used by our algorithm Thrifty-Greedy on the modified input .
At a high level, we would like to show that the bins produced by Thrifty-Greedy are 2/3-full on average, which would give a competitive ratio of 1.5. A medium or large bin already has load at least 2/3, while pairing a small bin with a large bin also gives an average load of 2/3.
Thus, the problematic bins are the remaining unpaired small bins. We would like to show that if Thrifty-Greedy performs badly on such a bin, then we can associate it with a distinct small bin where OPT also performs badly. This would give the desired bound on the competitive ratio. However, the packings produced by Thrifty-Greedy and OPT may be very different, making such a direct association difficult.
In Section 3.1, we handled a similar comparison using a standard exchange argument: we successively modified the packing produced by OPT so that it remained as good, while making its choices agree with those of Thrifty-Greedy. Here, we take an orthogonal approach. Instead of modifying either algorithm's packing, we keep the algorithms fixed and successively modify the input into an input so that Thrifty-Greedy remains as bad on the modified input, while making it easier to associate the remaining unpaired small bins of Thrifty-Greedy on with small bins of OPT on the original input . By repeatedly applying the conversion, we can compare Thrifty-Greedy on the final modified input with OPT on the original input , and consequently obtain the desired competitive analysis.
In Section 4, we present the input-conversion algorithm and prove its correctness. Specifically, the algorithm converts any input into another input such that the following three properties hold.
-
We use the same set of items in and in , except some items have more “restrictive” arrival times and deadlines in . Since the total size of items remains unchanged, .
-
After pairing small bins with large bins used by Thrifty-Greedy on , the number of remaining unpaired small bins is at most the number of small bins used by OPT on . In particular, .
-
Our algorithm Thrifty-Greedy performs as badly on as on . That is, Thrifty-Greedy() Thrifty-Greedy().
Remark 5. The first property does not imply the third. Recall from Section 3.2 that dominates , but Thrifty-Greedy is not monotone. Therefore, it is not guaranteed that Thrifty-Greedy() Thrifty-Greedy().
For now, suppose that we have such an input-conversion algorithm. Then, we have the following theorem.
Theorem 6. When every item has size in , Thrifty-Greedy is 1.5-competitive, which is optimal.
Proof. We adopt the notation defined above. By combining the equality from the first property with the inequality from the second property, we obtain
Consequently, we have
Combining this with the third property, we obtain
as desired. Furthermore, our algorithm is optimal, since Aminian proved a lower bound of 1.5 for any deterministic online algorithm, even on inputs containing only items of sizes in . This completes the proof.
4 Input Conversion for the {1/3, 2/3} Case
In this section, we will give details on the input conversion mentioned in Section 3.3 to change the input into another sequence satisfying certain properties. Note that the sequence is only for analysis purposes, so in the construction of such a sequence, we will assume that some optimal offline algorithm OPT is known, and so is its corresponding output on the input .
We consider the special case where each item in the input has size either 1/3 or 2/3. Here, we adopt the notation defined in Section 3.3. The following are the three properties that will be shown to satisfy in this section:
-
and use the same set of items, except some items may have more “restrictive” arrival times and deadlines in .
-
.
-
Thrifty-Greedy() Thrifty-Greedy().
4.1 The Conversion Algorithm
The formal definition is given in Algorithm 1. In the algorithm, we first fix an optimal offline algorithm OPT and obtain its output on for reference (Line 1 and Line 2). Then, we initialize as (Line 3), and iteratively update by modifying the arrival time and deadline of some selected item. Every time is updated, we will rerun our Thrifty-Greedy on to obtain the corresponding output (Line 4 and Line 10).
The algorithm maintains a time which is initialized as the latest deadline of all items in (or the initial ). This time will be updated iteratively (Line 9), each time moving to an earlier moment. Based on , we select the latest small bin in with packing time before , and also its trigger item (Line 7 and Line 8), and then modify and some other item's arrival time or deadline based on , and (Line 9). Consequently, the sequence is updated.
When no small bins with packing time before are found, the conversion algorithm terminates, in which case the sequence is obtained (Line 11).
Based on , and , the modification in Line 9 is made according to the following three cases:
-
Case 1: In , the item is also in a small bin.
-
Case 2: In , there exists some other bin packed in the interval of .
-
Case 3: Neither Case 1 nor Case 2 applies.
The intuition of this case division is that in the first two cases, we do not even need to modify , since the output is already good enough; therefore, all we need to do is update . In the remaining case, the small bin containing in may lead to a bad performance, so we make some changes to the arrival times or deadlines of some items such that, after the modification, the bin containing is no longer small. The details of how to perform the modification in each case will be discussed in Section 4.2.
We will show that, after each update, the following invariants hold:
-
Invariant 1: and use the same set of items, except some items may have more “restrictive” arrival times and deadlines in .
-
Invariant 2: For bins with packing time after , .
-
Invariant 3: Thrifty-Greedy() Thrifty-Greedy().
-
Invariant 4: Time will be moved to an earlier time slot.
The first three invariants correspond to the three properties mentioned in Section 3.3, except we only require that the original second property holds only for bins packed after . Invariant 4 guarantees that will be moved to an earlier time slot after each update, so the conversion algorithm will terminate.
It is easy to verify that all the invariants hold initially, when is set as the latest deadline of all items. Also, when the conversion terminates, there are no small bins with packing time before , and so the number of small bins will not change even if we move to the earliest moment. That is, Invariant 2 will continue to hold not just for bins after , but also for all bins. In other words, when the conversion terminates, the sequence obtained will satisfy all three properties in Section 3.3.
It remains to describe how each case is handled and to show that the four invariants are maintained after the update.
Algorithm 1 Input Conversion in Special Case
Input: Sequence
Output: Modified sequence
1: Fix any optimal algorithm OPT; 2: output by OPT on ; 3: ; 4: output by Thrifty-Greedy on ; 5: latest deadline of all items in ; 6: while contains a small bin with packing time before do 7: the small bin in with latest packing time before ; 8: trigger item of ; 9: Update and based on , and ; 10: output by Thrifty-Greedy on ; 11: return
▷ Details in Section 4.2
4.2 Details of Updates (Line 9)
4.2.1 Case 1
Here, the item is also in a small bin in . When this happens, we do nothing for the items in , and just move to the arrival time of .
As is not changed, Invariants 1 and 3 will hold automatically after the update. Also, is moved to an earlier moment, so Invariant 4 also holds. To see why Invariant 2 also holds, let us fix some notation. Let denote the value of before the update, and denote the arrival time of , which is the value of after the update. Let and denote the number of small bins packed after and after in , respectively. Similarly, let and denote the number of large bins packed after and in , and and denote the number of small bins packed after and in .
By the choice of , and the fact (Lemma 1) that the intervals of trigger items of small bins in do not overlap, we conclude that . As is an earlier moment than , . Also, is in a small bin in , so we further have . Now, because Invariant 2 holds after , we have . Immediately, this implies
so that Invariant 2 also holds after .
4.2.2 Case 2
Here, some other bin is packed in the interval of in . When this happens, we do nothing for the items in , and just move to the arrival time of .
Similarly to Case 1, we see that Invariants 1, 3 and 4 will hold after the update. To see why Invariant 2 also holds, let us re-use the notation introduced in Case 1. That is,
• and : the value of t before and after the update;
• and : the number of small bins packed after and after in ;
• and : the number of large bins packed after and in ; and
• and : the number of small bins packed after and in .
Similar to Case 1, we have . Next, as there is some other bin packed in the interval of , such a bin cannot be a small bin nor a medium bin, by Lemma 1. Thus, is a large bin, so that . As is an earlier moment than , . Now, because Invariant 2 holds after , we have . Immediately, this implies
so that Invariant 2 also holds after .
4.2.3 Case 3
Here, we consider all those situations that do not match the conditions of Case 1 or Case 2. In this case, we will make modifications to the arrival time of a selected item, and possibly the deadlines of some other items. At any time, we ensure that the following sub-invariants hold:
(SI1) For any item whose arrival time is modified, its modified arrival time will be after . Furthermore, it is packed with some item in whose arrival time is after .
(SI2) For any item p whose deadline is modified, its modified deadline will be before its original deadline. Furthermore, the modified deadline is on or after t.
(SI3) Let p and q be items that are packed before t by our algorithm Thrifty-Greedy on . Then, their time intervals overlap in I if and only if their intervals overlap in .
Obviously, the above sub-invariants are true before any item of I is modified. In the following, we assume inductively that they are true before the current modification; based on that, we describe how the modification is made, while ensuring that they continue to hold after the modification, and finally show that the main invariants, Invariants 1, 2, 3, 4, will also hold after the modification.
Our description now begins. First, because we are not in Case 1, item is not in a small bin in . This implies that is packed with some other item, say . Note that the arrival times of both and have not been modified, as they are not after . Also, the time intervals of and overlap in , whether their deadlines have been modified or not (as a modification on deadline can “truncate” only the portion of an interval after ). Then, we have:
Lemma 7. The arrival time of B is before the arrival time of C. Also, in , B is packed in some bin before the arrival time of C.
Proof. Consider . Since we are not in Case 2, no other bin is packed in the interval of . This implies that is either packed before the arrival time of , or after the deadline of . Yet, the latter one is impossible, as otherwise is available by the time is packed by our algorithm, so that would have been put together with in the same bin. In other words, must be packed before the arrival time of in . Furthermore, must arrive before for this to occur.
Let us look at the bin in where is packed. As this bin is packed before the arrival time of , it must be packed before the deadline of . So, is not the trigger item of . Instead, there exists some other trigger item, say . See Figure 1 for the relationship of the intervals of , , and .

Figure 1: Intervals of items , , and before and after the update.
Let denote the interval of , and denote the interval of . Let and denote the output of our algorithm Thrifty-Greedy on before and after the update. Then, the update of and in Case 3 is as follows:
-
For each item (except ) that is packed before in , if the original deadline is after , we set the deadline to be a value just before , say for an arbitrarily small positive .
-
We set the arrival time of to .
-
We set to .
Briefly speaking, the purpose of the above update is to put and together, and also “freeze” the bins packed after , so that they are not affected in the future.
It is easy to see that, after the update, all three sub-invariants (SI1, SI2, and SI3) continue to hold. As for the main invariants, trivially, Invariants 1 and 4 will hold after the update. For Invariants 2 and 3, intuitively, we will show that there is little difference between and , where denotes the output of our algorithm Thrifty-Greedy on after the update, so that the arrangement of items in their bins can be compared directly. In particular, we consider the items in different time zones, and we will show that:
-
(Z1) items packed within in are exactly those items packed within the same period in . Furthermore, bins are packed in the same way, so that in this period, the number of bins packed in is equal to the number of bins packed in .
-
(Z2) items packed within in , except , are exactly those items packed within the same period in . Also, in this period, the number of bins packed in is at least the number of bins in .
-
(Z3) In the period , has exactly one bin, which is packed with only, while also has exactly one bin, which is packed with both and (thus, a medium or a large bin).
-
(Z4) items packed after in are exactly those items packed after in . Furthermore, bins are packed in the same way, so that in this period, the number of bins packed in is equal to the number of bins packed in .
The above statements imply that after the update, the number of bins in is at least the number of bins in , so that Invariant 3 will hold after the update. Furthermore, let:
-
and : the value of before and after the update;
-
and : the number of small bins packed after in and after in ;
-
and : the number of large bins packed after in and after in ; and
-
and : the number of small bins packed after and in .
Then, statements Z3 and Z4 imply that
This is because the bin containing will no longer be small, but may become large after the update, while all the other bins packed after are the same in both outputs and . Also, as is moved to an earlier moment,
As Invariant 2 holds after in , we have . Immediately, this implies
so that Invariant 2 also holds after the update.
To complete the whole discussion, it remains to show that the above statements for the different time zones are true. Details are as follows.
Proof of Z1: Since the input restricted to the interval remains unchanged after the update, and by sub-invariant SI3 the overlap relations among these items are preserved, re-running Thrifty-Greedy produces exactly the same bins with packing times in .
Proof of Z2: We first observe the following result.
Lemma 8. For bins packed within the interval in , every trigger item remains a trigger item in in .
Proof. Let and denote the sequence before and after the update, respectively. Starting from time where we open a bin containing , since is modified, the bin will no longer contain , and the items inside may become different. Yet, any items added to the bin before in will still be in the bin in . Thus, only an item, say , that is added after in may not be added to the bin now, because another item is added to the bin instead. Yet, both and must have deadline after that of in , for otherwise they will be added to the bin before in . As the deadline of in is after , the deadline of is also after , so cannot be a trigger item in . Also, for this to happen, the deadline of must be after .
Here, we call the “culprit” and a “victim”. Note that there can be more than one victim.
As time goes on, we will open a bin for the next item whose deadline is due. The other items, if they exist, in the bin would be the same as in in general, but when some of them, say , becomes a culprit of an earlier bin, the items inside may become different. Yet, any items added to the bin before in will still be in the bin in if they are available now. Thus, only an item, say , that is added after in may not be added to the bin now, because another item is added to the bin instead. With the same argument as before, the new culprit cannot be a trigger item in , has deadline after , and all culprits and victims in the process so far have deadlines after that of in .
As time goes on, more and more culprits and victims may be formed. Yet, none of them can be a trigger item of any bin in . Also, as they have deadlines after that of in , those deadlines will be after in ; consequently, they cannot be a trigger item in a bin within in . In other words, only non-trigger items can be culprits or victims, so that they are the only items to be “re-distributed” into a different bin, while all trigger items in in must still remain in their own bins, and be trigger items in .
By Lemma 8, the number of bins in in is at least the number of bins in . Also, for all items packed during this period in , their deadlines are now before after the update, so that they will all be packed during this period in .
Proof of Z3: By statement Z1 and statement Z2, all items with packing time before (except B) are packed before in , and will be the only items left unpacked during , so that there will be exactly one bin in in this period, containing them.
Proof of Z4: By statements Z1, Z2, and Z3, all items with packing time before are still packed before , so for the time after , all unpacked items are the same in and in . Also, neither their arrival times nor their deadlines are updated. Thus, after re-running Thrifty-Greedy, all the bins with packing time after will be exactly the same.
5 Conclusion
In this paper, we revisited online TIMELY BIN PACKING. We proposed a simple deterministic algorithm with a competitive ratio of exactly 2, matching the best-known upper bound, while simultaneously achieving the optimal competitive ratio for two classes of inputs.
Several interesting problems remain open:
-
The optimal competitive ratio for deterministic online algorithms remains between 1.5 and 2. Closing this gap appears challenging.
-
This paper focused on deterministic algorithms, but randomization may lead to better performance. Aminian [1, Theorem 4.2.2] proved that, for inputs of length , no randomized online algorithm can achieve a competitive ratio below . This lower bound approaches 1.5 as grows. It remains open whether a randomized online algorithm can achieve a competitive ratio strictly below 2.
-
In TIMELY BIN PACKING, pending items may be stored temporarily without cost and without any limit on storage capacity. It would be interesting to study variants with bounded storage or with holding costs for pending items.
AI Methodology
ChatGPT was used to assist with literature searches and with improving the authors' existing text.
References
[1] Aida Aminian. "Algorithms for Timely Bin Packing, Fair TCP Acknowledgement, and Variants". Master's Thesis. York University, 2025.
[2] Mingxia Chen, Jianbo Li, Jianping Li, Weidong Li, and Lusheng Wang. "Some Approximation Algorithms for the Clique Partition Problem in Weighted Interval Graphs". In: Theoretical Computer Science 381.1–3 (2007), pp. 124–133. DOI: 10.1016/j.tcs.2007.04.030.
[3] E. G. Coffman Jr., M. R. Garey, and D. S. Johnson. "Dynamic Bin Packing". In: SIAM Journal on Computing 12.2 (1983), pp. 227–258. DOI: 10.1137/0212014.
[4] Zhadyra Khattar. "Online Timely Bin Packing". Master's Thesis. Utrecht University, 2023.
[5] F. D. Murgolo. On the Monotonicity of Certain Bin Packing Algorithms. Tech. rep. 244. Department of Information and Computer Sciences, University of California, Irvine, 1984.
[6] F. D. Murgolo. "Anomalous Behavior in Bin Packing Algorithms". In: Discrete Appl. Math. 21.3 (1988), pp. 229–243. DOI: 10.1016/0166-218X(88)90069-8.
[7] Young-Soo Myung. "On the Clique Partitioning Problem in Weighted Interval Graphs". In: Theoretical Computer Science 396.1–3 (2008), pp. 290–293. DOI: 10.1016/j.tcs.2008.02.016.
A Lower Bounds for Discrete-Greedy
The Discrete-Greedy algorithm works by simulating the optimal fractional algorithm, Greedy, such that each bin packed by Greedy is projected to no more than two integral bins.
For example, suppose Greedy packs the bins , where the last item of is split between and , and the last item of is split between and . Then, Discrete-Greedy produces: as before but without the fraction of ; a dedicated bin for ; as before; as before but without the fractions of and ; a dedicated bin for ; and as before but without the fraction of .
The projection step makes the analysis for the competitive ratio of Discrete-Greedy extremely simple. However, the projection step also leads to inefficiency. As we now show, Discrete-Greedy has a competitive ratio of at least 2, even for two simple classes of inputs.
A.1 Uniform-Size Items
We construct a sequence of inputs such that all items in have the same size (for each ) and Discrete-Greedy as , showing that Discrete-Greedy's competitive ratio is at least 2 for this class of inputs.
Let be a real number such that . The input consists of items with arrival time 0 and size . The items are divided into groups:
-
Groups : Each group contains items. Group has deadline .
-
Group : Contains items with deadline .
For Greedy, items are sorted by increasing deadlines. Since , a single bin cannot hold all items of one group. Hence, Greedy fills the first bins completely. Due to the small , the total size of all items is no more than , so Greedy uses bins. Notice that since the cumulative size of the first groups exceeds by a small margin , each bin ends with a split item.
Consequently, Discrete-Greedy projects each of the bins into 2 integral bins (one for the non-split items, one for the split item that closes the bin) and projects into 1 integral bin. Thus, Discrete-Greedy uses bins.
For OPT, each bin holds exactly items (since ). The total number of items is . Thus, OPT can pack all items into bins.
A.2 Items of Sizes in
Similarly, we construct a sequence of inputs such that all items have size either or , and Discrete-Greedy as , showing that Discrete-Greedy's competitive ratio is at least 2 for this class of inputs.
The input consists of items with arrival time 0. The items are divided into groups, ordered by increasing deadlines as follows:
-
Group 1: Two items of size .
-
Groups : Each group contains one item of size followed by one item of size .
-
Group : One item of size .
For Greedy, the items are packed in the order specified above.
-
The first bin packs the first item of Group 1 (size ) and the first of the second item. It ends with a split item.
-
For , the bin starts with the remaining of the split item from Group , packs the item of size from Group , and fills the remaining space with the first of the item of size from Group . Thus, each bin is full and ends with a split item.
-
The final bin starts with the remaining of the split item from Group and packs the single item of size from Group . The bin is not full but contains no split items at the end.
In total, Greedy uses bins. Since bins all end with a split item, Discrete-Greedy projects each of them into 2 integral bins (one for the non-split item, one for the split item that closes the bin). The final bin projects to 1 integral bin. Thus, Discrete-Greedy uses bins.
For OPT, we can pair the items. There are items of size and items of size . Thus, OPT uses bins.