Bincoloring 1. Sven O. Krumke a Willem E. de Paepe b Jörg Rambau c Leen Stougie d Kaiserslautern, Germany.

Similar documents
Colored Bin Packing: Online Algorithms and Lower Bounds

Online Scheduling of Parallel Jobs on Two Machines is 2-Competitive

Online Interval Coloring and Variants

Online algorithms for parallel job scheduling and strip packing Hurink, J.L.; Paulus, J.J.

A note on semi-online machine covering

On-line Bin-Stretching. Yossi Azar y Oded Regev z. Abstract. We are given a sequence of items that can be packed into m unit size bins.

This means that we can assume each list ) is

Discrete Applied Mathematics. Tighter bounds of the First Fit algorithm for the bin-packing problem

A lower bound for scheduling of unit jobs with immediate decision on parallel machines

A Robust APTAS for the Classical Bin Packing Problem

Minimizing the Maximum Flow Time in the Online-TSP on the Real Line

On improving matchings in trees, via bounded-length augmentations 1

Scheduling Parallel Jobs with Linear Speedup

On Two Class-Constrained Versions of the Multiple Knapsack Problem

A robust APTAS for the classical bin packing problem

Aditya Bhaskara CS 5968/6968, Lecture 1: Introduction and Review 12 January 2016

Semi-Online Multiprocessor Scheduling with Given Total Processing Time

Online Optimization Competitive Analysis and Beyond

Machine Minimization for Scheduling Jobs with Interval Constraints

Polynomial Time Algorithms for Minimum Energy Scheduling

Lecture 2: Paging and AdWords

Centre d Economie de la Sorbonne UMR 8174

Beating the Harmonic lower bound for online bin packing

Alternatives to competitive analysis Georgios D Amanatidis

An algorithm to increase the node-connectivity of a digraph by one

Avoider-Enforcer games played on edge disjoint hypergraphs

MAL TSEV CONSTRAINTS MADE SIMPLE

K-center Hardness and Max-Coverage (Greedy)

NP-Completeness. f(n) \ n n sec sec sec. n sec 24.3 sec 5.2 mins. 2 n sec 17.9 mins 35.

Lecture 6: Greedy Algorithms I

Online Scheduling with Bounded Migration

Online bin packing 24.Januar 2008

CS264: Beyond Worst-Case Analysis Lecture #14: Smoothed Analysis of Pareto Curves

arxiv: v1 [cs.ds] 30 Jun 2016

On-line Scheduling to Minimize Max Flow Time: An Optimal Preemptive Algorithm

2.2 Some Consequences of the Completeness Axiom

CS 374: Algorithms & Models of Computation, Spring 2017 Greedy Algorithms Lecture 19 April 4, 2017 Chandra Chekuri (UIUC) CS374 1 Spring / 1

Online Coloring of Intervals with Bandwidth

Quick Sort Notes , Spring 2010

Optimal on-line algorithms for single-machine scheduling

Online Removable Square Packing

The maximum edge-disjoint paths problem in complete graphs

NP-Completeness. NP-Completeness 1

CMSC 451: Lecture 7 Greedy Algorithms for Scheduling Tuesday, Sep 19, 2017

A Polynomial-Time Algorithm for Pliable Index Coding

Minimizing Mean Flowtime and Makespan on Master-Slave Systems

The Maximum Flow Problem with Disjunctive Constraints

Lecture 1 : Probabilistic Method

Online Dial-a-Ride Problems: Minimizing the Completion Time

Discrepancy Theory in Approximation Algorithms

arxiv: v1 [cs.ds] 6 Jun 2018

Gearing optimization

Rate-monotonic scheduling on uniform multiprocessors

Lower Bounds for q-ary Codes with Large Covering Radius

arxiv: v1 [cs.ds] 25 Jan 2015

Lecture notes for Analysis of Algorithms : Markov decision processes

Online Packet Routing on Linear Arrays and Rings

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

arxiv: v1 [math.oc] 3 Jan 2019

Online k-server routing problems

S. ABERS Vohra [3] then gave an algorithm that is.986-competitive, for all m 70. Karger, Phillips and Torng [] generalized the algorithm and proved a

Decentralized Control of Discrete Event Systems with Bounded or Unbounded Delay Communication

Deciding Emptiness of the Gomory-Chvátal Closure is NP-Complete, Even for a Rational Polyhedron Containing No Integer Point

The minimum G c cut problem

VC-DENSITY FOR TREES

On the Complexity of Computing an Equilibrium in Combinatorial Auctions

Theoretical Computer Science

1 Overview. 2 Learning from Experts. 2.1 Defining a meaningful benchmark. AM 221: Advanced Optimization Spring 2016

An Improved Approximation Algorithm for Maximum Edge 2-Coloring in Simple Graphs

A Different Perspective For Approximating Max Set Packing

12. LOCAL SEARCH. gradient descent Metropolis algorithm Hopfield neural networks maximum cut Nash equilibria

Graph coloring, perfect graphs

Johns Hopkins Math Tournament Proof Round: Automata

Single machine scheduling with forbidden start times

Spanning and Independence Properties of Finite Frames

About the relationship between formal logic and complexity classes

University of Twente. Faculty of Mathematical Sciences. Scheduling split-jobs on parallel machines. University for Technical and Social Sciences

CS264: Beyond Worst-Case Analysis Lecture #15: Smoothed Complexity and Pseudopolynomial-Time Algorithms

CS264: Beyond Worst-Case Analysis Lecture #11: LP Decoding

Upper and Lower Bounds on the Number of Faults. a System Can Withstand Without Repairs. Cambridge, MA 02139

Supplementary lecture notes on linear programming. We will present an algorithm to solve linear programs of the form. maximize.

Note Watson Crick D0L systems with regular triggers

Combinatorial Algorithms for Minimizing the Weighted Sum of Completion Times on a Single Machine

Asymptotic redundancy and prolixity

1 The Knapsack Problem

Non-clairvoyant Scheduling for Minimizing Mean Slowdown

Distribution of Environments in Formal Measures of Intelligence: Extended Version

1 Introduction and Results

Completion Time Scheduling and the WSRPT Algorithm

CS 561, Lecture: Greedy Algorithms. Jared Saia University of New Mexico

A polynomial-time approximation scheme for the two-machine flow shop scheduling problem with an availability constraint

