1

In his book, The Algorithm Design Manual, Steven S. Skiena poses the following problem:

            enter image description here

Now consider the following scheduling problem. Imagine you are a highly-indemand actor, who has been presented with offers to star in n different movie projects under development. Each offer comes specified with the first and last day of filming. To take the job, you must commit to being available throughout this entire period. Thus you cannot simultaneously accept two jobs whose intervals overlap.

For an artist such as yourself, the criteria for job acceptance is clear: you want to make as much money as possible. Because each of these films pays the same fee per film, this implies you seek the largest possible set of jobs (intervals) such that no two of them conflict with each other.

For example, consider the available projects in Figure 1.5 [above]. We can star in at most four films, namely “Discrete” Mathematics, Programming Challenges, Calculated Bets, and one of either Halting State or Steiner’s Tree.

You (or your agent) must solve the following algorithmic scheduling problem:

Problem: Movie Scheduling Problem

Input: A set I of n intervals on the line.

Output: What is the largest subset of mutually non-overlapping intervals which can be selected from I?

I wonder, is this an instance of the TSP (perhaps a simplified one)?

Community
  • 1
  • 1
wjmolina
  • 2,625
  • 2
  • 26
  • 35
  • It's certainly not TSP. As you'll find out a page or two later, this problem can be solved in efficiently (not sure if linear time, but at worst Theta(n log n)), and as you'll find out a couple hundred pages later, TSP cannot be solved efficiently. –  Aug 23 '13 at 22:42
  • @delnan, in that case, what is this problem's classification? – wjmolina Aug 23 '13 at 22:43
  • Well, what do you mean by classification? I could tell you where it's in the complexity hierarchy (it's at least in P) but probably isn't what you meant. –  Aug 23 '13 at 22:47
  • @delnan, I meant: does this problem fundamentally boil down to a general, well-known problem? My first guess was the TSP, but I am now suspecting if it is the knapsack problem. – wjmolina Aug 23 '13 at 22:48
  • No, any NP problem is right out for the reason stated in my first comment. I would say this *is* a "general, well-known problem". Just not as famous as many NP problems because it it's neither related to a famous unsolved problem (P?=NP) nor very common in real applications (like sorting). –  Aug 23 '13 at 22:50

2 Answers2

1

This problem can be solve by simply choosing the film with the earliest finish date, and proceeding from there, an O(n^2) process (there may be even faster solutions). Since we've found a polynomial time solution, it's not an instance of TSP, unless: (1) P=NP, and (2) there's an embarrassingly easy proof of (1).

Teepeemm
  • 4,331
  • 5
  • 35
  • 58
-2

Here's how to approach this problem:

  1. Create a tree with the vertices being the films and the edges being overlaps. That is, two vertices are connected by an edge iff their schedule overlap. Thus the problem can be restated like this: "Given a graph G find the maximal subset of unconnected vertices."

  2. Now one can relate the above problem to the known NP-hard problem. Specifically, create a graph G' with the same vertices and complimentary edges. That is, G' has an edge between vertices iff the original graph G didn't have it. Now the problem can be restated like this: "Given a graph G' find the maximal clique, where a clique is a subset of vertices all of which are connected to each other."

Clique is a well-know NP-hard problem. Because your scheduling problem is equivalent to Clique - voila! It's NP-hard too.

Michael
  • 5,775
  • 2
  • 34
  • 53
  • @delnan states that the problem is not in NP space, though. So, is he wrong? – wjmolina Aug 24 '13 at 00:42
  • To make this argument work, you need to go the other direction -- take an arbitrary graph and find a set of movies to which it corresponds. That's not possible, though, and in fact the asker's problem has a polynomial-time solution. – David Eisenstat Aug 24 '13 at 01:13
  • You are right, rookie mistake, went the opposite direction. :( – Michael Aug 24 '13 at 01:22
  • 1
    If you invert this, and put edges between all movies that _don't_ overlap, you can solve it by finding the longest path through the resulting DAG. – Nick Johnson Aug 24 '13 at 18:10
  • Nick, great idea, except it will be undirected graph rather than DAG. – Michael Aug 24 '13 at 22:25
  • No, you want a DAG, where arrows only go forward in time. Otherwise, you could get overlapping movies by going through a completely separate movie, such as Steiner's Tree -> Process Terminated -> Halting State. – Teepeemm Aug 25 '13 at 13:42