Category Archives: Appendix: Sequencing and Scheduling

Scheduling to Minimize Weighted Completion Time

This reduction took me a while to follow because there is a lot of subtle algebra you have to do for yourself.

The problem: Scheduling to minimize weighted completion time.  This is problem SS13 in the appendix.

The description: Given a set T of tasks where each task t has a length l(t) and weight w(t), a set of m processors, and a bound K.  Can we find an m-processor schedule for all tasks where each project’s “completion penalty” is its weight multiplied by it’s completion time, and the total completion penalty for all tasks is K or less?

Example: Suppose I had 2 processors and 4 tasks:

Task Length Weight
1 5 4
2 1 6
3 3 3
4 3 3

Scheduling greedily by weight would put task 1 and 2 on one processor, then tasks 3 and 4 on the second processor after task 2 finishes.  This has a total penalty of 20 for task 1 + 6 for task 2 + 12 for task 3 + 21 for task 4 = 59

Scheduling task 2 then 1 on processor 1 and tasks 3 and 4 on processor 2 gives a total penalty of 57.

Reduction: The paper by Lenstra, Rinnooy Kan, and Brucker was hard for me to follow because they are discussing lots of different scheduling variants in the same paper, and do it by parameterizing the kinds of inputs. I’m pretty sure our problem is Theorem 3b in the paper, which reduces from Partition.  So we start with a set T of elements and build 1 task for each element in T.  The processing time and weight of the task are the size of the element in T.  K will be the sum of the products of all pairs of elements – 1/4 of the sum of all of the elements squared.  We’ll have 2 processors.

They claim that since the processing times and lengths are all the same for each task, if you are given a set of these tasks on one processor, the order doesn’t matter, and we get the same total weight no matter what.  It took me a while to buy that, but it comes down to the fact that each task is costing one penalty unit per time step no matter where it is scheduled.

Given a subset T of S, define c to be the amount the sum of the elements in S is “off” of the partition.  (The difference between the sum of the elements in T and half of the sum of everything in S).  When c=0, T is a partition of S.

The completion penalty of a processor is the completion penalty of all of the tasks (remember, the order doesn’t matter)  – the sum of all of the weights of tasks on that processor * the sum of all of the weights not on that processor.  Which is K+c2. Which means we have a solution to the scheduling problem if and only if c is 0, which is exactly when we have a partition.

Difficulty: 6.  I’m not sure how much I’d trust students to be able to come up with the algebra themselves.  Make if you tell them to set up the problem with lengths and weights equal, and then make them prove that in that case, the order doesn’t matter, then it becomes more tractable for them.

Preemptive Scheduling

This is one of those reductions that is easy because you remove everything that makes the problem hard.  It always feels like cheating to do this, but I guess it shows that adding extra complexity to a hard problem will never make it easier..

The problem: Preemptive Scheduling.  This is problem SS12 in the appendix.

The description: Given a set T of tasks arranged in a partial order,   each task t has a positive length l(t).  We have a set of m processors and an overall deadline D.  Can we create a preemptive schedule for T that obeys the precedence constraints and meets the overall deadline?  A preemptive schedule allows tasks to be partially run on a processor and then removed, and we can finish it at some later time.

Example: Here is a simple partial order:

The number of the task is its length.  So task a takes 3 time units, for example.

A two-processor preemptive schedule could be something like: P1: (1,1,1,2,2,4)  and P2: (4,4,4,3,3,3), getting both tasks done at time6.

If we did not allow preemption, we would not be able to fit task 4 along with task 1, so we couldn’t do anything on P2 while P1 was running task 1.

Reduction: The paper by Ullman which we used for Precedence Constrained Scheduling has the reduction.   He basically notes that Precedence Constrained Scheduling is a special instance of Preemptive Scheduling where all lengths of all jobs are 1.  In that case, no preemption is possible.  So the reduction is basically “use the exact same problem”.

Difficulty: 2.  I usually reserve Difficulty 1 for “this is the same problem”, but here, there is a little bit of insight to convince yourself that you can interpret the problem this way.

Scheduling with Individual Deadlines

I feel like this problem is an easy extension of a problem we’ve already done.  This worries me, because why would it show up as a separate problem with a separate reference in G&J if that is the case?