8 Knapsack Problem 8.1 (Knapsack)

SPT is Optimally Competitive for Uniprocessor Flow

Stability with uniform bounds for online dial-a-ride problems under reasonable load

Designing Competitive Online Algorithms via a Primal-Dual Approach. Niv Buchbinder

Today s Outline. CS 561, Lecture 15. Greedy Algorithms. Activity Selection. Greedy Algorithm Intro Activity Selection Knapsack

Data Structures in Java

Multicommodity Flows and Column Generation

Part V. 17 Introduction: What are measures and why measurable sets. Lebesgue Integration Theory

Worst case analysis for a general class of on-line lot-sizing heuristics

Transcription:

Bincoloring 1 Sven O. Krumke a Willem E. de Paepe b Jörg Rambau c Leen Stougie d a Department of Mathematics, University of Kaiserslautern. Paul-Ehrlich-Str. 14, 67653 Kaiserslautern, Germany. Email: krumke@mathematik.uni-kl.de b Capgemini Nederland B.V., Papendorpseweg 100, P.O. Box 2575, 3500GN Utrecht, The Netherlands. Email: willem.de.paepe@capgemini.nl c Department of Mathematics, University of Bayreuth, Universitt Bayreuth, 95440 Bayreuth, Germany. Email: joerg.rambau@uni-bayreuth.de d Department of Mathematics and Computer Science, Technical University of Eindhoven, P. O. Box 513, 5600MB Eindhoven, The Netherlands and Centre for Mathematics and Computer Science (CWI), P. O. Box 94079, NL-1090 GB Amsterdam, The Netherlands. Email: leen@win.tue.nl Abstract We introduce a new problem that was motivated by a (more complicated) problem arising in a robotized assembly environment. The bin coloring problem is to pack unit size colored items into bins, such that the maximum number of different colors per bin is minimized. Each bin has size B N. The packing process is subject to the constraint that at any moment in time at most q N bins are partially filled. Moreover, bins may only be closed if they are filled completely. We settle the computational complexity of the problem and design an approximation algorithm for a natural version which has gives a solution whose value is at most 1 greater than the optimal one. We also investigate the existence of competitive online algorithms, Which must pack each item without knowledge of any future items. We prove an upper bound of 3q 1 and a lower bound of 2q for the competitive ratio of a natural greedy-type algorithm, and show that surprisingly a trivial algorithm which uses only one open bin has a strictly better competitive ratio of 2q 1. Moreover, we show that any deterministic algorithm has a competitive ratio Ω(q) and that randomization does not improve this lower bound even when the adversary is oblivious. Key words: Competitive Analysis, NP-hardness 1 Supported by MRT Network ADONET (MRTN-CT-2003-504438), the Dutch BSIK-BRICKS project, the Dutch mathematics cluster DIAMANT Preprint submitted to Elsevier Preprint 14 February 2007

1 Introduction One of the commissioning departments in the distribution center of Herlitz PBS AG, Falkensee, a main distributor of office supply in Europe, is devoted to greeting cards. The cards are stored in parallel shelving systems. Order pickers on automated guided vehicles collect the orders from the storage systems, following a circular course through the shelves. At the loading zone, which can hold q vehicles, each vehicle is logically loaded with B orders which arrive online. The goal is to avoid congestion among the vehicles (see [1] for details). Since the vehicles are unable to pass each other and the speed of a vehicle is correlated to the number of different stops it must make, this motivates to assign the orders to vehicles in such a way that the vehicles stop as few times as possible. The above situation motivates the following bin coloring problem (Bcp): One receives a finite sequence of unit size items σ = r 1, r 2,... where each item has a color r i N, and is asked to pack them into bins of size B. The goal is to pack the items into the bins most uniformly, that is, to minimize the maximum number of different colors assigned to a bin. The packing process is subject to the constraint that at any moment in time, at most q N bins may be partially filled. Bins may only be closed if they are filled completely. (Notice that without these strict bounded space constraints the problem is trivial since in this case each item can be packed into a separate bin.) In the online version, the online bin coloring problem (OlBcp), each item must be packed without knowledge of any future items. Trivially, any online algorithm for the OlBcp is B-competitive, where B denotes the size of the bins. We study the online and offline bin coloring problem. For the offline problem Bcp we derive complexity and approximability results. For the online problem OlBcp we investigate which competitive ratios are achievable. Our results reveal a curiosity of competitive analysis: a truly stupid algorithm achieves essentially a (non-trivial) best possible competitive ratio for the problem whereas a seemingly reasonable algorithm performs provably worse in terms of competitive analysis. This paper is organized as follows. In Section 2 we formally define the Bcp and OlBcp. Section 3 investigates the complexity of the offline problem Bcp. In Section 4 we describe and analyze the obvious algorithm greedyfit. In Section 5 we introduce and analyze the trivial algorithm onebin which surprisingly obtains a better competitive ratio than greedyfit. Sections 6 and 7 contain general lower bounds for deterministic and randomized algorithms. 2

2 Problem Definition We start by defining the problems under study. Definition 1 ((Online) Bin Coloring Problem) In the bin coloring problem (Bcp B,q ) with parameters B, q N (B, q 2), one is given a sequence σ = r 1,..., r m of unit size items (requests), each with a color r i N, and is asked to pack them into bins with size B, that is, each bin can accommodate exactly B items. The packing is subject to the following constraints: (1) The items must be packed according to the order of their appearance, that is, item i must be packed before item k for all i < k. (2) At most q partially filled bins may be open to further items at any point in time during the packing process. (3) A bin may only be closed if it is filled completely, i.e., if it has been assigned exactly B items. The objective is to minimize the maximum number of different colors assigned to a bin. In the online bin coloring problem ( OlBcp B,q ), an online algorithm must pack each item r i (irrevocably) without knowledge of requests r k with k > i. In the sequel it will be helpful to use the following view on the bins used to process an input sequence σ. Each open bin has an index x, where the number x satisfies x {1,..., q}. Each time a bin with index x is closed (since it is filled completely) and a new bin is opened the new bin will also have index x. If no confusion can occur, we will refer to a bin with index x as bin x. 3 Offline-Bin Coloring We first consider the general offline problem, and show that it is NP-complete. Then we consider the problem in a slightly different setting, where the number of items is exactly qb, and items have to be packed in exactly q bins. We show that even this problem is NP-complete. Theorem 2 The decision version of Bcp B,q is NP-complete. PROOF. We provide a polynomial time reduction from 3-Partition which is well known to be NP-complete in the strong sense [2, Problem SP15]. An instance of 3-Partition is given by a set of numbers S = {a 1,..., a 3t } with 3

