**The problem: **Minimum Weight Solution to Linear Equations. This is problem MP5 in the appendix.

**The description: **Given a set of equations X, where each equation consists of an m-tuple of integers and an integer b. We’re also given a positive integer K m. Can we find an m-tuple with rational entries such that at most K of y’s entries are non-zero and = b for all equations in X?

**Example**: I find it easier to write the equations out. Suppose we have:

3y_{1}+2y_{2}+y_{3} = 7

4y_{1}+3y_{2} + 7y_{3} = 10

If we set K=2, that means that only 2 of the 3 y values in the solution can be non-zero (so we need at least one 0). Choosing y_{1}=1, y2=2, y_{3}=0 works.

**Reduction: **G&J don’t give the reduction, but in the comments, they say it’s polynomial if K=m. That plus the use of “X” (the set in X3C) made me think that the reduction from X3C had the be related to the sets chosen from C.

So our X3C instance has a set X of 3q elements, and a set C of collections of 3-element subsets of X. We’ll set m (the size of the tuples in our equations) to |C|. Our equation set X’ will have 3q equations. Each equation will correspond to an element in X, and the positions of its vector will correspond to the sets in C. Each vector element will have a 1 in the positions where the element exists in the set in C, and 0 otherwise. Our b value will be 1 for each equation, and K will be q (we want q of the variables to be 1)

So, for example, if X = {1,2,3,4,5,6}, and C was {1,2,3}, {4,5,6}, {2,4,5}, we would have 6 equations:

y_{1} = 1 (the equation for element 1)

y_{1} + y_{3} = 1 (the equation for element 2, which appears in sets 1 and 3)

y_{1} = 1 (the equation for element 3)

y_{2}+y_{3} = 1 (the equation for element 4)

y_{2}+_{y3} = 1 (the equation for element 5)

y_{2} = 1 (the equation for element 6)

Since this is a small and simple X3C instance, there is a lot of redundancy in the equations. But hopefully it’s clear how it relates to the initial instance: We’re asking if we can create a 0/1 tuple that solves each of these equations (fractional values for the y variables won’t work because if we do that we will have more than K non-zero variable values). Setting a variable to 1 means “choosing” that set in the X3C instance. Having the equation be true means that we have found exactly one set in C’ holding that element of X. Having *all* of the equations be true means we have found a C’ that holds exactly one copy of all elements in X (thus solving the X3C instance).

**Difficulty: **5, assuming I didn’t mess anything up. It’s very tempting to set up the equations in the wrong way (for example, making there be |C| equations of 3q-tuples)

**The problem: **Feasible Basis Extension. This is problem MP4 in the appendix.

**The description: **Given an mxn matrix A of integers (m < n), and a column vector of size m, and a subset S of <m columns of A, can we find a non-singular (i.e., invertible) mxm submatrix B of A, such that:

- B contains all of the columns of S, and
- All of the elements of the vector , where = B
^{-1 }* are 0?

**Example: **I’ll try to keep the matrix calculations simple. Suppose A was:

1 | 2 | 3 |

4 | 5 | 6 |

was:

and S was just the second column. Then B has to be a 2×2 submatrix of A that includes the second column, for example:

1 | 2 |

4 | 5 |

The inverse of this is:

Which, if we multiply by , gives us:

**Reduction: **

The paper by Murty is from 1972, so doesn’t really follow the same reduction structure we’re used to. The basic idea is to start with an instance of TSP, and realize that we can write a tour as an nxn matrix X where x_{ij} = 1 if the tour goes from city i to city j, and 0 otherwise. (This is basically a way of taking a permutation of the n cities, and stretching it out to an nxn 0-1 matrix). We can then write the TSP problem as a set of constraints: Each row in the solution sums to exactly 1, each column in the solution sums to exactly 1, and all entries are 0. We are trying to minimize the cost of all of the 1 entries in the solution. We can get the decision problem by adding a new constraint: That the costs of all of the entries is the K from the TSP instance.

He then shows that if this system has a feasible basis, it must be a tour that satisfies the TSP instance. The proof involves lemmas that talk about the “convex polytope” of the constraints, which I think needs some pretty sophisticated linear programming familiarity to follow.

