310 likes | 492 Views
Approximation Algorithms: Job Scheduling. Lecture 16: March 15. Job Scheduling: General Setting. There are n jobs , each job has: a processing time p(i) (the time to finish this job) a release time r(i) (can only process this job after time r(i))
E N D
Approximation Algorithms: Job Scheduling Lecture 16: March 15
Job Scheduling: General Setting • There are n jobs, each job has: • a processing time p(i) (the time to finish this job) • a release time r(i) (can only process this job after time r(i)) • a deadline d(i) (have to finish this job before time d(i)) • a weight w(i) (e.g. the profit of finishing job i) There are m machines available. • Task: to scheduling the jobs to optimize the following criterion. • To minimize the completion time of all jobs (the makespan) • To finish as many jobs as possible meeting their deadlines • To minimize the weighted average completion time, etc… Practically infinitely many possibilities...
Job Scheduling: One Machine • There are n jobs, each job has: • a processing time p(j) (the time to finish this job) There are 1 machine available. Task: to scheduling the jobs to -To minimize the completion time of all jobs (the makespan) Trivial: just find an arbitrary ordering of the jobs.
Job Scheduling: One Machine • There are n jobs, each job has: • a processing time p(j) (the time to finish this job) There are 1 machine available. Task: to scheduling the jobs to -To minimize the average completion time of all jobs Optimal solution: Find an ordering which schedules long jobs first. Proof: swapping
Job Scheduling: Multiple Machines • There are n jobs, each job has: • a processing time p(j) (the time to finish this job) There are m machines available. Task: to scheduling the jobs -To minimize the completion time of all jobs (the makespan) NP-hard even for 2 machines: Partition problem Polynomial time approximation scheme by dynamic programming. Homework: Find a (very simple) 2-approximation algorithm.
Job Scheduling: Unrelated Multiple Machines • There are n jobs, each job has: • a processing time p(i,j) (the time to finish this job j on machine i) There are m machine available. Task: to scheduling the jobs -To minimize the completion time of all jobs (the makespan) NP-hard to approximate within 1.5 times of the optimal solution. We’ll design a 2-approximation algorithm for this problem together.
Why Unrelated? For example, different processors have different specialties. Computational jobs, display images, etc…
Why Unrelated? 2 “processors” Jobs: housework
Job Scheduling: Unrelated Multiple Machines • There are n jobs, each job has: • a processing time p(i,j) (the time to finish this job j on machine i) There are m machine available. Task: to scheduling the jobs -To minimize the completion time of all jobs (the makespan) Approach: Linear Programming. How to formulate this problem into linear program?
Linear Programming Relaxation whether job j is scheduled in machine i Each job is scheduled in one machine. for each job j Each machine can finish its jobs by time T for each machine i Relaxation for each job j, machine i
How good is the relaxation? Example for each job j One job of processing time K for each machine for each machine i Optimal solution = K. Optimal fraction solution = K/m. for each job j, machine i The LP lower bound could be as bad as you want.
How good is the relaxation? Example for each job j One job of processing time K for each machine for each machine i Optimal solution = K. Optimal fraction solution = K/m. for each job j, machine i Problem of the linear program relaxation: an optimal solution T could be even smaller than the processing time of a job!
How to tackle this problem? Problem of the linear program relaxation: an optimal solution T could be even smaller than the processing time of a job! Ideally, we could write the following constraint: but this is not a linear constraint… Idea? To enforce this constraint by hand!
Preprocessing Fix T. Consider the decision problem instead of an optimization problem Call the resulting linear program LP(T). Note that different T have different linear programs. Fancy name: parametric pruning.
Decision Problems Fix T Let S(T) be the set of jobs with p(i,j) < T. for each job j for each machine i for each job j, machine i Use binary search to find the minimum T* such that this LP is feasible. For example, if all variables with job j are deleted, then we know that this problem is not feasible.
Lower Bound We will use T* as the lower bound on the value of an optimal solution, clearly T* <= OPT, since LP(OPT) is feasible. Observation: Suppose there are m machines and at most m jobs. If we can assign all jobs to the m machines so that each machine is assigned at most 1 job, then the completion time (makespan) is at most T* <= OPT.
Fractional Solutions Fractional solutions could be very fractional. What have we learnt in the last class? Look at a vertex (basic) solution. Very fractional solutions may only be the average of many solutions.
Vertex Solutions for each job j for each machine i for each job j, machine i What can we say about a vertex solution of this LP? Basic solution: unique solution of n linearly independent tight inequalities, where n is the number of variables.
Vertex Solutions for each job j for each machine i for each job j, machine i A tight inequality of the last type corresponds to a variable of zero value. There are at most n+m inequalities of the first two types, and hence there are at most n+m nonzero variables.
Vertex Solutions Say a job is integral if it is assigned entirely to one machine; otherwise a job is fractional. Each fractional job is assigned to at least two machines. Let p be the number of integral jobs, and q be the number of fractional jobs. There are at most n+m nonzero variables. • p + q = n • p + 2q <= n + m • p >= n – m • q <= m There are at most m fractional jobs.
Integral Jobs How to handle integral jobs? Just follow the optimal fractional solution. And so we can schedule all the integral jobs in time at most T* <= OPT, as this schedule (on integral jobs) is just a subset of the fractional solution.
Fractional Jobs Remember this observation we made before. Observation: Suppose there are m machines and at most m jobs. If we can assign all jobs to the m machines so that each machine is assigned at most 1 job, then the completion time (makespan) is at most T* <= OPT. There are at most m fractional jobs. If we could find such a “matching”, then we use this matching to schedule all the fractional jobs in time at most T* <= OPT.
Approximation Algorithm Goal: to design a 2-approximation algorithm for this problem • Do preprocessing (parametric pruning) and find a smallest T* so that LP(T*) is feasible. • Find a vertex (basic) solution, say x, to LP(T*). • Assign all integral jobs to machines as in x. • Match the fractional jobs to the machines so that each machine is assigned at most one job. Proof (assuming a matching exists): Schedule all integral jobs in time T*, Schedule all fractional jobs in time T*, Schedule all jobs in time 2T* <= 2OPT.
Bipartite Matching Task: Match the fractional jobs to the machines so that each machine is assigned at most one job. Create a vertex for each job j, and create a vertex for each machine i, add an edge between machine i and job j if 0 < x(i,j) < 1. Now, the problem is to find a matching so that every job is matched.
Bipartite Matching job machine Assume the graph is connected. There are at most n+m nonzero variables. n + m vertices, n + m edges, at most one cycle.
Bipartite Matching Leaves must be machines, since each fractional job is adjacent to two machines. Match a leaf machine with its adjacent job, then remove these vertices and repeat. n + m vertices, n + m edges, at most one cycle.
Bipartite Matching Match a leaf machine with its adjacent job, then remove these vertices and repeat. Eventually a cycle is left, and we can find a perfect matching. n + m vertices, n + m edges, at most one cycle.
Bipartite Matching If the graph is not connected, we apply the same argument to each connected component. Prove: (1) each component has at most n’+m’ edges. (2) each component has a matching.
Bad Examples m machines m2 – m + 1 jobs: 1 job of processing time m on all machines remaining jobs have processing time 1 on all machines Optimal solution: the large job on one machine, m small jobs on the remaining m-1 machines, makespan = m LP vertex solution: 1/m of the first job and m-1 other jobs to each machine. Our rounding procedure will produce a schedule of makespan 2m-1.
Bad Examples Optimal solution: the large job on one machine, m small jobs on the remaining m-1 machines, makespan = m LP vertex solution: 1/m of the first job and m-1 other jobs to each machine. Our rounding procedure will produce a schedule of makespan 2m-1. Note that there is no integrality gap in this example. Just that the rounding procedure produces the error. Open question: Can we obtain a 3/2 approximation algorithm for this problem?
Quick Summary • Look at a vertex solution (not many fractional jobs). • Schedule all the integral jobs as in the fractional solution. • Schedule all the fractional jobs by a matching. • Each set can be scheduled in time at most OPT. • So we have a 2-approximation algorithm. • Get a feeling on job scheduling problems. • Linear programming is (again) a powerful tool.