1 Introduction
One of the most basic problems studied extensively in scheduling theory is the problem of minimizing the total weighted flowtime on a single machine (minWPFT). In this problem, we are given a set of jobs, each job having a release time , a processing time (also sometimes referred to as size, or length), and a weight . The flowtime of a job, denoted by , is defined as the amount of time the job spends in the system before it completes. Formally, , where is the completion time of job . The objective is to find a preemptive schedule that minimizes the total weighted flowtime: . If preemption is not allowed, then the problem cannot be approximated better than for any , even for the unweighted case [10]. Hence, preemption is a standard assumption in the study of flowtime objective functions. When the weight of all jobs is the same, then the Shortest Remaining Processing Time (SRPT) – which at any time step schedules the job with the least remaining processing time – is an optimal algorithm. However, when jobs have different weights the problem becomes difficult. The problem is known to be NPhard, which is the only known lower bound on the problem, and no constant factor approximation algorithm is known for the problem. Obtaining a polynomial time constant factor approximation algorithm for minWPFT has been listed as a top ten open problem in the influential survey of Schuurman and Woeginger [12], and also recently by Bansal [1]. In this paper, building on the recent breakthrough work of Batra, Garg, and Kumar[6], we give a polynomial time constant factor approximation algorithm to the problem.
For the purpose of stating earlier results, let us introduce some notation. We use to denote the total size of all jobs and to denote the ratio between maximum and minimum size (also referred to as spread). Likewise, denotes the total weight of all jobs, and is the spread in weights. Approximation ratios and running times of approximation algorithms are typically expressed as functions of , and . As shown in [8] (see Section 2 for more details), one may assume (for the purpose of approximation algorithms) that . Hence when (which is the case of interest in this paper), in all results cited below one can interchange between and without affecting the validity of the bounds.
Chekuri et al.[9] designed an approximation algorithm for minWPFT with approximation factor . Their algorithm is semionline (requires knowledge of in advance). Bansal and Dhamdhere [3] obtained an approximation, using an online algorithm. Bansal and Chan [2] showed that no deterministic online algorithm can have a constant approximation ratio. Chekuri and Khanna [8] designed a approximation (offline) algorithm with running time . Substantial progress towards getting a polynomial time constant approximation algorithm was made by Bansal and Pruhs [4], who gave a very elegant approximation to the problem. Their main insight was to reduce minWPFT to a geometric setcover problem, and argue that the geometry of the resulting objects leads to approximation to this setcover problem. A further advantage of the geometric approach is that the results extend to general cost functions, such as norms of flowtime.
In a recent breakthrough, Batra, Garg, and Kumar [6] gave a pseudopolynomial time approximation to minWPFT. Their idea was to show that the problem can be reduced to a generalization of the multicut problem on trees called Demand Multicut problem. They argue that instances of the problem produced by minWPFT have nice structural properties that can be exploited using a dynamic programming approach to obtain an approximation algorithm.
The algorithm of [6] runs in time polynomial in and in , which is polynomial in only when is bounded by a polynomial in . They posed the problem of obtaining truly polynomial time algorithms (polynomial in even when is exponential in ) as an open problem. In this paper, we show that one can use their result as a subroutine to obtain an approximation algorithm to the problem. In particular we show the following result.
Theorem 1.
For the problem of minimizing weighted flowtime on a single machine (even when jobs have exponential weights and processing lengths) there exist:

a polynomial time algorithm with approximation factor, and