**Difficulty: **8. Maybe less if you are teaching a mathematical programming class- I don’t think the ideas are *hard*, but I do think they’re not likely to come up in an algorithms class.

]]>

**The problem: **Cost-Parametric Linear Programming. This is problem MP3 in the appendix.

**The description: **Given a set of integer constraints (,b) as in Integer Programming, (except that the inequalities are instead of for some reason, but we can always multiply by -1 to flip the constraints) and a set J that is a subset of indices of the variables in . Can we find an m-tuple with rational values such that q and for all feasible non-negative m-tuples that satisfy the constraints, the minimum of >

**Example: **Ok, here’s a pretty simple situation. Suppose we have 3 variables, with constraints:

(Or, technically, )

Now, suppose we choose a of (1,1,0} and a J of {1,2}. So in this case, the minimum of would be .3 + .4 = .7. That needs to be more than This comes out to .5 + 0, so it works. So, with this , we need q , so a q > makes this solution correct. There may be different values for that will also work on smaller q’s.

**Reduction: **G&J say that the reduction is from 3SAT, but I think the paper by Jersolow uses DNF Non-Tautology. Given a logical formula in DNF form, he builds a linear inequality system. All variables in formula become variables in the linear program. For each clause, every variable has a constraint that it’s 1. (and, I think implicitly, 0). If the variable shows up in a literal positively, we add the constraint that it is 1. If it shows up negatively, we have a constraint that it’s 0. This means that we have a solution to the constraints if and only if we set the variables to the truth values that make the clause true. (Remember, we have a DNF formula, so each clause is a conjunction- we need to make each variable true).

He then shows that the minimum way to solve the constraints (since it’s in DNF, that means making one clause true) is is true for all if and only if A is a tautology. From there he goes on to show that our problem instance holds.

I’m pretty confused by the logic- especially seems it looks like he’s saying that his problem is true if and only if the original problem *is* a tautology, when *non-*tautology is what we’re supposed to be reducing from.

**Difficulty **9. This is a hard problem to understand, and the reduction is hard to follow as well. It’s very possible I’m not understanding something in the paper.

**The problem: **Quadratic Programming. This is problem MP2 in the appendix.

**The description**: Given a set of pairs (,b) of constraints, similar to those in Integer Programming, except the numbers can be rationals instead of integers. Instead of the single objective vector , we’re also given a second vector , both of rationals. Our objective bound B is also a rational.

Can we find a vector of rationals that meets all of the constraints and sets the objective function ?

**Example: **I’ll again try to write a simple example in a format closer to what I think is used in practice:

Maximize such that:

I’m pretty sure this has a trivial solution of and , for an objective score of 26.

**Reduction:** It’s worth mentioning that this is a “Not known to be in NP” problem, I think because the range of possible rational solutions is too large to nondeterministically guess. Sahni’s paper reduces from Sum of Subsets. So we’re given a set S= {} and a bound M. Our QP instance will be have the following objective function: . Our constraints will be that each has to be between 0 and 1 (inclusive) and also . Our bound B will be equal to M.

The first half of the objective function makes its contribution to the sum negative if is not 0 or 1 (and 0 if it is 0 or 1). So the only way to get the objective to exactly M is to choose 0/1 values for each . The second half of the objective function and the summation constraint force us to create a sum that is as large as possible but not larger than B. In this case the objective function value is the sum of the subset chosen, which is equal to B if and only if we have a SOS solution.

**Difficulty: **5. The hack to make fractional variable assignments negative is very cool, and easy to explain, but hard to find on your own. I also think that worrying about quadratics and fractional values for your variables makes this problem harder to handle.

**The problem: **Integer Programming. This is problem MP1 in the appendix.

**The description: **Given a set of X of pairs (,b), where is an m-tuple of integers, and b is an integer. We’re also given an m-tuple and an integer B.

Can we find an m-tuple of integers such that:

- b for each (,b) pair
- B.

**Example: **The definition above kind of hides the way we commonly think of integer (or linear) programming. The X set is the set of constraints, and the and B make the objective function. So, the set ((1,2,3,4),100) really corresponds to the constraint 1x _{1}+2x_{2}+3x_{3}+4x_{4} 100.