The problem: Scheduling with individual deadlines.  This is problem SS11 in the appendix.

Description: Given a set T of tasks, each of length 1, arranged in a partial order, a set of m processors, and a deadline d(t) for each task t, can we schedule all tasks to meet all deadlines?

Example: Here’s a precedence graph:

Suppose the deadlines are:

Task Deadline
1 1
2 3
3 2
4 1
5 2
6 3

If we have 2 processors, then we can schedule all tasks by doing each task exactly as its deadline is coming up.  If we add one more requirement in the partial order from 3 to 5, then these tasks cannot all be finished by the deadline.

Reduction (easy version): When I read this problem, it seemed very similar to Precedence Constrained Scheduling.  The difference is that in that problem, we’re given a single deadline D that all tasks must be completed by, but in this problem, each task can have its own deadline.

But this still leads to a pretty easy reduction from PCS: We take our PCS instance, use the exact same tasks, use the same number of processors, and make each task’s individual deadline be D.  So our Individual Deadline instance is feasible exactly when all tasks are finished by time D.

This feels too easy.  Maybe I’m misreading one of the problems.  So, to be safe..

Reduction (Brucker, Garey, and Johnson version):

The reduction in the paper goes from Vertex Cover.  So we’re given an undirected graph G=(V,E), and a K.  Define define v = |V|, e= |E|, a= v+ e(e+1).  Define m = a + e+ v.  This will be the number of processors.  Define D = 3e+3.  This is the largest deadline for any task.

There will be m*(D-1)+1 tasks. Task T0 has deadline 1.  There will be many other “dummy” tasks Tij that are set up so that they have to start at time j and have to end at time j+1.  This is enforced by having each Ti,j have to come before Ti,j+1 in the partial order.  The number of i tasks at each j changes:

  • Ti,1 where i goes from 1 to m-k
  • Ti,2, where i goes from 1 to m-e
  • Ti, 2+j for each j from 1 to e, where i goes from 1 to v+j
  • Ti, e+2+j, for each j from 1 to e, where i goes from 1 to a+v+j-1
  • Ti, 2e+2+j, for each j from 1 to e, where i goes from 1 to e+v

T0 is the root of all of these and comes before each Ti,1.

Then we add the “graph-dependent” tasks.  Each vertex vi has a task that has to come after T0 and has deadline e+3.  Each edge ej spawns two chains of j tasks (E’j(1) through E’j(j) and E”j(1) through E”j(j))  each, all of which have deadline 2e+3.  We’ll also have two other groups of tasks for each edge: L’j(1) through L’j(a) and L”j(1) through L”j(a). The last E’ task for each j comes before all of the corresponding L’ tasks, and the last E” task for each j comes before all of the corresponding L” tasks.  Each of these L tasks has a deadline D-j+1.

Edges in G also create precedence constraints.  The edge ej= (vq, vr), with q < r, creates the ordering vq->E’j(1) and vr->E”j(1).

If G has a Vertex Cover, then that means that each edge in E has at least one endpoint in the cover.  The jobs for these vertices will be scheduled at time 1.  Since the vertex jobs have to be run before the corresponding edge jobs, we can run the E’ or E” job that was set by the last precedence constraints above at time 2.  Once that chain finishes, we can run the L jobs.

If we have a valid schedule that meets all deadlines, we must have scheduled T0 first, and each Ti,j at time j. This means we only have so many slots to schedule the E chains.  Since vertex tasks have to happen before these chains, we need to schedule k vertex tasks at time 1.  If the schedule is feasible, that must be a cover. (Because if it wasn’t, then there is an edge that does not have it’s E’ or E” chain start at time 2, which is too slow).

Difficulty: The easy way is a 2.  The way from the paper is an 8, because it’s hard to see why the specific numbers of dummy tasks comes from, why you need 2 chains (E’ and E”.  You need them because you don’t know which endpoint of the edge will be in the cover), why you need the L tasks, and so on.

Resource Constrained Scheduling

I spend a bit of time trying to see if there was an easy reduction between this problem and one of the other scheduling ones, but I couldn’t find anything.  So we’ll do it the hard way.