a approximation algorithm, for any , which runs in time .
1.1 Our Techniques
For many optimization problems one can assume that input integers are bounded by a polynomial, sometimes without loss of generality, and sometimes with only negligible loss in the approximation ratio via simple reductions. However, it was not known whether such an assumption can be made for the minWPFT problem. Indeed, our main contribution is that we answer the question in the affirmative, via a nontrivial reduction that uses the geometric aspect of the minWPFT problem.
In our algorithm, we partition jobs into classes, where each class contains jobs with size in . For every , we define a minWPFT instance which contains jobs . The spread of each such instance, which is defined as the ratio between the maximum and minimum job size, is at most . Thus we can use the algorithm of Batra et al. [6] to obtain approximate solutions for these instances. It is easy to see that the total cost of these schedules is at most times the cost of the optimum schedule for . We build the final schedule for in an inductive manner, using the schedules . Start from . For every , we construct a schedule for , using the two schedules and . Our final schedule is , where is the index of the last job class.
The crux of our algorithm is the construction of from and . Jobs in are scheduled in in exactly the same way as they were in . Then our algorithm inserts into . To obtain a schedule with small cost, we define a tentative deadline for every : this is the maximum completion time of in the two schedules and (jobs in are not contained in and thus their tentative deadlines are their completion times in ). If we could show that all jobs in can be inserted into so that all these jobs complete by their respective tentative deadlines, then we will be done.
However in general this goal can not be achieved. Indeed, we need to extend the deadlines of jobs in so that they can be completed by their extended deadlines. In order to bound the cost of the final schedule, we show that the cost incurred by extending deadlines is small. This is done via a reduction of the problem to a geometric set cover problem, using the framework of Bansal and Pruhs [4]. We show that there is a fractional solution of small cost to the set cover instance, and the union complexity of the system of geometric objects in the instance is linear. Applying the algorithm of Bansal and Pruhs [5], which builds on the results of Chan et al.[7] and Varadarajan [13], leads to an approximation for the geometric set cover problem. This gives a way to extend the deadlines of jobs in with small cost.
Using the above technique, we shall lose a multiplicative factor of and an additive factor in the approximation ratio. This is sufficient for achieving an approximation for minWFPT. In order to obtain a QPTAS by combining our reduction with the algorithm of Chekuri and Khanna [8], we can only afford to lose a multiplicative factor in the reduction. This we do by considering instances with consecutive classes and more careful analysis of the geometric set cover instances.
2 Preliminaries
We assume, without loss of generality, that arrival times are nonnegative integers, and that processing times and weights are positive integers. Let denote the sum of processing times of all jobs, and denote the sum of their weights. For simplicity of the presentation, we assume that and , so the input instance has representation size that is polynomial in , yet previous constant factor approximation algorithms do not run in time polynomial in . (More generally, the running time of our algorithm is polynomial in the number of bits used in order to encode the input instance, when processing times and weights are encoded in binary.) For and as above, any reasonable output schedule has a representation that is polynomial in . A schedule is regarded as reasonable if the machine is idle only when there are no jobs to be processed, and two jobs do not each preempt the other. A reasonable schedule involves only a linear number of significant time steps. For each job, one need only specify the time step in which it began being processed (possibly preempting a different job), and the time step in which it completed (possibly allowing a different job to begin or resume). The job might be preempted and resumed multiple times during the process, but these events cooccur with release times and completion times of other jobs.
Indeed, in the schedule constructed by our algorithm, for every job we only specify its completion time (or its deadline) in . If these deadlines are feasible, in the sense formalized below, then scheduling jobs in the Earliest Deadline First (EDF) order gives a valid schedule; that is, every job completes by its deadline. Hence, our algorithm needs to ensure that deadlines are feasible. The following theorem characterizes the feasibility of a EDF schedule.
Optimality of EDF:
Consider a set of jobs , where each job has a release time and a deadline . For any time interval , let denote the set of jobs that are contained in ; that is, . Then,
Theorem 2.
Scheduling jobs using the Earliest Deadline First algorithm completes every job before its deadline if and only if for every interval , where is the release time of some job and is the deadline of some (possibly same) job , we have
Note that necessity of the above condition is straightforward: The total processing lengths of jobs that need to be scheduled entirely in the interval cannot be more than the length of the interval itself. The sufficiency of the condition follows from a bipartite matching argument, and we refer the readers to [4] for the proof.
Spreads of Instances
As shown in [8], if at least one of or is polynomially bounded, then one can assume that so is the other, up to a negligible loss in the approximation ratio. In fact, the same applies to the spreads and . Assume is polynomially bounded. One can initially ignore (and later schedule at arbitrarily available time slots) all jobs that have weight smaller than , with a multiplicative loss of at most a in the flow cost. Similarly, if is polynomially bounded, then one can initially ignore all jobs that have size smaller than . Thereafter, the ignored jobs can be inserted into the schedule, making room for them by delaying (preempting) the jobs that are already scheduled. This delay adds only an fraction to the flow cost, because the ignored jobs have very small size.
Given the above, we may assume (with only negligible loss in the approximation ratio) that, in any minWPFT instance, is at most . So we define the spread of an instance to be . Then, approximation ratios and running times of known algorithms for the scheduling problem can be expressed as functions of and . In particular, for every one can achieve a approximation in time [9] and a approximation in time [8]. These running times are quasipolynomial when is polynomial, but exponential if is exponential. The result of Batra, Garg and Kumar [6] gives an approximation in pseudopolynomial time, i.e, time polynomial in and . The best approximation ratio known to be achievable in polynomial time was [4], which is when is exponential.
Notations
In the rest of the paper, for a schedule (that possibly contains only a subset of jobs in ), and a job , we use the notation and to respectively denote the completion and flowtimes of job in the schedule . Let be the weighted flowtime of jobs scheduled in . For any subset of jobs, we use to denote the total size of jobs in .
3 Our Algorithm
In this section, we prove our main theorem that shows one can w.l.o.g assume the spread is polynomially related to the input size , sacrificing only an factor in the approximation ratio (we show that the loss can be decreased to in Section 4). Our main theorem is the following:
Theorem 3.
There is a constant , such that for every monotone functions , the following holds. Given an algorithm ALG that solves instances of minWPFT with jobs and spread ratio in time and with approximation ratio , one can solve instances of minWPFT in time and with approximation ratio .
Towards proving the above Theorem 3, we first set up some notation. Consider an arbitrary instance of minWPFT, with jobs and . Partition the jobs into classes, where for class contains all jobs of processing time in . Consider now subinstances of , where for the instance contains those jobs of the two classes and ; that is, . Each instance has spread at most , and hence one can run ALG on it to obtain a schedule that is approximately optimal.
We shall use schedules in order to derive our final schedule for . This will be done in an inductive manner. Initially, we have . For every , we will construct a schedule which contains all jobs in , using the two schedules and . Hence, our final schedule is .
For a fixed , we derive the schedule for the jobs as follows. All jobs in are scheduled in exactly as they are in . Hence, their deadlines in the schedule is same as that in . For every job we shall associate a tentative deadline by which the job has to finish. (Later, some tentative deadlines will be changed to extended deadlines.) For a job , the tentative deadline is the latest of the two completion times in , ; formally, . For a job , is the completion time of job in the schedule ; . Recall that jobs in do not participate in . See Figure 1 for the definition.
Our intention is to schedule all jobs from the set such that all jobs meet their tentative deadlines. If we could achieve this, then the flowtime of job is at most , and we would be done. This is because the total weighted flowtimes of jobs belonging to classes and in is at most times their total weighted flowtime in an optimal schedule. Summing over all job classes we get a approximation as each class participates exactly twice; once in and once in , which can be charged to their cost in the optimal solution. However, the tentative deadlines for jobs in and may not satisfy the condition in Theorem 2. Hence, we may need to extend the deadlines of few jobs. Extending the deadlines of jobs, however, increases the flowtime of jobs. Thus, our goal is to extend the deadlines of jobs in a such way that the increase in weighted flowtime is not too much and the requirement in Theorem 2 is satisfied. The crucial theorem we shall prove is the following.
Theorem 4.
In polynomial time we can find a schedule of where the scheduling of jobs belonging to class or lower remains the same as in and
We prove the above theorem by reducing our problem to a geometric setcover problem. For now, we assume Theorem 4 and finish the proof of Theorem 3. Let be our final schedule of jobs . We first show that the final schedule indeed has a small cost. For every , we have
(1)  
(2)  
(3)  
(4) 
(1) holds since jobs in are scheduled in in the same way as in ,(2) follows from the definition of ’s and Theorem 4, (3) is obtained by replacing with .
Considering the sequence (4) for all from to , we have
Let denote the total weighted flowtime of jobs in the optimum schedule, and be the weighted flowtime of all jobs in in the optimum solution. Then, we have . So, the above inequality implies
Taking the constant in the statement Theorem 3 to be larger than the term above, the approximation ratio given by the algorithm is at most , as desired.
Let us now analyze the running time of the algorithm. We need to run the algorithm ALG at most times to construct schedules . Each is constructed on an instance with at most jobs with the spread at most . Constructing the schedules for from also takes polynomial time. So, the running time of the whole algorithm is bounded by . This finishes the proof of Theorem 3.
From now on we focus on proving Theorem 4. The theorem is proved in Sections 3.1 to 3.4, where we fix the integer . We reduce the problem to a weighted setcover problem in Section 3.1, give a fractional solution to the setcover instance in Section 3.2, round the fractional solution in Section 3.3, and finally construct our schedule and analyze its cost in Section 3.4.
3.1 Reduction to a Set Cover Problem
Recall that the schedule is constructed from schedules and . At this stage, the time line is as follows. Some time slots are occupied by jobs in . Other time slots are free. For every job , we have a release time and a tentative deadline .
We reduce the problem of extending deadlines to a weighted set cover problem as follows. A relevant interval is a consecutive sequence of unit slots that starts with a release time of some job and ends with a tentative deadline of a (possibly different) job. Therefore, for every two jobs with (we allow ), we have the relevant interval . Hence there are at most relevant intervals.
Before describing what constitutes sets in our reduction, we now define some notations and present some properties of the relevant intervals that will motivate the way we define the sets. For every interval , let denote the total length of free time slots in . Recall that a time slot is free if no job from class and below is scheduled in according to . Let
denote the total number of these occupied time slots. Observe that . A job is said to be contained in a relevant interval if . For a relevant interval , let be the set of jobs contained in . A relevant interval is safe if , and dangerous otherwise. In the weighted set cover instance we define, every dangerous relevant interval corresponds to a single item.