i a i = tm, M/4 < a i < M/2 for all i, and a i Z + for all i and a bound M Z +. The question asked is whether S can be partitioned into t disjoint sets S 1,..., S t such that i:a i S j a i = M. We can assume that M 4. We construct an instance of Bcp B,q with q = t bins of size B = M as follows. The input sequence σ starts with a 1 items of color 1, followed by a 2 items of color 2 and so on until a 3t items of color 3t. Then follow 3t additional items, each with a new color not used before. Thus, there are 6t colors overall. We will show that the instance of Bcp B,q constructed has a solution of cost at most 3 if and only if the original instance of 3-Partition has a yes-answer. Suppose that there is a yes-answer to the instance of 3-Partition and let S 1,..., S t be sets such that i:a i S j a i = B. We put all items corresponding to a i S j into bin j, for all i = 1,..., 3t. After this, each bin contains exactly B items of at most three different colors. Consequently, all bins will be closed, and q empty bins can be used for placing the last 3t items. Assigning three of the remaining items to every bin will give a solution of cost 3. If there is no yes-answer for 3-Partition, one of the following is true. There is at least one non-empty bin after the first tb items, or there has been a bin that contained items of at least four different colors. In the latter case, we cannot have a solution of cost at most 3, so we can assume that all bins contain items of at most three colors, and there is at least one non-empty bin. Since M/4 < a i < M/2 for all i, we know that the non-empty bins that contain items of only one different color have at least M/2 + 1 = B/2 + 1 3 empty places, and that the non-empty bins that contain items of two different colors have at least two empty places. Non-empty bins containing items of three different colors must have at least one empty place, otherwise the bin would have been replaced by an empty bin. In order to establish a solution of cost at most 3, none of the non-empty bins can be completely filled (and replaced) by assigning one or more of the last 3t items to it, since these items all have a different color. As a consequence, all 3t items must be distributed over the t currently open bins. Since at least one bin is non-empty, at least one bin ends up with four or more different colors. Now consider the problem where the sequence σ consists of exactly qb items, and all items must be assigned to no more than q bins. We call this the fitting bincoloring problem. Observe that for the fitting bincoloring problem the order in which the items are given is irrelevant. First we show that deciding whether or not there exists a solution of cost at most 2 is NP-compete. Theorem 3 The decision version of the fitting bincoloring problem is NPcomplete. 4

PROOF. Again we use a reduction from 3-Partition. Given any instance of 3-Partition with 3t i=1 a i = tm and M/4 < a i < M/2, we construct an instance of the fitting bincoloring problem with q = 3t bins with capacity B = M/2. We will provide an input sequence σ such that the fitting bincoloring instance has a solution of cost at most two if and only if the instance of 3-Partition has a solution. The sequence σ consists of a set α i of 1 M/2 a i = B a i B/2 1 items of color i, for i = 1,..., 3t, and of a set β i of M = 2B items of color 3t + i, for i = 1,..., t. Suppose that the instance of 3-Partition has a solution S 1,..., S t. We first assign all items of α i to bin i. Hence, bin i has exactly a i free space left. Now, for j = 1,..., t we consider set S j = {a j1, a j2, a j3 } in the solution of 3-Partition and we distribute the items of β j over bins j 1, j 2 and j 3. Since a j1 + a j2 + a j3 = M = 2B this completely fills up the corresponding bins. Hence, we obtain a solution of cost 2. Conversely, suppose that there is a solution of cost at most 2. Each set α i has at least one item, and at most B/2 1 items, i = 1,..., 3t. Hence each of these sets can fill only less than half of a bin, hence in any solution of cost at most 2 they have to be allocated to 3t separate bins. To reach a solution of cost 2, the items of every set β j, j = 1,..., t, have to be assigned to bins such that those bins are completely filled by these items together with the already present α-items. It is easy to see that each set β j must be distributed over exactly 3 bins and that this implies that the instance of 3-Partition has a solution. The fitting bincoloring problem has been investigated in [4], where the authors provided a polynomial time algorithm which for every instance finds a solution of cost at most OPT(σ) + 1. Here, we give a much simpler two-step strategy roundrobin which achieves the same performance of OPT(σ) + 1 for the fitting bincoloring problem. We note that it is trivial to find the optimal solution if there exists a solution of value 1. Theorem 3 implies a lower bound of 3/2 on the approximation ratio. Theorem 4 Given an instance of the fitting bincoloring problem with input sequence σ, strategy roundrobin finds a solution of cost at most OPT(σ) + 1. PROOF. Let C 1,..., C k be the color sets in the given instance. Observe that OPT(σ) k/q. Suppose that at the moment that Step 1 of roundrobin ends, already the items C 1,..., C s have been assigned to bins. At this moment, by construction the following properties are satisfied: 5

Algorithm roundrobin Step 1: Group the items by color, and sort the sets by increasing cardinality. Let C 1,..., C k be the monochromatic sets such that C 1 C 2 C k. Fill the bins with monochromatic sets in a round robin fashion, i.e., bin 1 receives the items of set C 1, bin 2 gets the items of set C 2, etc., until the current set does not fit completely into the current bin. Notice that at every moment, a set of items is assigned to the bin with the least number of items. Call all bins with B items closed. The remaining bins are divided into available and unavailable bins. A bin with the same amount of colors as the current bin is termed available, otherwise the bin is unavailable. Notice that the unavailable bins contain one more color than the available bins. Step 2: If the number of different colors of the items yet to be assigned is at most the number of available bins, assign the remaining monochromatic sets to the bins as follows. If there are unavailable bins remaining, each set will be used to fill up at least one unavailable bin, and the remaining items of this color are assigned to an available bin, that will be marked as unavailable from that point. The bin that is filled is marked as closed. Continue like this until all items are assigned. If there are no unavailable bins left, use an available bin instead of an unavailable bin. If the number of remaining colors is greater than the number of available bins, fill the bins in a round robin fashion, starting from the bin with the least number of items, and assigning the remaining items of a color set to the next bin. No bin is able to accommodate any of the remaining sets C s+1,..., C k completely. No more than q different colors are remaining. The available bins have s/q different colors, the unavailable bins have s/q + 1 different colors. OPT(σ) s/q + 1. If the number of remaining colors is at most the number of available bins, at most two new colors are assigned to any originally available bin during Step 2, and at most one new color is assigned to any originally unavailable bin. The maximum number of colors in a bin is therefore at most s/q +2 = OPT(σ)+1. If the number of remaining colors is greater than the number of available bins, then the total number of different colors is at least ( s/q + 1)q, and hence OPT(σ) s/q + 2. Each bin gets at most two new colors, resulting in a solution of at most s/q + 3 = OPT(σ) + 1. 6