The problem: Given a set T of tasks, each with a length of 1, a set of m processors, and set of r resources.  Each resource i has a “bound” bi of how many resources are available at any time and each task t has a requirement ri(t) denoting how many of resource i it needs.  We’re also given a deadline D.

Can we find an m-processor schedule for all tasks that:

1) Meets the deadline, and

2) For all time units, ensures that all of the processors running in that time unit do not exceed the resource bounds for any resource?

Example: Suppose I have 4 tasks and 1 resource:

  • Task 1 uses 2 units of the resource
  • Task 2 uses 3 units of the resource
  • Task 3 uses 4 units of the resource
  • Task 4 uses 5 units of the resource

If there are 5 units of the resource available, we can get this task done in 3 time steps (Task 4, then 1 and 2, then 3)

If there are 7 units available, we can get the task done in 2 time steps (1 and 4, then 2 and 3)

If there are 14 units available, we can do everything in one time step.

Reduction: The paper by Garey and Johnson proves several variants of the problem,  The one I’ll do is in Lemma 3.4, which has 5 processors and 8 resources.  They go on from there to show the variant with 3 processors and 1 resource is also NP-Complete, but we only care about the general problem.

The reduction is from 3DM, In this case, we’re assuming that W, X, and Y (the 3 sets in the 3DM problem) are all the same set T, and S is our set of triples from T.  Define a value mk(i) to be the number of triples in S that have i in their kth value.  So m2(4) is the number of triples with a 4 in position 2.  Notice that for a legal matching to be possible, mk(i) has to always be at least 1.

So we build an instance of the resource constrained scheduling problem with 5 processors and 8 types of resources.   The tasks are:

  • One “S” task for each triple in S.
  • X0, Yo and Z0 tasks for each element in q (the number of elements in T)
  • Xij tasks where i runs from 1 to q and j runs from 1 to m1(i).
  • Similar Yij (using m2(i)) and Zij (using m3(i)) tasks.
  • “F” tasks from 1 to q.
  • |S|-q “G” tasks.

The deadline is |S|.

The resource requirements are set up so that during each time unit, we have 5 processors running:

  1. An S task
  2. An X or X0
  3. A Y or Y0
  4. A Z or Z0
  5. An F or G

The X0/Y0/Z0 tasks all correspond to an element in T, and can only be run along with an F and the S task that is the triple of the X, Y, and Z elements in S.   The F task makes sure that we have chosen a legal matching.   The matching consists of the S triples chosen along with an F task.  (The G tasks are there to fill the rest of the timesteps) .

Difficulty: 7.  More if you keep going and refine the problem down to 3 processors and 1 resource.

Precedence Constrained Scheduling

SS8 is “Multiprocessor Scheduling”, which is done in Section 3.2.1

Here’s SS9, which uses the non-book problem from last week.

The problem: Precedence Constrained Scheduling.  This is problem SS9 in the appendix.

The description: Given a set T of tasks arranged in a partial order, each of length 1, a set of m processors, and a positive deadline D.  Can we schedule the tasks in T in a way that obeys the precedence constraints and finishes by deadline D?


Suppose we had the following simple precedence graph:

With 2 processors, the earliest feasible schedule will finish at time 3 (timestep 1 schedules 2 of a,c, and d, timestep 2 schedules the remaining one, and then we can finally schedule b after that).  With 3 processors, we can finish at time 2 (schedule all of a,c, and d in timestep 1, then b right afterward).

Reduction: This is problem P2 in the paper by Ullman and the reduction uses the “Single Execution Time with Variable Number of Processors” problem from last week.  The main difference between that problem and this one is that instead of having a varying number of slots at each time, now we have K processors for all time steps.

So we start with an instance of the variable processor problem and add a bunch of new jobs Iij where i runs through each time step, and j runs from 0 to n – ci. (n is the number of jobs, ci is the number of processors available at time i).  The precedence graph keeps all of the old precedences and also has Iij come before Ii+1,k  for all j and k.  (So all I jobs at time i come before all I jobs at time i+1).  We have n+1 processors and the same deadline.  The idea is that the extra I jobs all have to run at their specific timestep, and they “fill” the empty processor slots between the ci processors available in the original and the n+1 processor slots available in this version of the problem.