If all relevant intervals are safe, then every job can be scheduled in the interval , and we will be done. This follows from Theorem 2.

A dangerous relevant interval must contain at least one job from , which implies that . This is true because all the jobs from that are contained in were scheduled within the free unit slots of in the schedule .

For every relevant interval , we have . This is because all jobs in have , i.e, were scheduled within under . As may have at most occupied unit slots, the interval would become safe if for some job with , we change the tentative deadline of to be some extended deadline , so that is no longer contained in . Motivated by this observation, we define
to be the set of jobs in with size at least . Notice that since all jobs in have size at least . We say that a job covers interval , if we extend the deadline of the job such that it is no longer contained in .

If job has , then it creates extended intervals whose right endpoint is the extended . We wish to have the property that if all (original) dangerous intervals are covered (by extending deadlines of jobs), then all of the extended intervals that are created are also safe. To ensure this property, we will later replace every extended deadline to , making it the final deadline for the job. We denote the final deadline of a job by . These final deadlines give rise to the final intervals. We show that if all the original dangerous intervals are covered, then all the final intervals are also safe.
We are now ready to describe the sets. Every and every integer will give rise to one set that corresponds to having an extended deadline of for the job. Set will cover all items (dangerous intervals) that contain job with its tentative deadline , but not with the extended deadline . That is, the set covers a relevant interval if and only if
We associate a cost with set , giving a weighted set cover instance.
3.2 A Fractional Solution
We show that the weighted setcover instance defined in the previous section have a fractional solution with cost at most . We construct the fractional solution as follows. For every and , let be a fractional variable indicating the extent to which participates in the fractional setcover. Define the variables as follows:
Observation 5.
The cost of fractional solution is at most .
Proof.
Recall that the cost of is . Now consider
Now we prove that is indeed a valid fractional solution to the weighted setcover instance.
Lemma 6.
The constructed above covers all the items (dangerous relevant intervals) to an extent of at least 1.
Proof.
Consider a dangerous interval . Recall that denotes the set of jobs belonging to sets contained in . We already argued that since must contain a job in . We say a time slot is empty, if is not processing a job in during . If we remove jobs not in from schedule , then contains less than idle slots in , since otherwise would not be dangerous. Also, the total length of jobs in is at most since every such job has length less than . Thus, there are at most empty slots in .
We can assume that every job has , since otherwise is covered by to an extent of . Now, focus on each . The contribution of towards the fractional setcover is at least where is the minimum integer such that . Notice that since is more than the total length of all jobs in .
This implies that , by our choice of (recall that ). So, the contribution of is at least
The last inequality used that for every contributing to the sum. So, the total contribution of all jobs is at least
Since there are at most empty slots , at most integers are not contributing to the sum. So, the above quantity is at least
The secondtolast inequality used that and . ∎
3.3 Rounding the Fractional Solution
Next we show that there exists a rounding of solution with only a constant factor loss in the approximation ratio. Let denote the cost of any fractional solution to the weighted setcover instance.
Lemma 7.
The fractional solution can be rounded in polynomial time to an integral solution such that .
As shown in [4], our weighted setcover instance is equivalent to a geometric weighted setcover instance of covering points in two dimensions by rectangles aligned with the axis. In this problem, which we call as R2C, we are given a collection of points in two dimensional space and a set of axis parallel rectangles . Each rectangle in is abutting axis and has the form . The cost of picking a rectangle is . The goal is to find a minimum weight subset of rectangles , such that for each point there is rectangle that contains it. Now we construct an R2C instance from the weighted setcover instance as follows.
Reduction
For every item in our setcover instance, which corresponds to a dangerous relevant interval , we create a point in our R2C instance. For every set , for and integer , we create a rectangle of cost . Notice that the rectangle covers a point if and only if , which is exactly the condition that the set covers the item . Thus, the constructed R2C instance is the equivalent to the original weighted setcover instance.
There are constant factor approximation algorithms known to solve the R2C problem. The main idea behind these algorithms is to exploit the structural properties of geometric objects. In particular, if the union complexity of the geometric objects is small, then the geometric setcover instances admit good (better than ) approximation factor. We will not concern ourselves with rigorous definition of the union complexity of objects; we refer the readers to [13, 4] to more details. Intuitively speaking, for a collection of geometric objects, the union complexity is the number of edges in the arrangement of the boundary of objects. For twodimensional objects, this is the total number of vertices, edges and faces. Bansal and Pruhs [4] showed the following result.
Lemma 8.
The union complexity of collection of rectangles of type is .
In the setting of [4] one obtains a geometric setcover problem where the union complexity of objects is because of different priority levels. In our setting, there are no priorities and thus our approximation ratio is better. To complete our rounding, we need the following theorem from Bansal and Pruhs [5], which is an extension of results of Chan et al.[7] and Varadarajan [13].
Theorem 9.
Let be an instance of a geometric weighted setcover problem on points, such that the union complexity of every sets is at most for all . Then there is a polynomialtime approximation for the problem. Furthermore, this approximation guarantee holds with respect to the optimum value of the fractional solution.
Lemma 10.
We can efficiently find an integral solution to the weighted setcover instance with cost at most .
Proof.
From Lemma 8, the union complexity of any rectangles in the R2C instance is at most . We use Theorem 9 to construct an integral solution for the R2C instance. From the guarantee of the theorem, the cost of this solution is at most times the cost of . But we know that the cost of is . This completes the proof. ∎
Thus, from now on we use to denote the integral solution to the weighted setcover instance we constructed. The is at most .
3.4 Constructing
Finally, we show how a solution to the setcover problem considered in the previous section can be used to construct the schedule . Given an integral solution to the setcover instance defined above, we define extended and final deadlines of jobs as follows. For a job , let be the largest integer such that (this is well defined since we can assume ), and we define . For jobs , we set . From the definition of our weighted setcover instance, the validity of , and the definition of , we can see that the original relevant intervals are safe w.r.t the extended deadlines. More specifically, we have
Observation 11.
For every original relevant dangerous interval , we have
However, since we extend the deadlines of some jobs, new relevant extended intervals are created (that end in an extended deadline), which might not be safe. Our fix is to further extend the deadline of jobs in by . Namely, for every , we define , and for every , we define . Now we need to show that the relevant intervals w.r.t final deadlines are also safe.
Lemma 12.
For every relevant final interval where is the release time of some job, and is the final deadline of some (possibly different) job, we have
(5) 
Proof.
Let be the largest integer that corresponds to a tentative deadline; we can assume since otherwise the set in the summation on the left side of (5) is empty. All jobs with has by our definition of . If , then we have
So we can assume .
If the interval was originally safe then so is . If was not safe, then some job has its extended deadline , implying that . Hence (5) holds because the final deadline of lies beyond (thus clearing a demand of unit slots from the interval ). ∎
Lemma 13.
All jobs of can be scheduled by their final deadlines, without need to move any job from from its unit slots in the schedule .
Proof.
Consider a bipartite matching instance, where free unit slots correspond to the right hand side vertices, each job corresponds to left hand side vertices, and these vertices can be matched to unit slots starting at and ending at the final deadline . A feasible schedule exists iff all right hand side vertices can be matched. This requires Hall’s condition to hold, and Hall’s condition holds iff it holds on all relevant intervals (that end in final deadlines). The fact that all relevant intervals are safe implies that Hall’s condition holds. ∎
This completes the description of the schedule . Note that at this stage every job from the set has a deadline , and from Lemmas 12 and 13, it follows that the condition required in Theorem 2 holds. Thus, is feasible. It only remains to bound the cost of our final schedule. Now we are ready to prove Theorem 4.
Proof of Theorem 4.
Recall that for each job