Here is a simple Integer Programming problem written in the way we’re probably more used to seeing:

Given constraints:

x_{1} + x_{2} 5

10x_{1} + 6x_{2} 45

Maximize 5x_{1} + 4x_{2 } (Or, as a decision problem, can 5x_{1} + 4x_{2} be 23?

The answer is yes: If x_{1}=3 and x_{2} = 2, we satisfy both constraints and get an objective value of 23.

Notice that if we allowed non-integer values for our variables, we would have a *linear* program, and could get to an objective value of 23.75 by setting x_{1}=3.75 and x_{2}=1.25.

**Reduction: **Karp’s paper uses 3SAT, which is fine, but it’s hard to see how the objective function works there. I think a much more natural reduction is from Knapsack.

So we’re given a set of n items, each item i has a profit p_{i} and weight w_{i}. We’re given a knapsack capacity B and a goal profit K.

Our constraints will be:

x_{1}*w_{1}+… x_{n}*w_{n} B (keep the total weight at B or less)

x_{i} 1 for all i (I can take at most 1 of each item)

-1*x_{i} 0 for all i (Each x_{i} has to be at least 0)

The last sets of constraints force each x_{i} variable to be either 0 or 1.

The objective function asks:

p_{1}*x_{1} + … + p_{n}*x_{n} B?

I think it’s pretty clear that this is exactly the rules for Knapsack written as an Integer Programming problem.

**Difficulty: **3. I think this might be too easy for a homework problem because the proof part of the reduction (Knapsack says “yes” if and only if IP says “yes”) is trivial. But the need for the last set of constraints (that each variable is >=0, written as a <= equation) is a fun wrinkle that will mess up some people.

**The problem: **Deadlock Avoidance. This is problem SS22 in the appendix.

**The description: **(The definition in G&J is a little vague, so this comes more from the paper by Araki, Sugiyama, Kasami, and Okui). Given a set {P_{1}..P_{U}} of processes (represented as directed acyclic graphs with a fixed “start node”), and set {t_{1}..t_{T}} of resource types, where resource type t_{i} has a_{i} equivalent units available. Each process state may allocate or deallocate a resource type, with the stipulations that:

- Each process can only deallocate a resource it has allocated
- Each process must deallocate all allocated resources before completing (along any path through its DAG)

Given a state in this system (where each process is somewhere along its process flow), is the state of the system “safe”? That is, for each control flow, can we find a sequence of allocations and deallocations that allows each process to finish?

**Example: **I had a hard time with this definition until I realized we were asking about a specific state of the system. So here is the classic deadlock situation described in this terminology. Suppose we have 2 processes, P1 and P2. Each process’ start node is its name, the symbol a(X) means to allocate resource X and the symbol d(X) means to deallocate resource X.

The process flows look like:

If we set the starting state to after the second node of each graph (so P0 has R1, and P1 has R2), then we have a deadlock. But if we set the starting state to after the *first* node for each graph (so, before any resources are allocated) then we would call that “safe” because we can do all of P0, followed by all of P1, and have both processes finish.

**Reduction: **The paper by Araki, Sugiyama, Kasami, and Okui have several reductions for several variants of the problem. This is the first one (Theorem 2 in my paper) and uses 3SAT. We’re given a formula with n variables and m clauses, and build a system that has 3m+2n+1 processes and 7m+3n+1 resource types (each with 1 unit of the resource each). The resources are:

- B
_{i}, X_{i}and ~X_{i}for each variable - C
_{j}for each clause - C
_{jk}and D_{jk }for each literal position in each clause (k goes from 1 to 3). - A single resource A, which will control the flow through processes.

The processes are:

- P
_{xi}and P_{~xi}for each variable - P
_{jk}for each literal position in each clause - P
_{0}, which manages everything.

Here is the flow diagram for P_{xi}. “a” means allocate a resource, and “d” means deallocate a resource:

Here is the flow diagram for P_{~xi}. Notice that because they share B_{i} and A, only one of these processes can complete at a time:

The three P_{jk} processes for a clause are all similar. The resource “Yj1” refers to the resource that is the first literal in clause j (so it’s really an X resource):

(You can click the images to make them larger)

It’s worth noticing that resource C_{j} is in common among all 3 processes, and that each process allocates two D resources in a circular fashion.

The main P_{0} process is:

The starting state is the second node of each process (so after each process acquires its first resource).

If the original formula was satisfiable, then we have a way of setting each variable that satisfies each clause. Each variable has two processes: P_{xi} (corresponding to setting x_{i} to true) and P_{~xi} (corresponding to setting x_{i} to false). The process corresponding to the way we set each x_{i} to satisfy the formula is the one we want to let proceed. It will grab B_{i} and eventually wait on A (which is held by P_{0}). This will release the x_{i} (if the variable is set to true) or ~x_{i} (if the variable is set to false) resource. This means that the P_{jk} process that corresponds to that literal that can run to completion (this is the literal that makes clause C_{j} true). Once it’s done, we can run the other two P_{jk} processes to right before they each try to acquire C_{j}.

At this moment, none of the C_{j}‘s or C_{jk} resources are allocated, so process P_{0} can finish. This releases A, so process P_{x}_{i} (or P_{~xi}) can finish. This releases B_{i}, so the other of P_{xi} and P_{~xi} can finish. Then, finally, the other two P_{jk} in each clause can finish, in order. Since we found an order to terminate all processes, our starting state was safe.

If the original formula was unsatisfiable, for each B_{i}, we need to decide whether to allocate it to P_{xi} or P_{~xi}. The one we allocate to can release it’s X_{i} (or ~X_{i}) resource. That process is waiting to get A (currently held by P_{0}) and the other process for that variable is waiting to get B_{i} (currently held by the other X_{i} (or ~X_{i} ) process). P_{0} can’t release A until all C_{j} and C_{jk} resources are free, which only happens if some P_{jk} process completes. But these processes can’t complete until they get a resource corresponding to a literal in a clause (currently held by a X_{i}/~X_{i} process). Since we know the formula is unsatisfiable, no matter how we decide to allocate the B_{i}, there will always be at least one clause where all of the literals in that clause were *not* chosen to advance. The three processes for this clause cannot complete, meaning P_{0} cannot advance. Since we always get to a state where no processes can finish, we have a deadlock.

**Difficulty: **8. Tracing through the different processes is very cool, but very complicated. I wish I could teach a course one of these years in “cool hard reductions”. This is way to hard to fit into the last couple of weeks of an Algorithms class, but I think it is something students could sink their teeth into and learn a lot from.

**The problem: **Production Planning. This is problem SS21 in the appendix.

**The description: **Given a positive number n of time periods, and for each period i, several non-negative parameters: demand (r_{i}), production capacity (c_{i}), setup cost (b_{i}), incremental production cost coefficient (p_{i}), and inventory cost coefficient (h_{i}). We’re also given an overall bound B. Can we find a positive production amount (x_{i}) for each period such that:

- x
_{i}≤ c_{i}for all i (we never produce more than the production capacity) - The inventory on hand for each period (I
_{i }=(x_{j}-r_{j}) is non-negative - (p
_{i}x_{i}+h_{i}I_{i}) + b_{i}≤ B?

**Example: **There are a lot of variables here, but here’s what it’s really saying:

Suppose we have a factory that makes some product, and the factory’s schedule for making the product is split into time periods. In each time period, we can only make a certain amount (c_{i}) of the product, and it costs a certain amount to use the factory at all during a time period (b_{i}) and then an additional amount to make each instance of the product (p_{i}). Each time period also has a demand (r_{i}) that has to be met. We can get ahead of the demand by producing more than we need (leaving I_{i} extra around at time i), but also at a cost (h_{i}).

Suppose I have 3 time periods:

Time Period | Production Capacity | Demand | Production Cost | Inventory Cost | Production Setup | ||

1 | 5 | 3 | 2 | 1 | 6 | ||

2 | 5 | 3 | 4 | 3 | 2 | ||

3 | 1 | 2 | 20 | 20 | 5 |

Since at time period 3, we have less production capacity than demand, we will have to carry over inventory from a previous time period. There are basically four strategies to meet the demands:

- Produce 4 units at time period 1, 3 at time 2, and 1 at time 3. At time 1, this costs 6 to set up production, 4×2 to make the goods, and 1×1 to store the extra good (So 15). At time period 2, it costs 2+3×4+1×3 = 17, and time period 3, it costs 5+1×20+0x20 = 25, for 57 total cost.
- Produce 3 units at time period 1, 4 at time 2, and 1 at time 3. At time 1, this costs 6+3×2+0x1 = 12. At time period 2, it costs 2+4×4+1×3 = 21. At time period 3, it costs 5+1×20+0x20 25. This is a total cost of 58.
- Produce 5 units at time period 1, 3 at time period 2, and 0 at time period 3. This would cost 6+5×2+2×1 = 18 at time 1, 2+3×4+2×3 =20, and 0 at time 3, for a cost of 38.
- Produce 3 units at time period 1, 5 at time period 2, and 0 at time period 3. This would cost 6+3×2+0x1 =12 at time 1, 2+5×4+2×3 = 28 at time 2, and 0 at time 3, for a total time of 40.

So option 3 is the best choice. But if we raised the inventory cost of time period 1 significantly (say, to 50), then option 3 would cost 114, and option 4 would still cost 40, and be best.

**Reduction: **The paper by Florian, Lenstra, and Rinnooy Kan say they use Knapsack, but by our definitions, the problem is really Sum of Subsets. So we’re given a set of integers A= {a_{1} .. a_{n}} and a target B. We will build a production planning instance with n+1 time periods numbered from 1 to n. The demand of each period is B. The b costs (to set up production) are 1 at all periods. The capacity at time period 0 is n*B, and the capacity at time period i > 0 is a_{i}. The production cost at time period 0 is 0, the production cost at time period i is . All inventory costs are 0. The cost bound B’ is equal to the SOS bound B + 1.

Since it costs 1 to make any amount of goods (up to our capacity limit) in time 0, we might as well make all of it that we can. This gives us n*B goods, and will be enough to supply the demands at all of the other time periods except for the last, leaving B left over to be supplied in the last time period. Notice that our production cost fraction is built in such a way that if in time period i, we make a_{i} goods, we pay exactly a_{i} cost. If we build less than a_{i} goods in time period i (but more than 0), we pay more than a_{i} cost in that time period. So the only to get a total cost of B’ while meeting the demand is to make exactly a_{i} of the good in each time period that makes goods. This corresponds to a subset of A that sums to exactly B.

**Difficulty**: 5. If you do use this in a class, I’d give them a simpler version where you don’t even mention the inventory costs, and where the b cost is always 1, and where the demands are always equal in each time period, since that’s what the reduction does.

**The problem: **Staff Scheduling. This is problem SS20 in the appendix.

**The description: **Given a collection C of m-tuples, each tuple consisting only of 0’s and 1’s, and each tuple having the same amount (k) of 1’s. These represent possible schedules we can give a worker. We’re also given a “requirement” m-tuple consisting of m non-negative integers, and a number N of workers. Can we map each c in C to a non-negative integer (representing the number of workers we assign to that schedule) such that the total number of all integers is N or less, and the requirement tuple is met?

**Example: **I think this is easier to explain with an example. Suppose we had 4-tuples (corresponding to 4 “work periods”) and C is the tuples:

0 | 0 | 1 | 1 |

1 | 1 | 0 | 0 |

1 | 0 | 0 | 1 |

0 | 1 | 1 | 0 |

0 | 1 | 0 | 1 |

Our requirement tuple is:

2 | 1 | 4 | 3 |

Then one possible schedule would be:

- 3 people with the first schedule (0,0,1,1)
- 2 people with the third schedule (1,0,0,1)
- 1 person with the fourth schedule (0,1,1,0)

..for a total of 6 workers. I think that’s the best you can do, since the first and third time periods have no schedules in common, and there is a total requirement of 6 workers for those time periods.

**Reduction:** G&J don’t give a reference, but they do suggest to use X3C. So we’re given a set X of 3q elements, and a collection C of 3-element subsets of X. The set C’ that we’ll build will be a set of “3q-tuples”, one position corresponding to each element in X. There will be one tuple for each triple in C. The tuples will have 1’s in the 3 positions corresponding to the elements in the triple in C, and 0’s everywhere else. The R-tuple will be all 1’s, and N will be equal to q.

The Staff Scheduling instance we’ve built needs to choose q different tuples to be successful, and that set of tuples will correspond to a solution to the original X3C instance.

**Difficulty: **4, assuming I didn’t miss anything. If you’ve previously explained X3C to your students, this would be a good homework problem.

**The problem: **Timetable Design. This is problem SS19 in the appendix.

**The description: **(I’m using the description in the paper by Even, Itai, and Shamir, because I think it’s clearer than G&J’s definition): We’re given a set H (of hours to schedule), a collection of N “teachers”, each teacher is available for some subset of the H hours. We’re also given a collection of M “Classes”, each class is available to be taught for some subset of the H hours. We’re also given an NxM matrix R of requirements: R_{ij} is the number of hours teacher i needs to teach class j for. Can create a function f: TxCxH->{0,1} such that f(t,c,h) is 1 if teacher T is teaching class c at time h (and 0 otherwise)? The function needs to respect the following rules:

- If f(i,j,h) is 1, then h is in T
_{i}and C_{j}(we only schedule teachers and classes when they’re available) - The sum of f(i,j,h) over all h = R
_{ij}(Each teacher teaches each class the number of hours they’re supposed to - The sum of f(i,j,h) over all i <= 1 (Each class has at most 1 teacher in each time period)
- The sum of (i,j,h) over all i <= 1 (Each teacher can only teach 1 class per time slot).

**Example: **Suppose H was {1,2,3,4,5}

We have 3 teachers:

- T
_{1}is available at {1,2,3} - T
_{2}is available at {3,4,5} - T
_{3}is available at {1,3,5}

..and 3 classes:

- C
_{1}is available at {2,4} - C
_{2}is available at {1,5} - C
_{3}is available at {2,3}

If R was:

1 | 1 | 0 |

1 | 0 | 1 |

0 | 1 | 1 |

(Teachers are rows, so T_{1} needs 1 hour of C_{1}, 1 hour of C_{2}, and none of C_{3}, this won’t be satisfiable, since neither T_{2} nor T_{3} can teach C_{3} during hour 2, and someone has to. If we change C_{3} to be available at {2,3,5}, then this becomes satisfiable:

- T
_{1}can only teach C_{1}at time 2, and C_{2}at time 1 - T
_{2}can only teach C_{1}at time 4, and C_{3}can be either time 3 or 5. Let’s pick 5. - T
_{3}can teach C_{2}at times 1 or 5, but time 1 is taken by T_{1}, so we schedule it at time 5. Similarly, C_{3}is available at times 2 and 3, and T_{3}is also available at time 3, so we can schedule that class then.

**Reduction: **Even, Itai, and Shamir use 3SAT. So we’re given a set X of literals (x_{1} through x_{l}, and the negation ~x_{1} through ~x_{l}), and a set D of k clauses (D_{1} through D_{k}). Define p_{i} to be the number of times variable i (so the literal x_{i} or the literal ~x_{i}) shows up in the formula. Each variable i will get 5*p_{i} classes denoted C^{i}_{ab}, where a runs from 1 to p_{i}, and b runs from 1 to 5. There will be 3 hours to schedule the classes. They organize the teachers for the classes in a widget that looks like this (from the paper, p. 693):

The idea is that the diagonal lines are teachers who have to teach the 2 classes connected by the line (So, C_{12} and C_{13} for example) and the crosses are the 2 ways they can teach it (so h_{2} and h_{3}). The bottom arrows are teachers who can have 3 hours of availability and 3 classes to teach. Each variable gets p_{i} teachers who teach C_{q3} and C_{q4} (where q runs from 1 to p_{i}) during h_{1} and h_{2}. If C_{q3} is taught at time h_{1}, the variable is treated as being set to positive, otherwise, it’s negative.

We then need to add more jobs to make sure that we make one literal true in each clause. This is done by creating a teacher with 3 classes (one for each literal in the clause). If the literal is the qth occurrence of literal x_{i}, the teacher is assigned to class C^{i}_{q2 }if the literal is true, and C^{i}_{q5} if the literal is false.

If there is a satisfiable solution to the SAT instance, the literal that makes each clause true will define a way to set the teacher at time h_{1} and h_{2}, and that starts a chain reaction that schedules everything.

If there is a feasible timetable, we look at the C^{i}_{q3} and C^{i}_{q4} classes to see how we have allocated the teachers to those tasks, which tells us how to set the variables to make each clause true.

**Difficulty: **9. I’m having a hard time following all of the classes and teachers here. I wonder if there is a much easier way to do this if we reduce from some other problem.

]]>

**The problem: **Job-Shop Scheduling. This is problem SS18 in the appendix.

**Description: **We’re given a set of m processors and a set J of jobs. Each job j in J consists of a chain of tasks, but different jobs can have different numbers of tasks. The subtasks need to be processed in order, and each task has a processor assignment associated with it, and it’s possible that the subtasks can be assigned to the same processor multiple times, and/or skip some processors entirely. The only requirement is that two consecutive tasks need to be on different processors (otherwise, we can just merge those tasks together). If we’re given a deadline D, can we schedule all jobs to complete all of their tasks by time D?

**Example:** Suppose we have three processors and 4 jobs:

- Job 1: 1 time on P1, then 2 time on P2, then 3 time on P3, then 2 time on P2
- Job 2: 2 time on P1, then 3 time on P2, then 2 time on P1
- Job 3: 1 time on P1, then 2 time on P3, then 3 time on P1, then 2 time on P3.
- Job 4: 1 time on P4, and that’s it.

Then we can get everything done by time 8 with the following schedule:

P1 | 1 | 2 | 2 | 3 | 3 | 3 | 2 | 2 |

P2 | 3 | 1 | 1 | 2 | 2 | 2 | 1 | 1 |

P3 | 4 | 3 | 3 | 1 | 1 | 1 | 3 | 3 |

**Reduction: **Garey, Johnson, and Sethi use 3-Partition. So we’re given a set of 3n elements A, and a bound B. The Job-Shop instance will have 2 processors and 3n+1 jobs labeled C_{0} through C_{3n}. Job C_{0} has 2n tasks, alternating B time on each processor (so, B time on P1, then another B time on P2, then another B time on P1, and so on). The rest of the tasks get 0 time on P1 and a_{1} time on P2. The deadline is 2nB, which is the time it takes to schedule all of C_{0}. The paper leaves out the “straightforward” task of showing this reduction actually solves the problem. I believe them that it is straightforward, let’s take a closer look:

If A has a 3-Partition, then we have a collection of N sets of 3 elements that all add up to B. Each one of these sets can fit on P2 while C_{0} is running on P1 (since C_{0} uses P1 for exactly B time for each task on P1), so we can fit all of the C tasks into the “holes” left by C_{0}.

If we have a schedule that meets the deadline, we know that C_{0} must be scheduled continually, which leaves the B-sized holes on P2. For all of the A tasks to be scheduled by the deadline, they have to fit in those holes, which gives us a partition of A.

**Difficulty: **5. The hard part, of course, is coming up with the conversion. 3-Partition isn’t the easiest problem to work with, but the nice features of it (especially that you know that any subset of A that adds to B has exactly 3 elements) make it a good fit here.

I wonder if it’s necessary to have C_{0} spend B time on both processors. I understand the need to have C_{0} running on P2 to separate the partition sets, but wouldn’t it also work (and to my mind, be easier) if C_{0} took just 1 time (instead of B) each time it ran on P2?

I also wonder if there isn’t an easier reduction that goes straight from Flow-Shop Scheduling. The reduction can take the Flow-Shop instance, and map it directly to the Job-Shop instance (just because the Job-Shop problem *allows* you to reuse, reorder, or skip processors with tasks, doesn’t mean it’s *required*). Unless I’m missing something, this is a difficulty 2 reduction. I think the reason they do the 3-Partition reduction in the paper is because they want to show it’s NP-Complete in the case where there are only 2 processors, and the Flow-Shop Scheduling reduction uses 3 processors.