First, we consider general instances for both objective functions in the removable model. We develop a 3k/(k−1)-competitive deterministic algorithm for the sum-objective, whose barely random variant is 3-competitive irrespective of k; see the statement of Theorem 1 for exact upper bound on the algorithm’s competitive ratio. Then we consider the max-objective and note that for k=2 bins the same algorithm is 2-competitive (and this ratio is optimal). Moreover, while the aforementioned randomized algorithm is 3-competitive for all k, we note that for k=1 its competitive ratio can be improved to 2 by altering the probability distribution.
3.1.1 General case
To state our algorithm, let us classify items as follows: an item is small if its size is at most 1/2, otherwise it is large. Essentially, we are going to use two well-known algorithms, extended to many bins, to handle each type of item.
Algorithm
Greedy: When a new item e is issued, while there is not enough space in any bin to put e, remove the item \(e^{\prime } \in \{e\} \cup \bigcup _{i=1,\ldots ,k} B_{i}\) that minimizes p(e
′
)/s(e
′
) from its bin, removing the most-recent item in case of ties. Stop when either e is removed or there is a bin that can accommodate it. In the latter cases, put e into that bin.
Algorithm
PGreedy: Maintain the k most profitable items, one per bin, as follows. When a new item e is issued, put it in an empty bin if there is one. Otherwise, if p(e)> mini=1,…,k
p(B
i
), replace the minimum-profit item with e.
Recall that, with some arbitrary numbering of the algorithm’s bins, B
i
denotes its i-th bin and \({\mathcal {B}}_{i}\) denotes the set of its first i bins. Moreover, p(X) and s(X) denote the total profit and the total size of items in the set X; we abuse this notation slightly and use it also for bins and sets of bins.
Our algorithm is a combination of the two algorithms above.
Algorithm
MultiGreedy: Use PGreedy on ⌈k/3⌉ of the bins for large items and Greedy on the remaining ⌊2k/3⌋ bins for small items.
The randomized variant, with probability 1/3, uses PGreedy on all the bins for large items, ignoring small items, and, with probability 2/3, uses Greedy on all the bins for small items, ignoring large items.
By Theorem 1, a barely random 1-bin variant of
MultiGreedy is 3-competitive. But a trivial 2-approximation algorithm for
Knapsack gives rise to a 2-competitive barely random 1-bin algorithm: toss a fair coin and, depending on the result, simulate either 1-bin
Greedy or 1-bin
PGreedy on all items. This was also independently observed by Han et al. [
8].
3.1.3 Proportional case—the simplified asymptotic version
In this and the next sections, we give an improved deterministic algorithm ProFit for proportional instances under the sum-objective (and k>1), our most technically involved upper bound.
Before we describe the algorithm, let us classify the items by their sizes as follows: Let α∈(1/2,1) be a given parameter and let β=1−α. An item is small if its size is in [0,β], medium if it is in (β,1/2), big if it is in [1/2,α), and huge if it is in [α,1]. This classification is a refinement of the simplistic one we used previously, and it is used for this result only.
To explain the main ideas of the algorithm, we first sketch a simplified version which only approaches the ratio of 1.6 asymptotically for a large m. We give this simplified version in a parametric form, to see that our later choice of α is optimal for the given approach.
Suppose that we want to achieve the ratio of 1/α. A natural way to do this is to try to fill each bin to at least α, as the size is equal to the profit and thus the optimum cannot get larger profit than 1 per bin. If all but a constant number of bins have size at least α, the algorithm is asymptotically 1/α-competitive. (Recall that the size of the bin means the size of all items packed into it, not to be confused with the capacity which is always 1.)
First we give the algorithm and its analysis assuming that no small items arrive as this is the most important case. Each big item is packed in an empty bin if such a bin is available; otherwise the item is rejected. Each huge item is packed into an empty bin; if no empty bin is available, then into a bin with a big item, which is removed; if no such bin exists, then the item is rejected. Medium items are packed in pairs. More precisely, a medium item is packed into a bin with a single medium item if such a bin exists. Otherwise it is packed into an empty bin, or else into a bin with a big item, which is removed, or it is rejected if no such bin exists.
If a huge or medium item is rejected, it means that each bin, with a possible exception of a single bin with one medium item, contains either a huge item or two medium items. Thus the size of each bin except one is at least min{α,2β} and the algorithm is asymptotically 1/α-competitive, as long as 2β≥α.
Otherwise all the huge and medium items are packed. If also all the big items are packed, the solution is optimal. It remains to handle the case when some big item is removed or rejected, which implies that no bin is empty. We use a charging argument which gives a matching of the bins in the optimal (offline) solution bins to the bins of the algorithm so that the sizes of the matched bins have the required ratio. Actually, it is a bit more complicated, as we compare not single bins but typically pairs of bins. Any bin in the optimal solution that contains a huge or medium item is charged to a bin of the algorithm containing that item; if the bin in the optimum contains more than one medium item, choose arbitrarily. The remaining bins of the optimum are charged arbitrarily one-to-one to the remaining bins of algorithm. Each bin of the algorithm that is charged two bins of the optimum is paired with one of the uncharged bins; this is well-defined as the number of the bins is the same in the algorithm and in the optimum. In this simplified analysis, we ignore the bin with one medium item, if it exists (there is at most one such bin), and the bin of the optimum that is charged to it. Then each remaining bin has size at least 1/2. First we analyze the pairs of bins: The two optimal bins have total size at most 2, while the two bins of the algorithm have size at least 2β+1/2, as one of the bins has two medium items and the other one has at least a big item. Thus the ratio is 1/(β+1/4). Any remaining optimal bin with a huge or medium item is charged to a bin of size α, giving the ratio at most 1/α. Any remaining optimal bin with no huge or medium item contains only a single big item, thus the ratio is at most α/(1/2)=2α. The best overall ratio is achieved when α=β+1/4=(1−α)+1/4, which gives α=5/8 and 1/α=1.6; note that the ratio in the remaining case of charging is 2α=10/8, which is far from tight, and also 2β≥α, which we needed in the previous analysis.
It remains to extend the algorithm to the small items, which is a bit technical but not hard. We combine them with the big items as much as possible. We maintain the invariant that each bin contains small items of total size at most β. A new small item is packed into one of the bins with some small item(s) if that does not violate the invariant. If no such bin exists, it is packed into some bin that contains only a big item (it always fits, as α+β≤1). If no such bin exists either, it is packed into an empty bin. If that is not possible, we need to violate the invariant for one bin: We put the small items greedily into bins with only small items so that they are filled one by one to have size of at least α; this is possible, since the small items have size at most β=1−α. The packing of other items is modified as follows: A big item is put into a bin with only small items of total size at most β if such a bin exists; otherwise it is put in an empty bin. Huge and medium items are handled as before, except that if no empty bin remains, they are also put into the bins with only small items of total size at most β, possibly removing some of the small items if necessary. Only if no such bin with small items remains, they are packed into a bin with a single big item and that item is removed. The algorithm stops whenever all but three bins have size at least α; in such a case the asymptotic 1/α ratio is guaranteed.
The important property of this packing of small items is that bins with a big item and no small items and bins with small items and no big item do not exist simultaneously. Moreover, if two bins contain small items, one of them has to contain at least β/2 small items. If such a bin contains also a big item, its size is at least 1/2+β/2>α for our choice of α.
It follows that if a huge or medium item causes a removal of a small item and later a big item would have to be rejected or removed, almost all bins have size at least α and the algorithm can simply stop. (There may be three exceptional bins with size less than α: one bin with a single medium item, one bin with more than β of small items, and one bin with a big item and less than β/2 of small items.)
If the algorithm exhausts all items before rejecting or removing a big item, we compare the total size of items that were not packed to items that were packed. All items are packed when they arrive and at most size β of small items is removed from each bin (when a medium or huge item is packed there); furthermore, the size of the bin after the step when small items are removed is at least α (as it contains two medium items or one huge item) and thus no further removals occur in that bin. This gives the ratio of packed items to all items of at least α/(β+α)=α and the competitive ratio of 1/α follows.
Finally, if none of the two cases above applies, a big item is rejected or removed before any small item is removed. It follows that either the algorithm stops with almost all bins of size at least α or else it stops by exhausting the items, in which case all the small items are packed. Then the charging argument given before applies as the packed small items can only improve the ratio.
3.1.4 Proportional case—the full version
We now extend the previous algorithm to the algorithm ProFit which achieves the competitive ratio of 1.6 for every value of m, not only in the limit. We fix α=5/8, as we have seen that this is the best value already for the asymptotic case.
We follow the general outline of the previous algorithm, but we need to deal with a significant number of special cases. The main obstacle is that when we argue about the total size the algorithm packs, we cannot tolerate a constant number of bins of size less than 5/8 as we did before. The algorithm needs to continue packing even if there are two or three such bins. Even more difficult is the last such bin: We can fill it greedily to at least 1/2, but we cannot guarantee more. To deal with this, we typically obtain the desired bound on the total volume by arguing that there is a bin of size at least 6/8 and averaging its size with the size of the last bin.
However, to guarantee that a bin of size at least 6/8 is created, we need to modify the algorithm significantly. Most significantly, we try to gain one such bin by packing a big and a medium item together whenever possible. This forces three more changes throughout the algorithm. (1) To guarantee that we have at least one such bin whenever the optimum has one, we need to avoid rejecting or removing big items arbitrarily; instead we guarantee that the smallest big item so far (called the min-big item) is never removed or rejected. The min-big item then guarantees that the smallest medium item is packed either with some big item or with another medium item; in both cases we gain a bin with size at least 6/8 which we can average with the last bin. (2) Another forced change is that we sometimes pack a medium item into a bin that already has size larger than 5/8, in particular in a bin with a big item and some small items that are removed; in turn we then need to guarantee that in such a bin the size of small items is at most 3/8, so that no more small items are removed from any single bin. (3) We need to handle huge items of size smaller than 6/8 more carefully: If such an item should be packed so that it replaces a big item and small items of total size more than 6/8, it is better to reject the huge item instead. This is a conservative change which can only help the algorithm.
Technically, we describe ProFit in two main phases. In the first phase, we follow the outline of the simplified algorithm with the changes above as long as no big item is rejected or removed. The description is somewhat lengthy, as this is the place where we need to handle some of the special cases with only a few bins smaller than 5/8. In the end, if the algorithm ends in this phase, we argue that either the algorithm packs a 5/8 fraction of the size of all items or it fills 5/8 of the total volume; the competitive ratio then follows easily.
The second phase starts when each bin has a medium, big or huge item. We again follow the simplified algorithm and try to pack all medium and huge items even at the cost of removing some big items, with the modifications described above. Since there are now fewer types of bins, the description is simpler. If the average size of a bin does not reach 5/8, we prove the competitive ratio by a charging argument. This is more complicated than in the simplified algorithm, again because we cannot ignore a constant number of bins. First, we cannot assume that all the small items are packed, thus the charging scheme needs to consider the small items as well. Second, if there exists a bin with one medium item (which we have ignored before), its size may be as small as 3/8, while it can be charged the size of 1; we need to modify the analysis so that such a bin is considered together with one or two other bins.
Preliminaries
We classify the items by their sizes as in the simplified algorithm, but with the specific value of α=3/8: an item is small if its size is in [0,3/8], medium if it is in (3/8,1/2), big if it is in [1/2,5/8), and huge if it is in [5/8,1].
For the description and analysis of ProFit we classify the bins into eight types. At the beginning, we have only empty bins with no items. Then we have bins that are not empty and may be used for packing new items. They are of three major types according to the type of the largest item packed into them: small bins, medium bins and big bins. They are further divided into six different subtypes specified as follows:
Regular small bin:
A bin with only small items of total size at most 3/8.
Regular big bin:
A bin with a single big item and no other items.
Semi-final big bin:
A bin with a single big item and small items of total size at least 1/8 and at most 3/8.
Active big bin:
A bin with one big item and one or more small items of total size less than 1/8.
Active medium bin:
A bin with one medium item and possibly some small items with total size at most 3/8.
Active small bin:
A bin with only small items of total size more than 3/8 but less than 5/8.
As we shall see later, there is always at most one active bin of each major type. The other types of bins can appear in many copies.
The last type of bins are final bins that are required to satisfy the following two properties: (1) The size of the bin is at least 5/8, and (2) small items of size at most 3/8 were removed from the bin in the step when its type was set to a final bin and no small item was removed before that step. Moreover, once a bin type has been changed to final, no more items are ever packed into it.
Usually the type of the bin is uniquely determined by its contents, except that in some cases the condition of the final bins may be satisfied also by a bin of another type (in particular by a semi-final big bin or a medium bin). Thus the algorithm needs to be explicit in particular in specification of when the bin is declared to be final.
One of the invariants of the algorithm is that no other bins than the types described above ever appear, possibly with the exception of the bin where the last item is packed. The algorithm always specifies the type of a bin whose contents change. In most cases, we leave it to the reader to check that the bin indeed satisfies the conditions of its declared type. In particular, this is the case for the new final bins: verifying that both conditions hold easily follows by inspecting the contents of such a bin. To verify that the condition (2) for the final bin holds, we also use the fact that whenever small items are removed from a bin, either the bin is then declared to be final or the algorithm stops; thus it is sufficient to verify that in the step when the bin is declared to be final, at most 3/8 of small items are removed, and this typically holds because there are no more small items in the bin before the step.
The next two lemmata guarantee that once some condition holds, the algorithm will not enter the second phase. This allows us to significantly restrict the possibilities in the second phase.
Proof 8
We claim that the following hold at any moment when an active small bin or a final bin with only small items is created:
(i)
There is no regular big bin and no empty bin.
(ii)
If a medium bin exists, it has small item(s) and size greater than 5/8.
(iii)
Every regular small bin has size at least 3/16.
As the bin is created by packing a small item in Step (4g), no rule of higher priority applied. In particular, (i) holds since Steps (4c-d) do not apply, and (ii) holds since Step (4e) does not apply. As for (iii), its first claim follows from Lemma 2(i), which implies that (iii) holds with the possible exception of the smallest regular bin. But as the item we consider is packed into this bin, turning it into an active small bin or a final bin, all remaining regular small bins have size at least 3/16.
Now we claim that the following, slightly different, properties hold at the end of Phase 1:
(iv)
There is no regular big bin and no empty bin. If there is an active big bin, it was present already at the first time when an active small bin or a final bin with only small items was created.
(v)
If a medium bin exists, either its size is greater than 5/8, or the total size of the small items in it is in [3/16,2/8] and the medium item in it does not fit in the active small bin (if such a bin exists).
(vi)
There is no regular small bin.
As any item can be packed in a regular small bin, (vi) follows. The previous two points follow from (i)–(iii). Specifically, (iv) follows from (i): there were no empty or regular big bins and clearly none can be created later. Moreover, any new active big bin would have to be created in Step (3b) from a regular small bin with size less than 1/8 but there is no such bin due to (iii). As for (v), its first option holds, by (ii), for any medium bin that was present the last time that an active small bin or a final bin with only small items was created. And if the medium bin was created later, it was created by packing a medium item into a regular small bin in Step (2e). As Step (2d) did not apply, the medium item did not fit in the active small bin if there was such a bin. Moreover, the small bin into which the medium item was packed had at least 3/16 of small items by (iii). We may assume it had no more than 2/8 of small items as otherwise its total size would exceed 5/8 and the first option of (v) would apply.
With (iv)–(vi) established, we know that, apart from the final and semi-final bins, only the active bins of each kind may be present; recall that there is at most one active bin of each kind by Lemma 2(ii). Our goal now is to show that since the algorithm did not stop before reaching the end of Phase 1, the Terminal Move can be performed. To this end, we inspect several cases. In each of them, our goal is to show how to pack the current item so that the average size of the active bins is at least 5/8 since all the other bins are no smaller than 5/8. For this reason, there must be at least one active bin since otherwise the algorithm would have stopped by now. The cases below are exhaustive: Case 4 covers the case when there is an active big bin, while Cases 1-3 cover the cases when only active small and medium bin or one of them exist.
Case 1: There is an active small bin and either no other active bin or the other active bins have average size at least 5/8. Put the current item is in the active small bin, removing the small items greedily. This guarantees that the active small bin will have size at least 5/8 afterward.
Case 2: The only active bin is medium. Then its size is smaller than 5/8 since otherwise the algorithm would have terminated. Hence, by v, the total size of the small items in it is in [3/16,2/8). If the current item is huge, pack it by replacing all the items in the active medium bin. If the current item is big, replace the medium item with it. In both subcases the size of the medium bin is at least 5/8. There are no more subcases, as a medium or a small element would be packed into the medium bin in step (2b) or (4e).
Case 3: There are both an active small bin and an active medium bin with size smaller than 5/8. Again, by (v), the total size of the small items in the medium bin is in [3/16,2/8) and the medium item does not fit in the active small bin. In particular, the active small bin has size at least 4/8.
If the current item is huge, pack it into the medium active bin as follows: If the current item is larger than 6/8, remove all other items from the bin, otherwise remove the medium item and keep all the small items. Either way the medium bin now has size greater than 6/8, so the total size of the two bins is greater than 10/8. If the current item is big, pack it into the active small bin, removing all the items packed into it in the step when it became active and later. The size of remaining items in the bin is at most 3/8, so any big item fits. On the other hand, by Lemma 2(i), the total size of remaining small items in both active bins is at least 3/8. Together with the big and medium items we have at least 3/8+4/8+3/8=10/8 and we reach an average size of 5/8. There are no more subcases, as a medium or a small element would be packed into the medium bin in step (2b) or (4e).
Case 4: There is an active big bin. In this case we can ignore the active medium bin completely as its size is greater than 5/8. This follows from the fact that the medium bin (if it exists) has some small items by (v), the fact that the active big bin has less than 1/8 of small items, and Lemma 2(i).
For convenience, in this case we will refer to to the active big bin as the big bin. Similarly, let the small bin denote the active small bin if it exists and an arbitrary final bin with only small items otherwise, and let the smallish item denote the small item that made the small bin active small or final. Note that due to the lemma assumption, the small bin and the smallish item are well defined. Moreover, as there are no regular small or regular big bins, these names should not cause any confusion.
We begin by observing that the total size of the small items in the small bin and the large bin is greater than 5/8. To this end, note that the big bin was active big already at the time when the small bin became active small or final by (iv). Then, since the total size of small items in the big bin is less than 1/8, the size of the small bin right before the smallish item was packed in it was greater than 2/8 by Lemma 2(i). Moreover, as the smallish item was not packed in the big bin in Step (4b), the sum of its size and that of all small items in the big bin is greater than 3/8 and together with more than 2/8 of small items in the small bin, the total size of the small items is at least 5/8. Also note that each of the two bins has size greater than 4/8, thus it is sufficient to pack the current item in either bin so that its size is at least 6/8.
If the current item is huge and larger than 6/8, it is sufficient to let it replace all items in the active big bin. If the current item is huge but smaller than 6/8, pack it in the big bin replacing the big item but keeping all the small items; the total size of the big bin and the small bin is now larger than 10/8 since the total size of the small items in them is greater than 5/8.
If the current item is medium or big, put it in the small bin together with the smallish item, removing all the other small items in the bin. If the current item is big, this clearly results in a bin of size greater than 6/8. If the current item is medium, we note that since Step (2a) did not apply, the total size of the current item and the big item in the big bin is larger than 1. So together with the smallish item, the total size of the two bins is greater than 10/8.
Finally, if the current item is small, let it replace all the small items in the big bin. Note that the current item’s size is greater than 2/8 since otherwise Step (4b) would be possible; thus the resulting size of the big bin is at least 6/8. □
The next lemma finally summarizes the situation at the beginning of Phase 2.
Proof 9
Consider the situation when no option of Phase 1 is possible. We prove that either the Terminal Move is possible or the lemma holds. To prove that the Terminal Move is possible, we only need to show that we can pack the current item so that the average size of the active bins becomes at least 5/8.
First of all, note that there is no active small bin by Lemma 5. Moreover, there are no empty or regular small bins, as otherwise some Phase 1 move would be possible. This establishes (i).
Since no rule of Phase 1 applies, the current item is not small and, if a medium bin exists, the current item is also not medium.
If there is a regular big bin or a medium bin with no small item(s), both (ii) and (iii) are implied by Lemma 3 as follows: (ii)follows directly from Lemma 3(ii) and (iii) holds trivially since Lemma 3(i) implies that there is no medium bin with small item(s).
Thus we can restrict our attention to the case where in addition to final and semi-final bins, we have only an active big bin and/or an active medium bin.
If no active bin exists, the average size is at least 5/8 and the algorithm would have already terminated. Similarly, if both the active big bin and the active medium bin exist, the algorithm would have already terminated: The total size of small items in them is at least 3/8 by Lemma 2(i); their average size is thus at least 5/8.
It remains to consider the case of exactly one active bin.
Suppose that there exists a final bin of size at least 6/8 and there is only one active bin. Then we need only to attain a size of 4/8 in the active bin through the Terminal Move. Since the algorithm did not stop before, the active bin has size smaller than 4/8. In particular, it is a medium bin. As noted before, in such case the current item is big or huge, so even putting it alone in the active medium big would stop the algorithm.
We now inspect the last remaining case in which there is only one active bin and no final bin has size at least 6/8. Then (iii) holds trivially. As all final bins have sizes strictly smaller than 6/8, none of them has more than one medium or big item. Hence, to prove (ii) it suffices to show that every final bin contains a huge item. To this end, we show that a final bin contains no small items. By Lemma 5, there is no final bin with only small items and there is no active small bin. Inspecting the rules for big (Step 4) and small (Step 5) items, we see that without items of other kind, these never create a final bin. To rule out a final bin with a medium item and small item(s), note that it is created only in two cases, both ruled out: (2d) because there is no active small bin, and (4e) because all final bins have size strictly smaller than 6/8. This concludes the proof of the lemma. □
Proof 10
(i) As in Phase 1, we pack small items so that each two bins with small items have at least 3/8 of them, thus there cannot be two active big bins. A medium bin is created only in Step (2c), which can be reached only if no medium bin exists. No other bins exist at the beginning of Phase 2 by Lemma 6(i) and none are also created later.
(ii) If Step (4d) is reached, there is no regular big bin as Step (4b) did not apply. Thus there exist only final, semi-final and active bins. There must exist at least one active bin, as the size of all the other bins is at least 5/8 and the algorithm would have stopped otherwise.
We claim that only a single active bin exists. Assume for the sake of contradiction that this is not the case. Then both the active medium bin and the active big bin contain small item(s), as Steps (4a) and (4c) did not apply. Thus the size of small items in the two active bins is at least 3/8. As there is a big item in the active big bin and a medium item in the active medium bin, the total size of these two active bins is at least 10/8. Therefore, the average size of all bins is at least 5/8. This yields a contradiction since the algorithm would have stopped by now.
As there exists only a single active bin, its size is smaller than 5/8 as the algorithm would have stopped otherwise. So the small item fits. Furthermore, as Steps (4a) and (4c) did not apply, the size of small items is now more than 3/8, so the size of the bin is more than 5/8 and therefore the algorithm stops.
(iii) This holds at the beginning of Phase 2 by Lemma 4 and inspecting the rules of Phase 1. In Phase 2, this is maintained trivially for medium items. For a huge item, notice that if no big bin exists, putting the huge item in a medium bin guarantees average size of bins at least 5/8, so Step (1a) applies. For a small item, this follows from (ii).
(iv) Recall that no new big bin is created in Phase 2. If a medium bin contains some small item(s) at the beginning of Phase 2, there is no regular big bin nor any active big bin by Lemma 6(iii). If a medium bin is created later, it is created from a big bin by replacing the big item by a medium item. If this big bin is regular, the new medium bin contains no small item. Otherwise, by the preference in Step (2c), any remaining regular or active big bin must contain the min-big element. Thus, there is at most one such big bin.
(v) No final bins other than the ones specified in the claim exist at the beginning of Phase 2 by Lemma 6(ii). It also follows from the rules of Phase 2 that no final bins other than the ones specified are created during Phase 2. For the second part of the claim, note that if a second medium element is put in a medium bin with some small item(s), this bin has size at least 6/8. Then there is at most one active or regular big bin of size at least 4/8, and all the other bins have size at least 5/8, by (iv). Thus, the average bin size is at least 5/8 and the algorithm stops. □
The following lemma implies that if there are compatible medium and big items, the algorithm creates at least one final bin of size 6/8.
The next lemma will later guarantee that the charging scheme is well-defined.
Proof 13
Case A. The algorithm stops because the average size of bins is at least 5/8. This includes a successful Terminal Move. The theorem follows because the average size of bins in the optimum is at most 1.
Case B. The algorithm exhausted all items during Phase 1. It follows that all medium, big and huge items were packed and none of them was removed with the possible exception of a medium item that was removed in the Special Move. Small items are also all packed but some of them may have been removed when packing medium, big or huge items and making a bin final. However, in each final bin, a volume of at least 5/8 remains, and a volume of at most 3/8 small items has been removed from it, with the exception of the Special Move, which we handle later. Thus at least 5/8 fraction of the volume of all the items that were packed into the bin remains there, and the ratio 8/5 follows.
It remains to deal with the Special Move. Upon the Special Move, a final bin from which a medium item is removed is created, and all other bins except one are either final or semi-final. The remaining bin is a small bin with volume at least 2/8. Moreover, as the algorithm stops by exhausting all items in Phase 1 by the case assumption, no items were removed from that bin. Hence, the total volume of the two bins right after the Special Move is at least 7/8, and no more than 4/8 volume (of the removed medium item) was removed from them. This yields ratio (7+4)/7<1.6 for the pair of bins. All other bins are handled as above.
Case C. The algorithm exhausted all items during Phase 2.
We use a charging argument.
As an auxiliary notion, we define a mapping of optimal bins with medium items to medium items in the algorithm’s packing. Provisionally, map each optimal bin to a medium item in it; this is possible since all medium items are packed. Lemma 7(i) implies that there is at most one medium bin. If it exists, m is the medium item in it, and an optimal bin is mapped to m, do the following: (1) If there is another medium item a that has no bin mapped to itself, modify the assignment so that the optimal bin of m is mapped to a. (2) Otherwise, if the optimal bin of m contains a big item but another optimal bin contains a medium item a and no big item, map the bin of a to m and the bin of m to a. (Note that if (1) does not apply, no optimal bin contains two medium items.)
Now we define an assignment of optimal bins to algorithm’s bins and pairs of bins. Every optimal bin with a huge item is assigned to the algorithm’s bin with the same item or to the bin where the huge item is assigned by the algorithm; this is possible and one-to-one since all huge items are packed or assigned to a final bin. Every optimal bin with a medium item is assigned to a bin with the medium item to which the bin is mapped in the previous paragraph. Every bin of the algorithm that now has two optimal bins assigned is paired with one remaining big bin; this is possible by Lemma 9. The remaining optimal bins (with no medium or huge item) are assigned arbitrarily one-to-one to the remaining bins; this can be done since there is the same number of optimal and algorithm’s bins.
The charging is defined as follows. All medium, big and huge items in any optimal bin are charged to the bin where the optimal bin is assigned. The small items are charged to the bin where the algorithm packed them even if they were removed later. We argue then that for each bin and each pair of bins the ratio of charged items to the packed items is at most 8/5. Most often we argue that the ratio of charged medium, big and huge items plus the removed small items to the packed medium, big and huge items is at most 8/5. This is sufficient, as adding the items that are packed both in the optimum and in the algorithm can only improve the ratio.
We first prove that the charging above works for all bins and pairs of bins with the exception of the medium bin. In most cases, we ignore the small items packed by the algorithm since considering them can only improve the ratio for each considered pair of bins or bin.
-
A pair of algorithm’s bins has total size at least 10/8 as it contains two medium items and a big item; no small items are removed from these bins. The pair of bins is charged items from two optimal bins, a total of at most 16/8 and the ratio at most 16/10 follows.
-
A final bin with a huge item a is charged at most this huge item or a big item, plus at most 3/8 of removed small items, so the ratio is at most (s
a
+3/8)/s
a
=1+3/(8s
a
)≤1+3/5=1.6, as s
a
≥5/8.
-
A final bin with a huge item assigned is charged this huge item with a size at most 6/8. As the bin has a big item and no small items were removed from it, the ratio is at most 6/4=1.5.
-
A final bin with both medium and big items is charged at most 1 plus 3/8 for removed small items. Thus, the ratio is at most (8+3)/(4+3)<1.6.
-
An unpaired final bin with two medium items is charged at most 1, as no small items are removed from them by Lemma 7(v), yielding ratio at most 8/6<1.6.
-
A big bin is charged at most a big item (possibly different) and no small items are removed, so the ratio is at most 5/4.
This completes the proof if there is no medium bin.
If there is a medium bin, we need to consider it together with another bin or pair of bins. We pair the medium bin with a final bin with medium and big items combined if such a final bin exists. Otherwise we pair it with any pair of bins (necessarily consisting of a final bin with two medium items and a big bin), creating a triple. If also no pair of bins exists, we pair the medium bin with any final or semi-final bin that either has size at least 6/8 or no small item was removed from it.
We claim that the pair or triple of the medium bin is well-defined. Any final bin created in Phase 2 satisfies one of the conditions, any final bin with a medium item or a semi-final bin is eligible as well. Thus the only remaining possibility is that all k−1 bins other than the medium bin are created in Phase 1 by packing a huge item and removing small items including one larger than 2/8. This would in turn imply that upon creating the last such bin, we would use the Special Move and the algorithm would end in Phase 1.
To complete the proof, we need to argue that the triple or pair with the medium bin is charged at the correct ratio. We distinguish two cases.
Case C.1 The medium bin is not assigned an optimal bin with both medium and big items.
Then the medium bin has a medium item of size at least 3/8 and it is charged at most 5/8. This does not guarantee the ratio, but it is very close and we need to save only a little in the triple or pair of the medium bin. Except for the first two types, we argue as above which works since the ratio was not tight. Calculate depending on where the medium bin is:
-
In a triplet with a final bin with two medium items and a big bin we argue as follows: The medium item in the medium bin and the big item in the big bin have total size more than 1 by Lemma7 (v). Together with the two medium items in the final bin, this is at least 14/8. We are charged at most 2 to the pair of bins and at most 5/8 to the medium bin. As no small items were removed from either bin by Lemma 7(v), the ratio is at most 21/14=1.5.
-
In a pair with a final bin B with a huge item, we distinguish two options. If the final bin has size s(B)≥6/8, it is charged at most s(B) for the items in it (including the small ones here) plus at most 3/8 for removed items. Together with the medium bin we have a ratio of at most (s(B)+3/8+5/8)/(s(B)+3/8)=1+5/(8s(B)+3)≤1+5/9<1.6, using s(B)≥6/8. If the final bin has at most 2/8 of small items removed, we get ratio at most (5+2+5)/(5+3)=1.5. No other option is possible due to the choice of a pair for the medium bin.
-
In a pair with a final bin with a huge item assigned. Ignoring the small items, we are charged at most (6+5)/8, and we have at least (4+3)/8 in medium and big items. Thus the ratio is at most 11/7<1.6.
-
In a pair with a final bin with both medium and big items the ratio is at most (8+3+5)/(4+3+3)=1.6.
-
In a pair with a final bin with two medium items, the ratio is at most (8+5)/(6+3)<1.6.
-
In a pair with a big bin the ratio is at most (5+5)/(4+3)<1.6.
Case C.2 There is a medium bin and it is assigned an optimal bin with one medium and one big item. By the construction of the matching of bins with medium items, it follows that the optimum packs all medium items, and each medium item is packed with a big item.
In this case every medium item fits with the min-big item, thus we know by Lemma8(ii) that there is also a final bin with medium and big items. Thus the medium bin is paired with one such bin.
We distinguish two more subcases.
Case C.2.1 One of the optimal bins is assigned to a big bin.
Fix one such bin and analyze it together with the pair of the medium bin and a final bin with both medium and big items. The medium item of the medium bin and the big item of the big bin together have size at least 1 as they do not fit together. The final bin has volume at least 7/8, for a total of at least 15/8. The triple is charged at most 2 to the final and medium bins, a big item of at most 5/8 to the big bin, and at most 3/8 of the removed small items in the final bin. The total charge is at most 24/8, giving a ratio of at most 24/15=1.6.
Case C.2.2 Each optimal bin with no medium item is assigned to a final bin. (Includes the case when each optimal bin has a medium item.)
In this case we charge the small items differently. We simply charge all the items in the optimal bin, including the small ones, to the assigned bin or pair of bins.
The pair of the medium bin has size at least 3/8 for the medium bin and 7/8 for the final bin with both medium and big items, a total of 10/8; the pair of bins is charged at most 2 from the two optimal bins, the ratio is at most 1.6. Any other pairs of algorithm’s bins have total size at least (4+3+3)/8=10/8 for one big item and two medium ones; it is charged at most 2 from the two optimal bins, the ratio is at most 1.6. All the other bins are charged one-to-one to a final bin of size at least 5/8, thus the ratio is again at most 8/5=1.6. □