Difficulty: 4, mainly because the variable # of processors problem we’re reducing from is hard to understand.  But this is a classic “go from a variable number of things to a larger fixed number of things” technique that can be used for lots of problems.


Sequencing to Minimize Maximum Cumulative Cost

I want to give credit to our Interlibrary Loan people who tracked this reference down- it’s a Ph.D. thesis that only existed on microfilm.   So I got to use the microfilm reader for the first time since elementary school.  Those things are very different now.

The problem: Sequencing to Minimize Maximum Cumulative Cost.  This is problem SS7 in the appendix.

The description: Given a set of tasks with a partial order defined on the tasks, and a (possibly negative) integer cost c(t) for each task t, and a positive value Z.  Can we create a one-processor schedule that obeys the partial order constraints such that for each task t, the cost of each task scheduled before t is K or less?

Example: Suppose we have the following precedence graph of tasks (the number in the vertex is the cost of the task):

The schedule (d,e,a,c,b), has the last cost (task b) with a total cost of 12 (the sum of the costs of all tasks before it).  Notice that if some task costs are negative, it’s possible that the last task that is done does not have the maximum total cost.  For example, if task c’s cost was -4, then the schedule (d,e,a,c,b) has its maximum cost of 10 after task a is scheduled.

Reduction: I got this from a Ph.D. thesis by Abdel-Wahab, and in it, he reduces from Register Sufficiency.  So we’re given an instance of register sufficiency: a directed graph G=(V,E), and a K.  The precedence graph G’=(V’, E’) that we’ll build has 2 copies of every vertex in G.  The edge set of G’ will have all of the edges in E, and additionally, if (i,j) is an edge in E, then (j’, i) is an edge in E’.  (That’s an edge from the second copy of j, back to i.)  Each vertex costs 1 if it was in V, and -1 if it is a second copy.  Set K’ = K+1.

If the register sufficiency problem has a solution, then we build a sequence based on it.  Thinking in terms of Sethi’s “stone game”, each time we place a new stone on a vertex, we add that vertex to the end of the sequence.  If we pick up a stone from vertex x, add x’ (the second copy) to the end of the sequence.  If we’re moving a stone from y to x, then that’s like removing it from y and adding it to x.  You can prove by induction that the max cost of any task in this sequence is K’.

If the scheduling task has a solution, then we build a solution to the stone game.  For each task in the schedule, if it is in V (the original set of vertices), then place a stone on that vertex.   If it is not in V then it is a new vertex, so remove a stone from the copy in V.  Since K’ = K+1, it’s possible that this sequence of steps uses K+1 stones, so we need to modify it to use K.   So, find a node in the sequence whose cost is exactly K’.  We know this node is in V (it was a “place a stone” move since it took us to K’ stones).  It can’t be the last task since we have to end with one that costs -1 (since all of those vertices have no outdegree, and the ones that cost 1 all have an outdegree of at least 1).    So look at the task after it.  It can’t be a “place a stone” move, otherwise, we’ll use K’+1 stones.  So we know that the next task to be scheduled has cost -1.  Since that move will be to pick up a stone, just move the stone that’s about to be removed to our peak cost task instead of allocating a new stone, and we will solve the problem using 1 less stone at this point. If multiple places in the schedule cost K’ exactly, we can do this modification to all of them, creating a program sequence that uses just K stones at most.

Difficulty: 6.  The reduction is not hard, but the stone game takes some work to understand, and the turning a solution that costs K’ into a solution that costs K is a little tricky.  I wonder if there’s an alternate reduction that has K’=K.

Sequencing With Deadlines and Setup Times

Is it weird that G&J call these problems “sequencing” and not “scheduling”?  They use “scheduling” for multiprocessor problems, and shop scheduling problems.  I guess the thinking is that single-processor problems are just “sequences” of what you put on the processor.

The problem: Sequencing with Deadlines and Setup Times.  This is problem SS6 in the appendix.

