O-lne Temporary Tasks Assgnment Yoss Azar and Oded Regev Dept. of Computer Scence, Tel-Avv Unversty, Tel-Avv, 69978, Israel. azar@math.tau.ac.l??? Dept. of Computer Scence, Tel-Avv Unversty, Tel-Avv, 69978, Israel. odedr@math.tau.ac.l Abstract. In ths paper we consder the temporary tasks assgnment problem. In ths problem, there are m parallel machnes and n ndependent jobs. Each job has an arrval tme, a departure tme and some weght. Each job should be assgned to one machne. The load on a machne at a certan tme s the sum of the weghts of jobs assgned to t at that tme. The objectve s to nd an assgnment that mnmzes the maxmum load over machnes and tme. We present a polynomal tme approxmaton scheme for the case n whch the number of machnes s xed. We also show that for the case n whch the number of machnes s gven as part of the nput (.e., not xed), no algorthm can acheve a better approxmaton rato than 4 unless P = NP. Introducton We consder the o-lne problem of non-preemptve load balancng of temporary tasks on m dentcal machnes. Each job has an arrval tme, departure tme and some weght. Each job should be assgned to one machne. The load on a machne at a certan tme s the sum of the weghts of jobs assgned to t at that tme. The goal s to mnmze the maxmum load over machnes and tme. Note that the weght and the tme are two separate axes of the problem. The load balancng problem naturally arses n many applcatons nvolvng allocaton of resources. As a smple concrete example, consder the case where each machne represents a communcaton channel wth bounded bandwdth. The problem s to assgn a set of requests for bandwdth, each wth a specc tme nterval, to the channels. The utlzaton of a channel at a specc tme t s the total bandwdth of the requests, whose tme nterval contans t, whch are assgned to ths channel. Load balancng of permanent tasks s the specal case n whch jobs have nether an arrval tme nor a departure tme. Ths specal case s also known as the classcal schedulng problem whch was rst ntroduced by Graham [5, 6]. He descrbed a greedy algorthm called \Lst Schedulng" whch has a m approxmaton rato where m s the number of machnes. Interestngly, the same??? Research supported n part by the Israel Scence Foundaton and by the US-Israel Bnatonal Scence Foundaton (BSF).
analyss holds also for load balancng of temporary tasks. However, untl now, t was not known whether better approxmaton algorthms for temporary tasks exst. For the specal case of permanent tasks, there s a polynomal tme approxmaton scheme (PTAS) for any xed number of machnes [6, 0] and also for arbtrary number of machnes by Hochbaum and Shmoys [7]. That s, t s possble to obtan a polynomal tme ( + )-approxmaton algorthm for any xed > 0. In contrast we show n ths paper that the model of load balancng of temporary tasks behaves derently. Speccally, for the case n whch the number of machnes s xed we present a PTAS. However, for the case n whch the number of machnes s gven as part of the nput, we show that no algorthm can acheve a better approxmaton rato than 4 unless P = NP. Note that smlar phenomena occur at other schedulng problems. For example, for schedulng (or equvalently, load balancng of permanent jobs) on unrelated machnes, Lenstra et al. [9] showed on one hand a PTAS for a xed number of machnes. On the other hand they showed that no algorthm wth an approxmaton rato better than for any number of machnes can exst unless P = NP. In contrast to our result, n the on-lne settng t s mpossble to mprove the performance of Graham's algorthm for temporary tasks even for a xed number of machnes. Speccally, t s shown n [] that for any m there s a lower bound of m on the performance rato of any on-lne algorthm (see also [, ]). Our algorthm works n four phases: the roundng phase, the combnng phase, the solvng phase and the convertng phase. The roundng phase actually conssts of two subphases. In the rst subphase the jobs' actve tme s extended: some jobs wll arrve earler, others wll depart later. In the second subphase, the actve tme s agan extended but each job s extended n the opposte drecton to whch t was extended n the rst subphase. In the combnng phase, we combne several jobs wth the same arrval and departure tme and unte them nto jobs wth hgher weghts. Solvng the resultng assgnment problem n the solvng phase s easer and ts soluton can be converted nto a soluton for the orgnal problem n the convertng phase. The novelty of our algorthm s n the roundng phase. Standard roundng technques are usually performed on the weghts. If one apples smlar technques to the tme the resultng algorthm's runnng tme s not polynomal. Thus, we had to desgn a new roundng technque n order to overcome ths problem. Our lower bound s proved drectly by a reducton from exact cover by -sets. It remans as an open problem whether one can mprove the lower bound usng more sophstcated technques such as PCP reductons. Notaton We are gven a set of n jobs that should be assgned to one of m dentcal machnes. We denote the sequence of events by = ; ; n, where each event
s an arrval or a departure of a job. We vew as a sequence of tmes, the tme s the moment after the th event happened. We denote the weght of job j by w j, ts arrval tme by a j and ts departure tme by d j. We say that a job s actve at tme f a j < d j. An assgnment algorthm for the temporary tasks problem has to assgn each job to a machne. Let Q = fjja j < d j g be the actve jobs at tme. For a gven algorthm A let A j be the machne on whch job j s assgned. Let l A k () = X fjja j=k;jqg w j be the load on machne k at tme, whch s the sum of weghts of all jobs assgned to k and actve at ths tme. The cost of an algorthm A s the maxmum load ever acheved by any of the machnes,.e., C A = max ;k lk A (). We compare the performance of an algorthm to that of an optmal algorthm and dene the approxmaton rato of A as r f for any sequence C A r C opt where C opt s the cost of the optmal soluton. The Polynomal Tme Approxmaton Scheme Assume wthout loss of generalty that the optmal makespan s n the range (; ]. That s possble snce Graham's algorthm can approxmate the optmal soluton up to a factor of, and thus, we can scale all the jobs' weghts by l where l denotes the value of Graham's soluton. We perform a bnary search for the value n the range (; ]. For each value we solve the ( + ) relaxed decson problem, that s, ether to nd a soluton of sze ( + ) or to prove that there s no soluton of sze. From now on we x the value of. 8>< dlog ne >: J 4 J 5 J 6 J 7 c J 4 c 5 c J 6 c 7 c J c c Fg.. Parttonng J nto fjg In order to descrbe the roundng phase wth ts two subphases we begn wth denng the parttons based on whch the roundng wll be performed. We begn by denng a partton fj g of the set of jobs J. Let M be a set of jobs and
4 consder the sequence of tmes n whch jobs of M arrve and depart. Snce the number of such tmes s r for some r, let c be any tme between the r-th and the r + -st elements n that set. The set J contans the jobs n M that are actve at tme c. The set M contans the jobs n M that depart before or at c and the set M + contans the jobs n M that arrve after c. We set M = J and dene the M's teratvely untl we reach empty sets. The mportant property of that partton s that the set of jobs that exst at a certan tme s parttoned nto at most dlog ne derent sets J. S S T T s s c t t Fg.. Parttonng J nto fs j ; T j g (R s not shown) We contnue by further parttonng the set J. We separate the jobs whose weght s greater than a certan constant and denote them by R. We order the remanng jobs accordng to ther arrval tme. We denote the smallest prex of the jobs whose total weght s at least by S. Note that ts total weght s less than. We order the same jobs as before accordng to ther departure tme. We take the smallest sux whose weght s at least and denote that set by T. Note that there mght be jobs that are both n S and T. We remove the jobs and repeat the process wth the jobs left n J and dene S ; T ; ; Sk ; T k. The last par of sets S k and T k may have a weght of less than. We denote by s j the arrval tme of the rst job n Sj and by tj the departure tme of the last job n T j. Note that s s sk c t k t t. The rst subphase of the roundng phase creates a new set of jobs J 0 whch contans the same jobs as n J wth slghtly longer actve tmes. We change the arrval tme of all the jobs n S j for j = ; ; k to s j. Also, we change the departure tme of all the jobs n T j to tj. The jobs n R are left unchanged. We denote the sets resultng from the rst subphase by J 0, J 0, j S0, T 0 j. The second subphase of the roundng phase further extends the actve tme of the jobs of the rst subphase. We take one of the sets J 0 and the partton we dened earler to R ; S 0 [ T 0 ; S 0 [ T 0 ; ; S 0 k [ T 0 k. We order the jobs n S 0 j accordng to an ncreasng order of departure tme. We take the smallest prex of ths orderng whose total weght s at least. We extend the departure tme of all the jobs n that prex to the departure tme of the last job n that prex. The process s repeated untl there are no more jobs n S 0 j. The last prex may
5 s S 0 s S 0 c T 0 t T 0 t Fg.. The set J 0 (after the rst subphase) have a weght of less than. Smlarly, extend the arrval tme of jobs n T 0 j. The jobs n R are left unchanged. We denote the sets resultng from the second subphase by J 00, J 00, S 00 j, T 00 j. s S 00 s S 00 c T 00 t T 00 t Fg. 4. The set J 00 (after the roundng phase) The combnng phase of the algorthm nvolves the weght of the jobs. Let Jst 00 00 be the set of jobs n J that arrve at s and depart at t. Assume the total weght of jobs whose weght s at most n Jst 00 s a. The combnng phase replaces these jobs by dae jobs of weght. We denote the resultng sets by Jst 000. The set J 000 s created by replacng every Jst 00 wth ts correspondng Jst, 000 that s, J 000 = [ s<t Jst. 000 The solvng phase of the algorthm solves the moded decson problem of J 000 by buldng a layered graph. Every tme n whch jobs arrve or depart has ts own set of vertces called a layer. In each layer we hold a vertex for every possble assgnment of the current actve jobs to machnes; that s, an assgnment whose makespan s at most for a certan. Two vertces of adjacent layers are connected by an edge f the transton from one assgnment of the actve jobs to the other s consstent wth the arrval and departure of jobs at tme. Now we can smply check f there s a path from the rst layer to the last layer. In the convertng phase the algorthm converts the assgnment found for J 000 nto an assgnment for J. Assume the number of jobs of weght n Jst 000 that are
6 assgned to a certan machne s r. Replace these wth jobs smaller than n Jst 00 of total weght of at most (r + ). Note that all the jobs wll be assgned that way snce the replacement nvolves jobs whose weght s at most and from volume consderaton there s always at least one machne wth a load of at most r of these jobs. The assgnment for J 00 s also an assgnment for J 0 and J. 4 Analyss Lemma. For =, gven a soluton whose makespan s to the orgnal problem J, the same soluton appled to J 0 has a makespan of at most + dlog ne. Also, gven a soluton whose makespan s to J 0, the same soluton appled to J has a makespan of at most. Proof. The second clam s obvous snce the jobs n J are shorter than ther perspectve jobs n J 0. As for the rst clam, every tme s contaned n at most dlog ne sets J. Consder the added load at from jobs n a certan set J. If < s or t then the same load s caused by J 0 and J. Assume < c and dene s k+ = c, the other case s symmetrcal. Then for some j, s j < sj+ and the added load at s at most the total load of S j whch s at most. Summng on all sets J, we conclude that the maxmal load has ncreased by at most dlog ne =. Lemma. For = 4mdlog ne, gven a soluton whose makespan s to the problem J 0, the same soluton appled to J 00 has a makespan of at most ( + ). Also, gven a soluton whose makespan s to J 00, the same soluton appled to J 0 has a makespan of at most. Proof. The second clam s obvous snce the jobs n J 0 are shorter than ther perspectve jobs n J 00. As for the rst clam, gven a tme and a par of sets S 0 j, T 0 j from J 0 we examne the ncrease n load at. If < sj or tj t s not aected by the transformaton because no job n T 0 j [ j S0 arrves before s j or departs after tj. Assume that < c, the other case s symmetrcal. So s aected by the decrease n arrval tme of jobs n T 0 j. It s clear that the way we extend the jobs n T 0 j ncreases the load at by at most. Also, snce s j, we know that the load caused by j S0 s at least f j < k. Thus, an extra load of at most s created by every par S 0 j, T 0 j for j < k only f the par contrbutes at least to the load. Also, S k for all contrbutes an extra load of at most dlog ne. Snce the total load on all machnes at any tme s at most m, the ncrease n load and therefore n makespan s at most m + dlog ne = + 4m. Lemma. For = m = 4m, gven a soluton whose makespan s dlog ne to the problem J 00, the moded problem J 000 has a soluton wth a makespan of (+). Also, gven a soluton whose makespan s to the moded problem J 000, the soluton gven by the convertng phase for the problem J 00 has a makespan of at most ( + ).
Proof. Consder a soluton whose makespan s to J 00. If the load of jobs smaller than n a certan Jst 00 on a certan machne s r, we replace t by at most dr e jobs of weght. Note that ths s an assgnment to J 000 and that the ncrease n load on every machne s at most tmes the number of sets Jst 00 that contan jobs whch are scheduled on that machne. As for the other drecton, consder a soluton whose makespan s to J 000. The ncrease n load on every machne by the replacement descrbed n the algorthm s also at most tmes the number of sets Jst 00 that contan jobs whch are scheduled on that machne. The number of sets Jst 00 that can coexst at a certan tme s at most m snce the weght of each set s at least and the total load at any tme s at most m. Therefore, the ncrease n makespan s at most m =. Lemma 4. The runnng tme of the algorthm for solvng the relaxed decson problem for s bounded by O(n 6m log m + ). The runnng tme of the PTAS s the above bound tmes O(log =). Proof. Every layer n the graph stores all the possble assgnments of jobs to machnes. Snce the smallest job s of weght, the maxmum number of actve jobs at a certan tme s m. So, the maxmum number of edges n the graph s nm m and the runnng tme of the relaxed decson problem algorthms s O(nm m ) = O(nm 8m dlog ne ) = O(n 6m log m + ). The runnng tme of the PTAS s the above bound tmes O(log =) snce there are O(log =) phases n the bnary search for the approprate. 7 5 The unrestrcted number of machnes case In ths secton we show that n case the number of machnes s gven as part of the nput, the problem cannot be approxmated up to a factor of 4= n polynomal tme unless P = NP. We show a reducton from the exact cover by -sets (XC) whch s known to be NP-complete [4, 8]. In that problem, we are gven a set of n elements, A = fa ; a ; ; a n g, and a famly F = ft ; ; T m g of m trples, F A A A. Our goal s to nd a coverng n F,.e. a subfamly F 0 for whch jf 0 j = n and [ TF 0T = A. Gven an nstance for the XC problem we construct an nstance for our problem. The number of machnes s m, the number of trples n the orgnal problem. There are three phases n tme. Frst, there are tmes ; ; m, each correspondng to one trple. Then, tmes m + ; ; m + n each correspondng to an element of A. And nally, the two tmes m + n + ; m + n +. There are four types of jobs. The rst type are m jobs of weght startng at tme 0. Job r, r m ends at tme r. For any appearance of a j n a trple T corresponds a job of the second type of weght that starts at and ends at m + j and another job of the thrd type of weght that starts at tme m + j. Among all the jobs that start at tme m + j, one ends at m + n + whle the rest end at m + n +. The fourth type of jobs are m n jobs of weght that start at m + n + and end at m + n +.
load machne 8 Type I Type II Type III Type IV 0 0 0 0 0 4 5 6 7 8 9 0 (a ) (a ) (a ) (a 4 ) (a 5 ) (a 6 ) 4 Fg. 5. An assgnment for the schedulng problem correspondng to m = 4, n =, F = f(; ; ); (; 4; 5); (4; 5; 6); (; ; 4)g We show that there s a schedule wth makespan at most f and only f there s an exact cover by -sets. Suppose there s a cover. We schedule a job of the rst type that ends at tme to machne. We schedule the three jobs of the second type correspondng to T to machne. At tme m + j, some jobs of type two depart and the same number of jobs of type three arrves. One of these jobs s longer than the others snce t ends at tme m + n +. We schedule that longer job to machne where T s the trple n the coverng that contans j. At tme m + n + many jobs depart. We are left wth n jobs, three jobs on each of the n machnes correspondng to the -sets chosen n the cover. Therefore, we can schedule the m n jobs of the fourth type on the remanng machnes. Now, assume that there s a schedule whose makespan s at most. One mportant property of our schedulng problem s that at any tme, 0 < m + n + the total load remans at m so the load on each machne has to be. We look at the schedule at tme m + n +. Many jobs of type three depart and only the long ones stay. The number of these jobs s n and ther weght s. Snce m n jobs of weght arrve at tme m + n +, the n jobs must be scheduled on n machnes. We take the trples correspondng to the n machnes to be our coverng. Assume by contradcton that ths s not a coverng. Therefore, there are two -sets that contan the same element, say a j. At tme m + j only one long job arrves. The machne n whch a shorter job was scheduled remans wth a load of untl tme m + n + and then the short job departs and ts load decreases to at most. Ths s a contradcton snce at tme m + n + there are n machnes each wth long jobs. Corollary. For every < 4, there does not exst a polynomal -approxmaton algorthm for the temporary tasks assgnment problem unless P = NP.
9 6 Acknowledgments We are grateful to Jr Sgall and Gerhard J. Woegnger for ther helpful dscussons. References [] Y. Azar. On-lne load balancng. In A. Fat and G. Woegnger, edtors, Onlne Algorthms - The State of the Art, chapter 8, pages 78{95. Sprnger, 998. [] Y. Azar and L. Epsten. On-lne load balancng of temporary tasks on dentcal machnes. In 5th Israel Symp. on Theory of Computng and Systems, pages 9{ 5, 997. [] A. Borodn and R. El-Yanv. Onlne Computaton and Compettve Analyss. Cambrdge Unversty Press, 998. [4] M.R. Garey and D.S. Johnson. Computers and Intractablty. W.H. Freeman and Company, San Francsco, 979. [5] R.L. Graham. Bounds for certan multprocessor anomales. Bell System Techncal Journal, 45:56{58, 966. [6] R.L. Graham. Bounds on multprocessng tmng anomales. SIAM J. Appl. Math, 7:6{69, 969. [7] D. S. Hochbaum and D. B. Shmoys. Usng dual approxmaton algorthms for schedulng problems: Theoretcal and practcal results. J. of the ACM, 4():44{ 6, January 987. [8] R.M. Karp. Reducblty among Combnatoral Problems, R.E. Mller and J.W. Thatcher (eds.), Complexty of Computer Computatons. Plenum Press, 97. [9] J.K. Lenstra, D.B. Shmoys, and E. Tardos. Approxmaton algorthms for schedulng unrelated parallel machnes. mathprog, 46:59{7, 990. [0] S. Sahn. Algorthms for schedulng ndependent tasks. Journal of the Assocaton for Computng Machnery, :6{7, 976.