Interval scheduling
Interval scheduling is a class of problems in computer science, particularly in the area of algorithm design. The problems consider a set of tasks. Each task is represented by an interval describing the time in which it needs to be processed by some machine. For instance, task A might run from 2:00 to 5:00, task B might run from 4:00 to 10:00 and task C might run from 9:00 to 11:00. A subset of intervals is compatible if no two intervals overlap on the machine/resource. For example, the subset is compatible, as is the subset ; but neither nor are compatible subsets, because the corresponding intervals within each subset overlap.
The interval scheduling maximization problem is to find a largest compatible set, i.e., a set of non-overlapping intervals of maximum size. The goal here is to execute as many tasks as possible, that is, to maximize the throughput. It is equivalent to finding a maximum independent set in an interval graph.
A generalization of the problem considers machines/resources. Here the goal is to find compatible subsets whose union is the largest.
In an upgraded version of the problem, the intervals are partitioned into groups. A subset of intervals is compatible if no two intervals overlap, and moreover, no two intervals belong to the same group. Each group of intervals corresponds to a single task, and represents several alternative intervals in which it can be executed.
The group interval scheduling decision problem is to decide whether there exists a compatible set in which all groups are represented. The goal here is to execute a single representative task from each group. GISDPk is a restricted version of GISDP in which the number of intervals in each group is at most k.
The group interval scheduling maximization problem is to find a largest compatible set - a set of non-overlapping representatives of maximum size. The goal here is to execute a representative task from as many groups as possible. GISMPk is a restricted version of GISMP in which the number of intervals in each group is at most k. This problem is often called JISPk, where J stands for Job.
GISMP is the most general problem; the other two problems can be seen as special cases of it:
- ISMP is the special case in which each task belongs to its own group.
- GISDP is the problem of deciding whether the maximum exactly equals the number of groups.
All these problems are special cases of single-machine scheduling, since they assume that all tasks must run on a single processor. Single-machine scheduling is a special case of optimal job scheduling.
Single-Interval Scheduling Maximization
Single-interval scheduling refers to creating an interval schedule in which no intervals overlap.Unweighted
Several algorithms, that may look promising at first sight, actually do not find the optimal solution:- Selecting the intervals that start earliest is not an optimal solution, because if the earliest interval happens to be very long, accepting it would make us reject many other shorter requests.
- Selecting the shortest intervals or selecting intervals with the fewest conflicts is also not optimal.
- Select the interval, x, with the earliest finishing time.
- Remove x, and all intervals intersecting x, from the set of candidate intervals.
- Repeat until the set of candidate intervals is empty.
A more formal explanation is given by a Charging argument.
The greedy algorithm can be executed in time O, where n is the number of tasks, using a preprocessing step in which the tasks are sorted by their finishing times.
Weighted
Problems involving weighted interval scheduling are equivalent to finding a maximum-weight independent set in an interval graph. Such problems can be solved in polynomial time.Assuming the vectors are sorted from earliest to latest finish time, the following pseudocode determines the maximum weight of a single-interval schedule in Θ time:
// The vectors are already sorted from earliest to latest finish time.
int v; // list of interval vectors
int w; // w is the weight for v.
int p; // p is the # of vectors that end before v begins.
int M;
int finalSchedule;
// v does not exist, and the first interval vector is assigned to v.
w = 0; p = 0; M = 0;
// The following code determines the value of M for each vector.
// The maximum weight of the schedule is equal to M.
for
// Function to construct the optimal schedule
schedule
Example
If we have the following 9 vectors sorted by finish time, with the weights above each corresponding interval, we can determine which of these vectors are included in our maximum weight schedule which only contains a subset of the following vectors.Here, we input our final vector into our schedule function from the code block above. We perform the actions in the table below until j is set to 0, at which point, we only include into our final schedule the encountered intervals which met the requirement. This final schedule is the schedule with the maximum weight.
| j | Calculation | Set j to | |
| 9 | True | j=p=p=6 | |
| 6 | True | j=p=p=4 | |
| 4 | False | j=j-1=4-1=3 | |
| 3 | True | j=p=p=1 | |
| 1 | True | j=p=p=0 |
Group Interval Scheduling Decision
NP-complete when some groups contain 3 or more intervals
GISDPk is NP-complete when, even when all intervals have the same length. This can be shown by a reduction from the following version of the Boolean satisfiability problem, which was shown to be NP-complete likewise to the unrestricted version.Given an instance of this satisfiability problem, construct the following instance of GISDP. All intervals have a length of 3, so it is sufficient to represent each interval by its starting time:
- For every variable, create a group with two intervals: one starting at and another starting at .
- For every clause, create a group with the following intervals:
- * For every variable that appears positively for the first time in C an interval starting at.
- * For every variable that appears positively for the second time in C an interval starting at. Note that both these intervals intersect the interval, associated with.
- * For every variable that appears negatively - an interval starting at. This interval intersects the interval associated with.
The constructed GISDP has a feasible solution, if and only if the given set of boolean clauses has a satisfying assignment. Hence GISDP3 is NP-complete, and so is GISDPk for every.
Polynomial when all groups contain at most 2 intervals
GISDP2 can be solved at polynomial time by the following reduction to the 2-satisfiability problem:- For every group i create two variables, representing its two intervals: and.
- For every group i, create the clauses: and, which represent the assertion that exactly one of these two intervals should be selected.
- For every two intersecting intervals create the clause:, which represent the assertion that at most one of these two intervals should be selected.
Group Interval Scheduling Maximization
MaxSNP-complete when some groups contain 2 or more intervals
GISMPk is NP-complete even when.Moreover, GISMPk is MaxSNP-complete, i.e., it does not have a PTAS unless P=NP. This can be proved by showing an approximation-preserving reduction from MAX 3-SAT-3 to GISMP2.
Polynomial 2-approximation
The following greedy algorithm finds a solution that contains at least 1/2 of the optimal number of intervals:- Select the interval, x, with the earliest finishing time.
- Remove x, and all intervals intersecting x, and all intervals in the same group of x, from the set of candidate intervals.
- Continue until the set of candidate intervals is empty.
The approximation factor of 2 is tight. For example, in the following instance of GISMP2:
- Group #1:
- Group #2:
A more general approximation algorithm attains a 2-factor approximation for the weighted case.
LP-based approximation algorithms
Using the technique of Linear programming relaxation, it is possible to approximate the optimal scheduling with slightly better approximation factors. The approximation ratio of the first such algorithm is asymptotically 2 when k is large, but when k=2 the algorithm achieves an approximation ratio of 5/3. The approximation factor for arbitrary k was later improved to 1.582.Related problems
An interval scheduling problem can be described by an intersection graph, where each vertex is an interval, and there is an edge between two vertices if and only if their intervals overlap. In this representation, the interval scheduling problem is equivalent to finding the maximum independent set in this intersection graph. Finding a maximum independent set is NP-hard in general graphs, but it can be done in polynomial time in the special case of intersection graphs.A group-interval scheduling problem can be described by a similar interval-intersection graph, with additional edges between each two intervals of the same group, i.e., this is the edge union of an interval graph and a graph consisting of n disjoint cliques of size k.
Variations
An important class of scheduling algorithms is the class of dynamic priority algorithms. When none of the intervals overlap the optimum solution is trivial. The optimum for the non-weighted version can found with the earliest deadline first scheduling. Weighted interval scheduling is a generalization where a value is assigned to each executed task and the goal is to maximize the total value. The solution need not be unique.The interval scheduling problem is 1-dimensional – only the time dimension is relevant. The Maximum disjoint set problem is a generalization to 2 or more dimensions. This generalization, too, is NP-complete.
Another variation is resource allocation, in which a set of intervals s are scheduled using resources k such that k is minimized. That is, all the intervals must be scheduled, but the objective is to minimize the usage of resources.
Another variation is when there are m processors instead of a single processor. I.e., m different tasks can run in parallel. See identical-machines scheduling.
Single-machine scheduling is also a very similar problem.