4 The Algorithm greedyfit We now turn to the online problem OlBcp. In this section we introduce a natural greedy-type strategy, which we call greedyfit, and show that the competitive ratio of this strategy is at most 3q but no smaller than 2q (provided the capacity B is sufficiently large). Algorithm greedyfit If upon the arrival of request r i the color r i is already contained in one of the currently open bins, say bin b, then put r i into bin b. Otherwise put item r i into a bin that contains the least number of different colors (which means opening a new bin if currently less than q bins are non-empty). Ties are broken arbitrarily. The analysis of the competitive ratio of greedyfit is essentially via a pigeonhole principle argument. We first show a lower bound on the number of bins that any algorithm can use to distribute the items in a contiguous subsequence and then relate this number to the number of colors in the input sequence. Lemma 5 Let σ = r 1,..., r m be any request sequence for the OlBcp B,q and let σ = r i,..., r i+l be any contiguous subsequence of σ. Then any algorithm packs the items of σ into at most 2q + (l 2q)/B different bins. PROOF. Let ALG be any algorithm and let b 1,..., b t be the set of open bins for ALG just prior to the arrival of the first item of σ. Denote by f(b j ) {1,..., B 1} the empty space in bin b j at that moment in time. To close an open bin b j, ALG needs f(b j ) items. Opening and closing an additional new bin needs B items. To achieve the maximum number of bins ( 2q), ALG must first close each open bin and put at least one item into each newly opened bin. From this moment in time, opening a new bin requires B new items. Thus, it follows that the maximum number of bins ALG can use is bounded from above as claimed in the lemma. Theorem 6 Algorithm greedyfit is c-competitive for the OlBcp B,q with c = min{2q + (qb 3q + 1)/B, B}. PROOF. Let σ be any request sequence and suppose greedyfit(σ) = w. It suffices to consider the case w 2. Let s be the smallest integer such that greedyfit(r 1,..., r s 1 ) = w 1 and greedyfit(r 1,..., r s ) = w. By the construction of greedyfit, after processing r 1,..., r s 1 each of the currently open bins must contain exactly w 1 different colors. Moreover, since w 2, after processing additionally request r s, greedyfit has exactly q open bins (where, 7

as an exception, we count here the bin where r s is packed as open even if by this assignment it is just closed). Denote those bins by b 1,..., b q. Let bin b j be the bin among b 1,..., b q that has been opened last by greedyfit. Let r s be the first item that was assigned to b j. Then, the subsequence σ = r s,..., r s consists of at most qb (q 1) items, since between r s and r s no bin is closed and at the moment r s was processed, q 1 bins already contained at least one item. Moreover, σ contains items with at least w different colors. By Lemma 5 OPT distributes the items of σ into at most 2q + (qb 3q + 1)/B bins. Consequently, OPT(σ) w 2q + (qb 3q + 1)/B, which proves the theorem. Corollary 7 Algorithm greedyfit is c-competitive for the OlBcp B,q with c = min{3q 1, B}. We continue to prove a lower bound on the competitive ratio of algorithm greedyfit. This lower bound shows that the analysis of the previous theorem is essentially tight. Theorem 8 greedyfit has a competitive ratio greater or equal to 2q for the OlBcp B,q if B 2q 3 q 2 q + 1. PROOF. We construct a request sequence σ that consists of a finite number M of phases in each of which qb requests are given. The sequence is constructed in such a way that after each phase the adversary has q empty bins. Each phase consists of two steps. In the first step q 2 items are presented, each with a new color which has not been used before. In the second step qb q 2 items are presented, all with a color that has occurred before. We will show that we can choose the items given in Step 2 of every phase such that the following properties hold for the bins of greedyfit: Property 1 The bins with indices 1,..., q 1 are never closed. Property 2 The bins with indices 1,..., q 1 contain only items of different colors. Property 3 There is an M N such that during Phase M greedyfit assigns for the first time an item with a new color to a bin that already contains items with 2q 2 1 different colors. Property 4 There is an assignment of the items of σ such that no bin contains items with more than q different colors. 8

We analyze the behavior of greedyfit by distinguishing between the items assigned to the bin with index q and the items assigned to bins with indices 1 through q 1. Let L k be the set of colors of the items assigned to bins 1,..., q 1 and let R k be the set of colors assigned to bin q during Step 1 of Phase k. We now describe a general construction of the request sequence given in Step 2 of a phase. During Step 1 of Phase k there are items with R k different colors assigned to bin q. For the moment, suppose that R k q (see Lemma 11 (iv)). We now partition the at most q 2 colors in R k into q disjoint non-empty sets S 1,..., S q. We give qb q 2 2q 2 items with colors from R k such that the number of items with colors from S j is B q for every j, and the last R k items all have a different color. By Lemma 11 (iii) below, greedyfit will pack all items given in Step 2 into bin q. Hence bins 1,..., q 1 only get assigned items during Step 1, which implies the properties 1 and 2. The adversary assigns the items of Step 1 such that every bin receives q items, and the items with colors in the color set S j go to bin j. Clearly, the items in every bin have no more than q different colors. The items given in Step 2 can by construction of the sequence be assigned to the bins of the adversary such that all bins are completely filled, and the number of different colors per bin does not increase (this ensures that property 4 is satisfied). The rest of the proof is decomposed in several lemmas. Lemma 9 At the end of Phase k where k = 1,..., M 1, bin q of greedyfit contains exactly B j k L j items, and this number is at least q 2. PROOF. After Phase k, exactly kqb items have been given. Moreover, after k phases bins 1 through q 1 contain exactly j k L j items because the items of Step 2 are always packed into bin q by greedyfit. Thus, the number of items in bin q of greedyfit equals kqb L j mod B B L j j k j k }{{} <B mod B. We show that B j k L j q 2. This implies that B j k L j mod B = B j k L j. Since k < M we know that each of the bins 1 through q 1 contains at most 2q 2 1 colors. Thus, j k L j (2q 2 1)(q 1) = 2q 3 2q 2 q +1. It follows from the assumption on B that B j k L j q 2. 9

Corollary 10 For any Phase k < M, bin q is never closed by greedyfit before the end of Step 1 of Phase k. PROOF. The claim clearly holds for the first phase. Hence for the remainder we consider the case k > 1. Since there are exactly q 2 items presented in Step 1 of any phase, the claim is true by Lemma 9 as soon as j k L j q 2 at the beginning of Phase k: in that case, there is even enough space in bin q to accommodate all items given in Step 1. We show that L 1 + L 2 q 2 which implies that j k L j q 2 for k 2. After Phase 1, each bin of greedyfit contains q colors, which yields L 1 = q(q 1). It is easy to see that all items presented in Step 2 of the first phase are packed into bin q by greedyfit: All these items have colors from R 1 where R 1 = q. Either a color from R 1 is currently already present in bin q or bin q has less than q different colors, while all other bins contain q colors. In either case, greedyfit packs the corresponding item into bin q. By Lemma 9, at the end of Phase 1 bin q contains at least q 2 items. Since the last R 1 = q items presented in Step 2 of the first phase have all different colors (and all of these are packed into bin q as shown above) we can conclude that at the beginning of Phase 2 bin q of greedyfit already contains q colors. Thus, in Step 1 of Phase 2 greedyfit again puts q items into each of its bins. At this point, the total number of distinct colors in the first q 1 bins is at least (q 1)q + (q 1)q = 2q 2 2q q 2 for q > 1, so that L 1 + L 2 q 2. As noted above, this implies the claim. The success of our construction heavily relies on the fact that at the beginning of each phase, bin q of greedyfit contains at least q colors. We show that this is indeed true. Lemma 11 For k 1 the following statements are true: (i) At the beginning of Phase k bin q of greedyfit contains exactly the colors from R k 1 (where R 0 := ). (ii) After Step 1 of Phase k, each of the bins 1,..., q 1 of greedyfit contains at least R k + R k 1 1 different colors. (iii) In Step 2 of Phase k greedyfit packs all items into bin q. (iv) R k q. PROOF. The proof is by induction on k. All claims are easily seen to be true for k = 1. Hence, in the inductive step we assume that statements (i) (iv) are 10

true for some k 1 and we consider Phase k + 1. (i) By the induction hypothesis (iii) all items from Step 2 presented in Phase k were packed into bin q by greedyfit. Since at the end of Phase k bin q contains at least q 2 R k items (see Lemma 9) and the last R k items presented in Phase k had different colors, it follows that at the beginning of Phase k + 1, bin q contains at least all colors from R k. On the other hand, since all the Bq q 2 > B items from Step 2 of phase k were packed into bin q by greedyfit, this bin was closed during this process and consequently can only contain colors from R k. (ii) By Corollary 10 bin q is not closed before the end of Step 1. After Step 1 all colors from R k+1 are already in bin q by construction. Since by (i) before Step 1 also all colors from R k were contained in bin q, it follows that bin q contains at least R k + R k+1 different colors at the end of Step 1. By construction of greedyfit each of the bins 1,..., q 1 must then contain at least R k + R k+1 1 different colors. (iii) When Step 2 starts, all colors from R k+1 are already in bin q by construction. Therefore, greedyfit will initially pack items with colors from R k+1 into bin q as long as this bin is not yet filled up. We have to show that after bin q has been closed the number of colors in any other bin is always larger than in bin q. This follows from (ii), since by (ii) each of the bins 1,..., q 1 has at least R k + R k+1 1 colors after Step 2 of Phase k + 1 and by the induction hypothesis (iv) the estimate R k q holds, which gives R k + R k+1 1 R k+1 + q 1 > R k+1. (iv) At the beginning of Phase k +1, bin q contains exactly R k colors by (i). By the induction hypothesis (ii) and (iii) each of the bins 1,..., q 1 contains at least R k + R k 1 1 R k colors. Hence, at the beginning of Phase k +1, the minimum number of colors in bins 1,..., q 1 is at least the number of colors in bin q. It follows from the definition of greedyfit that during Step 1 of Phase k + 1, bin q is assigned at least the q 2 /q = q colors. In other words, R k+1 q. To this point we have shown that we can actually construct the sequence as suggested, and that the optimal offline cost on this sequence is no more than q. Now we need to prove that there is a number M N such that after M phases there is a bin from greedyfit that contains items with 2q 2 different colors. We will do this by establishing the following lemma: Lemma 12 In every two subsequent Phases k and k+1, either L k L k+1 > 0 or bin q contains items with 2q 2 different colors during one of the two phases. PROOF. Suppose that there is a Phase k in which L k = 0. This means that 11

all q 2 items given in Step 1 are assigned to bin q ( R k = q 2 ). By Lemma 11 (i), at the beginning of Phase k + 1, bin q still contains q 2 different colors. If in Step 1 of Phase k + 1 again all q 2 items are assigned to bin q, bin q contains items with 2q 2 different colors (recall that bin q is never closed before the end of Step 1 by Corollary 10). If less than q 2 items are assigned to bin q then one of the other bins gets at least one item, and L k+1 > 0. We can conclude from Lemma 12 that at least once every two phases the number of items in the bins 1 through q 1 grows. Since these bins are never closed (property 1), and all items have a unique color (property 2), after a finite number M of phases, one of the bins of greedyfit must contain items with 2q 2 different colors. This completes the proof of the Theorem 8. 5 The Trivial Algorithm onebin This section is devoted to arguably the simplest (and most trivial) algorithm for the OlBcp, which surprisingly has a better competitive ratio than greedyfit. Moreover, as we will see later this algorithm achieves essentially the best competitive ratio for the problem. Algorithm onebin The algorithm uses only at most one open bin at any point in time. The next item r i is packed into the open bin. A new bin is opened only if the previous item has closed the bin by filling it up completely. The proof of the upper bound on the competitive ratio of onebin is along the same lines as that of greedyfit. Lemma 13 Let σ = r 1,..., r m be any request sequence. Then for i 0 any algorithm packs the items r ib+1,..., r (i+1)b into at most min{2q 1, B} bins. PROOF. It is trivial that the B items r ib+1,..., r (i+1)b can be packed into at most B different bins. Hence we can assume that 2q 1 B, which means q (B 1)/2 B. Consider the subsequence σ = r ib+1,..., r (i+1)b of σ. Let ALG be any algorithm and suppose that just prior to the arrival of the first item of σ, algorithm ALG has t open bins. If t = 0, the claim of the lemma trivially follows, so we can assume for the rest of the proof that t 1. Denote the open bins by b 1,..., b t. Let f(b j ) {1,..., B 1} be the number of empty places in bin b j, 12

j = 1,..., t. Notice that t f(b j ) 0 mod B. (1) j=1 Suppose that ALG uses at least 2q bins to distribute the items of σ. By arguments similar to those given in Lemma 5, ALG can maximize the number of bins used only by closing each currently open bin and put at least one item into each of the newly opened bins. To obtain at least 2q bins at least tj=1 f(b j )+(q t)+q items are required. Since σ contains B items and t q it follows that t f(b j ) + q B. (2) j=1 Since by (1) the sum t j=1 f(b j ) is a multiple of B and q 1, the only possibility that the left hand side of (2) can be bounded from above by B is that t j=1 f(b j ) = 0. However, this is a contradiction to f(b j ) 1 for j = 1,..., t. As a consequence of the previous lemma we obtain the following bound on the competitive ratio of onebin. Theorem 14 Algorithm onebin is c-competitive for the OlBcp B,q where c = min{2q 1, B}. PROOF. Let σ = r 1,..., r m be any request sequence for the OlBcp B,q and suppose that onebin(σ) = w. Let σ = r ib+1,..., r (i+1)b of σ be the subsequence on which onebin gets w different colors. Clearly, σ contains items with exactly w colors. By Lemma 13 OPT distributes the items of σ into at most min{2q 1, B} different bins. Hence, one of those bins must be filled with at least w colors. min{2q 1,B} The competitive ratio proved in the previous theorem is tight as the following example shows. Let B 2q 1. First we give (q 1)B items. The items have q different colors, every color but one occurs B 1 times, one color occurs only q 1 times. After this, in a second step q items with all the different colors used before are requested. Finally, in the third step q 1 items with new (previously unused) colors are given. After the first (q 1)B items by definition onebin has only empty bins. The adversary assigns all items of the same color to the same bin, using one color per bin. When the second set of of q items arrives, the adversary can now close q 1 bins, still using only one color per bin. onebin ends up with q different colors in its bin. 13

The adversary can assign every item given in the third step to an empty bin, thus still having only one different color per bin, while onebin puts these items in the bin where already q different colors where present. 6 A General Lower Bound for Deterministic Algorithms In this section we prove a general lower bound on the competitive ratio of any deterministic online algorithm for the OlBcp. We establish a lemma which immediately leads to the desired lower bound but which is even more powerful. In particular, this lemma will allow us to derive essentially the same lower bound for randomized algorithms in Section 7. In the sequel we will have to refer to the state of (the bins managed by) an algorithm ALG after processing a prefix of a request sequence σ. To this end we introduce the notion of a C-configuration. Definition 15 (C-configuration) Let C be a set of colors. A C-configuration is a packing of items with colors from C into at most q bins. More formally, a C-configuration can be defined as a mapping K : {1,..., q} S B, where S B = { S : S is a multiset over C containing at most B elements from C } with the interpretation that K(j) is the multiset of colors contained in bin j. We omit the reference to the set C if it is clear from the context. We are now ready to prove the key lemma which will be used in our lower bound constructions. Lemma 16 Let B, q, s N be numbers such that s 1 and the inequality B/q s 1 holds. There exists a finite set C of colors and a constant L N with the following property: For any deterministic algorithm ALG and any C- configuration K there exists an input sequence σ ALG,K of OlBcp B,q such that (i) The sequence σ ALG,K uses only colors from C and σ ALG,K L, that is, σ ALG,K consists of at most L requests. (ii) If ALG starts with initial C-configuration K then ALG(σ ALG,K ) (s 1)q. (iii) If OPT starts with the empty configuration (i.e., all bins are empty), then OPT(σ ALG,K ) s. Additionally, OPT can process the sequence in such a way that at the end again the empty configuration is attained. Moreover, all of the above statements remain true even in the case that the online algorithm is allowed to use q q bins instead of q (while the offline adversary still only uses q bins). In this case, the constants C and K depend only on q but not on the particular algorithm ALG. 14

PROOF. Let C be a set of (s 1) 2 q 2 q colors and ALG be any deterministic online algorithm which starts with some initial C-configuration K. The construction of the request sequence σ ALG,K works in phases, where at the beginning of each phase the offline adversary has all bins empty. During the run of the request sequence, a subset of the currently open bins of ALG will be marked. We will denote by P k the subset of marked bins at the beginning of Phase k. Then, P 1 = and we are going to show that during some Phase M, one bin in P M will contain at least (s 1)q colors. In order to assure that this goal can in principle be achieved, we keep the invariant that each bin b P k has the property that the number of different colors in b plus the free space in b is at least (s 1)q. In other words, each bin b P k could potentially still be forced to contain at least (s 1)q different colors. For technical reasons, P k is only a subset of the bins with this property. For bin j of ALG we denote by n(j) the number of different colors currently in bin j and by f(j) the space left in bin j. Then every bin j P k satisfies n(j) + f(j) (s 1)q. By min P k := min j Pk n(j) we denote the minimum number of colors in a bin from P k. The idea of the construction is the following (cf. Claim 18 below): We will force that in each phase either P k or min P k increases. Hence, after a finite number of phases we must have min P k (s 1)q. On the other hand, we will ensure that the optimal offline cost remains bounded by s during the whole process. We now describe Phase k with 1 k q(s 1)q. The adversary selects a set of (s 1)q new colors C k = {c 1,..., c (s 1)q } from C not used in any phase before and starts to present one item of each color in the order c 1, c 2,..., c (s 1)q, c 1, c 2,..., c (s 1)q, c 1, c 2,... (3) until one of the following cases appears: Case 1 ALG puts an item into a bin p P k. In this case we let Q := P k \ { j P k : n(j) < n(p) }, that is, we remove all bins from P k which have less than n(p) colors. Notice that min j Q n(j) > min P k, since the number of different colors in bin p increases. Case 2 ALG puts an item into some bin j / P k which satisfies n(j) + f(j) (s 1)q. (4) In this case we set Q := P k {j} (that is, we tentatively add bin j to the set P k ). Notice that after a finite number of requests one of these two cases must occur: 15

Let b 1,..., b t be the set of currently open bins of ALG. If ALG never puts an item into a bin from P k then at some point all bins of {b 1,..., b t }\P k are filled and a new bin, say bin j, must be opened by ALG by putting the new item into bin j. But at this moment bin j satisfies satisfies n(j) = 1, f(j) = B 1 and hence n(j) + f(j) = B (s 1)q which gives (4). Since the adversary started the phase with all bins empty and during the current phase we have given no more than (s 1)q colors, the adversary can assign the items to bins such that no bin contains more than s 1 different colors (we will describe below how this is done precisely). Notice that due to our stopping criterions from above (Case 1 and Case 2) it might be the case that in fact we have presented less than (s 1)q colors so far. In the sequel we imagine that each currently open bin of the adversary has an index x, where 1 x q. Let ϕ: C k {1,..., q} be any mapping of the colors from C k to the offline bin index such that ϕ 1 ({x}) s 1 for j = 1,..., q. We imagine color c r to belong to the bin with index ϕ(c r ) even if no item of this color has been presented (yet). For those items presented already in Phase k, each item with color c r goes into the currently open bin with index ϕ(c r ). If there is no open bin with index ϕ(c r ) when the item arrives a new bin with index ϕ(c r ) is opened by the adversary to accommodate the item. Our goal now is to clear all open offline bins so that we can start a new phase. During our clearing loop the offline bin with index x might be closed and replaced by an empty bin multiple times. Each time a bin with index x is replaced by an empty bin, the new bin will also have index x. The bin with index x receives a color not in ϕ 1 ({x}) at most once, ensuring that the optimum offline cost still remains bounded from above by s. The clearing loop works as follows: (1) (Start of clearing loop iteration) Choose a color c C k which is not contained in any bin from Q. If there is no such color, goto the good end of the clearing loop (Step 4). (2) Let F qb denote the current total empty space in the open offline bins. Present items of color c until one of the following things happens: Case (a): At some point in time ALG puts the lth item with color c into a bin j Q for some 1 l < F. Notice that the number of different colors in j increases. Let Q := Q \ {b Q : n(b) < n(j)}, in other words, we remove all bins b from Q which currently have less than n(j) colors. This guarantees that min n(b) > min n(b) min P k. (5) b Q b Q 16

The adversary puts all l items with color c into bins with index ϕ(c ). Notice that during this process the open bin with index ϕ(c ) might be filled up and replaced by a new empty bin with the same index. Set Q := Q and go to the start of the next clearing loop iteration (Step 1). Notice that the number of colors from C k which are not contained in Q decreases by one, but min b Q n(b) increases. Case (b): F items of color c have been presented, but ALG has not put any of these items into a bin from Q. In this case, the offline adversary processes these items differently from Case (a): The F items of color c are used to fill up the exactly F empty places in all currently open offline bins. Since up to this point, each offline bin with index x had received colors only from the s 1 element set ϕ 1 ({x}), it follows that no offline bin has contained more than s different colors. We close the clearing loop by proceeding as specified at the standard end (Step 3). (3) (Standard end of clearing loop iteration) In case we have reached this step, we are in the situation that all offline bins have been cleared (we can originate only from Case (b) above). We set P k+1 := Q and end the clearing loop and the current Phase k. (4) (Good end of clearing loop iteration) Stop the current phase and issue additional requests such that all offline bins are closed without increasing the offline cost. After this, end the sequence. We analyze the different possible endings of the clearing loop. First we show that in case of a good end we have successfully constructed a sufficiently bad sequence for ALG. Claim 17 If the clearing loop finishes with a good end, then one bin in Q contains at least (s 1)q different colors. PROOF. If the clearing loop finishes with a good end, then we have reached the point that all colors from C k are contained in a bin from Q. Before the first iteration, exactly one color from C k was contained in Q. The number of colors from C k which are contained in bins from Q can only increase by one (which is in Case (a) above) if min b Q n(b) increases. Hence, if all colors from C k are contained in bins from Q, min b Q n(b) must have increased (s 1)q 1 times, which implies min b Q n(b) = (s 1)q. In other words, one of ALG s bins in Q contains at least (s 1)q different colors. What happens if the clearing loop finishes with a standard end? 17

Claim 18 If the clearing loop of Phase k completes with a standard end, then min P k+1 > min P k or P k+1 > P k. Before we prove Claim 18, let us show how this claim implies the result of the lemma. Since the case P k+1 > P k can happen at most q times, it follows that after at most q phases, min P k must increase. On the other hand, since min P k never decreases by our construction and the offline cost always remains bounded from above by s, after at most q(s 1)q phases we must be in the situation that min P k (s 1)q, which implies a good end. Since in each phase at most (s 1)q new colors are used, it follows that our initial set C of (s 1) 2 q 2 q colors suffices to construct the sequence σ ALG,K. Clearly, the length of σ ALG,K can be bounded by a constant L independent of ALG and K. PROOF. [Proof of Claim 18] Suppose that the sequence (3) given at the beginning of the phase was ended because Case 1 occurred, i.e., ALG put one of the new items into a bin from P k. In this case min b Q n(b) > min P k. Since during the clearing loop min b Q n(b) can never decrease and P k+1 is initialized with the result of Q at the standard end of the clearing loop, the claim follows. The remaining case is that sequence (3) was ended because of a Case 2- situation. Then Q = P k {j} for some j / P k and hence Q > P k. During the clearing loop Q can only decrease in size if min i Q n(i) increases. It follows that either P k+1 = P k + 1 or min P k+1 > min P k which is what we claimed. This completes the proof of Lemma 16. As an immediate consequence of Lemma 16 we obtain the following lower bound result for the competitive ratio of any deterministic algorithm: Theorem 19 Let B, q, s N such that s 1 and the inequality B/q s 1 holds. No deterministic algorithm for OlBcp B,q can achieve a competitive ratio less than s 1 q. Consequently, the competitive ratio of any deterministic s algorithm for fixed B and q is at least ( ) 1 q B+q q. In particular, for the general case with no restrictions on the relation of the capacity B to the number of bins q, there can be no deterministic algorithm for OlBcp B,q that achieves a competitive ratio less than q. All of the above claims remain valid, even if the online algorithm is allowed to use an arbitrary (but fixed) number q q of open bins. 18

7 A General Lower Bound for Randomized Algorithms In this section we show lower bounds for the competitive ratio of any randomized algorithm against an oblivious adversary for the OlBcp B,q. To this end we first recall Yao s Principle: Theorem 20 (Yao s Principle) Let { ALG y : y Y } denote the set of deterministic online algorithms for an online minimization problem. If X is a probability distribution over input sequences { σ x : x X } and c 1 is a real number such that inf E y Y X [ALG y (σ x )] c E X [OPT(σ x )], (6) then c is a lower bound on the competitive ratio of any randomized algorithm against an oblivious adversary. Theorem 21 Let B, q, s N such that s 1 and the inequality B/q s 1 holds. Then no randomized algorithm for OlBcp B,q can achieve a competitive ratio less than s 1 q against an oblivious adversary. s In particular for fixed B and q, the competitive ratio against an oblivious adversary is at least ( ) 1 q. q B+q All of the above claims remain valid, even if the online algorithm is allowed to use an arbitrary (but fixed) number q q of open bins. PROOF. Let A := { ALG y : y Y } be the set of deterministic algorithms for the OlBcp B,q. We will show that there is a probability distribution X over a certain set of request sequences { σ x : x X } such that for any algorithm ALG y A and, moreover, E X [ALG y (σ x )] (s 1)q, E X [OPT(σ x )] s. The claim of the theorem then follows by Yao s Principle. Let us recall the essence of Lemma 16. The lemma establishes the existence of a finite color set C and a constant L such that for a fixed C-configuration K, any deterministic algorithm can be fooled by one of at most C L sequences. Since there are no more than C qb configurations, a fixed finite set of at most N := C L+qB sequences Σ = {σ 1,..., σ N } suffices to fool any deterministic algorithm provided the initial configuration is known. 19

Let X be a probability distribution over the set of finite request sequences { σ i1, σ i2,..., σ ik : k N, 1 i j N } such that σ ij is chosen from Σ uniformly and independently of all previous subsequences σ i1,..., σ ij 1. We call subsequence σ ik the kth phase. Let ALG y A be arbitrary. Define ɛ k by ALG y has at least one bin with ɛ k := Pr X. at least (s 1)q colors during Phase k The probability that ALG y has one bin with at least (s 1)q colors on any given phase is at least 1/N, whence ɛ k 1/N for all k. Let p k := Pr X [ ALGy (σ i1... σ ik 1 σ ik ) (s 1)q ]. Then the probabilities p k satisfy the following recursion: p 0 = 0 (7) p k = p k 1 + (1 p k 1 )ɛ k (8) The first term in (8) corresponds to the probability that ALG y has already cost at least (s 1)q after Phase k 1, the second term accounts for the probability that this is not the case but cost at least (s 1)q is achieved in Phase k. By construction of X, these events are independent. Since ɛ k 1/N we get that p k p k 1 + (1 p k 1 )/N. (9) It is easy to see that any sequence of real numbers p k [0, 1] satisfying (7) and (9) must converge to 1. Hence, also the expected cost E X [ALG y (σ x )] converges to (s 1)q. On the other hand, the offline costs remain bounded by s by the choice of the σ ij according to Lemma 16. 8 Remarks We have studied the bin coloring problem, which was motivated by applications in a robotized assembly environment. The investigation of the online problem from a competitive analysis point of view revealed a number of oddities (see Table 1 for an overview of our results). A natural greedy-type strategy greedyfit achieves a competitive ratio strictly worse than arguably the most stupid algorithm (onebin). Moreover, no algorithm can be substantially better 20

than the trivial strategy (onebin). Even more surprising, neither randomization nor resource augmentation helps to overcome the Ω(q) lower bound on the competitive ratio. This is in contrast to [6,5] where the concept of resource augmentation was applied successfully to scheduling problems. Intuitively, the strategy greedyfit should perform well on average (which was confirmed in preliminary experiments with random data, see [3]). An open problem remains the existence of a deterministic (or randomized) algorithm which achieves a competitive ratio of q (matching the lower bound of Theorems 19 and 21). However, the most challenging issue raised by our work seems to be an investigation of OlBcp from an average-case analysis point of view. Problem Competitive Ratios Lower Bounds OlBcp onebin: min{2q 1, B} (Theorem 14) greedyfit: min{3q, B} (Corollary 7) deterministic ( ) algorithms: 1 q B+q q (Theorem 19) randomized ( ) algorithms: 1 q B+q q (Theorem 21) Table 1 Results for the OlBcp. References [1] N. Ascheuer, M. Grötschel, S. O. Krumke, and J. Rambau. Combinatorial online optimization. In Proceedings of the International Conference of Operations Research (OR 98), pages 21 37. Springer, 1998. [2] M. R. Garey and D. S. Johnson. Computers and Intractability (A guide to the theory of NP-completeness). W.H. Freeman and Company, New York, 1979. [3] A. Höft. Online-optimierung einer halbautomatischen glückwunschkarten kommissionierungsanlage. Diplomarbeit, Technische Universität Berlin, 2001. [4] M. Lin, Z. Lin, and J. Xu. Almost optimal solutions for bin coloring problems. In Proceedings of the 16th International Symposium on Algorithms and Computation, volume 3827 of Lecture Notes in Computer Science, pages 82 91, 2005. [5] C. Phillips, C. Stein, E. Torng, and J. Wein. Optimal time-critical scheduling via resource augmentation. In Proceedings of the 29th Annual ACM Symposium on the Theory of Computing, pages 140 149, 1997. 21

[6] K. R. Pruhs and B. Kalyanasundaram. Speed is as powerful as clairvoyance. In Proceedings of the 36th Annual IEEE Symposium on the Foundations of Computer Science, pages 214 221, 1995. 22