The description: We’re given a set of T tasks, each task with a length l(t) and deadline d(t).  We also have a set of “compilers”, C, and each task has a specific compiler k(t).  Each compiler has a setup time l(c).  Can we find a one-processor schedule for T that meets the deadlines of all tasks with the additional constraint that if two tasks are scheduled with different compilers, we must pay the setup cost of the second task’s compiler before starting the second task?

Example: I’m not sure “compiler” is the best word for C.  I think of it as more of a preprocessor (and in fact, the paper by Bruno and Downey that has the reduction calls it a “setup task”).  Each task needs some preprocessing to be done before it can run, and if you run two tasks that need the same preprocessing in a row, you can do them both one after the other. Otherwise, you need the preprocessing to happen (immediately) before you start the task.

So, suppose I have 2 compilers:

Compiler Setup time
1 5
2 7

And 4 tasks:

Task Length Deadline Compiler
1 5 10 1
2 3 20 2
3 3 23 2
4 10 100 1

..Then if we schedule task 1 first, its setup + length gets it done at time 10.  Then we do the setup for task 2, so it finishes at time 20.  Task 3 uses the same “compiler”, so does not need to do setup time, so will finish at time 23.  Task 4 uses a different compiler, so needs to re-run compiler 1’s setup time of 5, and will be done at time 38.

Notice that the most “efficient” schedule that minimizes the number of setups we have to do will not schedule all tasks by their deadlines.

Reduction: I’m pretty sure this problem is Theorem 1 in the paper by Bruno and Downey.  They say they reduce from Knapsack, but since there aren’t any weights, they’re really using Sum of Subsets.  The original set S has N elements, a target B, and the sum of all elements in the set is called t0 (which will, of course, be > B).  There will be N+2 “classes” of 3 tasks each that share the same setup task.  The setup for all classes Ci takes time 1 and has 3 tasks: one that takes time 1, one that takes time si (the corresponding element in S), and a third task that takes time H*si, where H is the larger of t0 and N+2.  The 2 “extra” classes Co and Cn+1 work similarly, but use t0 instead of si.  The deadline for the first task in all classes is d1 = 2(N+2) + B.  The deadline for the second task in all classes is d2 = 3N+5+3t0+2Ht0-HB.  The deadline for the third task in all classes is d3=3N+5+3t0+3Ht0.

They go on to show the following facts:

  • In a feasible schedule, you can’t have a d3 task finish before the d1 deadline (there is no time for it).
  • In a feasible schedule, you can’t finish the second task of C0 or Cn+1 before d1.  (Since the second task takes t0 time, feasibly scheduling everyone’s first tasks with their setup times does not leave enough time left).
  • In a feasible schedule, we can only setup 2N+3 setup tasks at most. (More leaves too much time for setup and processing and someone will miss their d3 deadline).
  • In a feasible schedule, there is exactly one task that gets setup once (that is, it gets set up, and does its three tasks in sequence).  This is because of the first bullet and the fact that we have a limit of setup tasks.
  • In a feasible schedule, you never do the first task then the third task without doing the second task  (You can rearrange other feasible schedules to have this property and remain feasible).

What results from these facts is that a feasible schedule has: a bunch of first tasks (preceded by the setup task), a bunch of first and second tasks in sequence (preceded by the setup task), and a single class that does its setup then all three tasks.  This last sequence crosses over the d1 deadline.  Then we need to set up and schedule the second and third tasks of all of the classes we only did the first task for before the d2 deadline.  Then we will set up and schedule the last task of all classes that have a third task remaining.

It turns out that the classes we chose to do the first 2 tasks before the d1 deadline for have costs (and second task length) of exactly B.

Difficulty: 7.  This is a really good paper that does a really good job of proving each of the above facts along the way and showing how it all works (many other papers would resort to saying some of these proofs were “obvious”, which I don’t think they are).  Having said that, I don’t know how anyone comes up with these classes- especially the deadlines- without weeks of trial and error, and that is too much for a student to manage on their own.

Protected: Sequencing to Minimize Weighted Tardiness

This content is password protected. To view it please enter your password below:

Protected: Scheduling to Minimize Weighted Completion Time

This content is password protected. To view it please enter your password below:

Protected: Sequencing to Minimize Tardy Tasks, Sequencing to Minimize Tardy Task Weight

This content is password protected. To view it please enter your password below: