approximation algorithms: job scheduling

31
Approximation Algorithms: Job Scheduling Lecture 16: March 15

Upload: shandi

Post on 15-Jan-2016

51 views

Category:

Documents


0 download

DESCRIPTION

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)) - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Approximation Algorithms:  Job Scheduling

Approximation Algorithms: Job Scheduling

Lecture 16: March 15

Page 2: Approximation Algorithms:  Job Scheduling

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...

Page 3: Approximation Algorithms:  Job Scheduling

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.

Page 4: Approximation Algorithms:  Job Scheduling

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

Page 5: Approximation Algorithms:  Job Scheduling

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

Homework: Find a (very simple) 2-approximation algorithm.

Polynomial time approximation scheme by dynamic programming.

Job Scheduling: Multiple Machines

Page 6: Approximation Algorithms:  Job Scheduling

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.

Page 7: Approximation Algorithms:  Job Scheduling

Why Unrelated?

For example, different processors have different specialties.

Computational jobs, display images, etc…

Page 8: Approximation Algorithms:  Job Scheduling

Why Unrelated?

2 “processors”

Jobs: housework

Page 9: Approximation Algorithms:  Job Scheduling

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?

Page 10: Approximation Algorithms:  Job Scheduling

Linear Programming Relaxation

whether job j is scheduled in machine i

for each job jEach job is scheduledin one machine.

for each machine iEach machine canfinish its jobs by time T

for each job j, machine i Relaxation

Page 11: Approximation Algorithms:  Job Scheduling

How good is the relaxation?

for each job j

for each machine i

for each job j, machine i

Example

One job of processingtime K for each machine

Optimal solution = K.

Optimal fraction solution = K/m.

The LP lower bound could be as bad as you want.

Page 12: Approximation Algorithms:  Job Scheduling

How good is the relaxation?

for each job j

for each machine i

for each job j, machine i

Example

One job of processingtime K for each machine

Optimal solution = K.

Optimal fraction solution = K/m.

Problem of the linear program relaxation:

an optimal solution T could be even smaller than the processing time of a job!

Page 13: Approximation Algorithms:  Job Scheduling

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!

Page 14: Approximation Algorithms:  Job Scheduling

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.

Page 15: Approximation Algorithms:  Job Scheduling

Decision Problems

for each job j

for each machine i

for each job j, machine i

Fix T Let S(T) be the set of jobs with p(i,j) < T.

For example, if all variables with job j are deleted,

then we know that this problem is not feasible.

Use binary search to find the minimum T* such that this LP is feasible.

Page 16: Approximation Algorithms:  Job Scheduling

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.

Page 17: Approximation Algorithms:  Job Scheduling

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.

Page 18: Approximation Algorithms:  Job Scheduling

for each job j

for each machine i

for each job j, machine i

Vertex Solutions

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.

Page 19: Approximation Algorithms:  Job Scheduling

for each job j

for each machine i

for each job j, machine i

Vertex Solutions

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.

Page 20: Approximation Algorithms:  Job Scheduling

Vertex Solutions

There are at most n+m nonzero variables.

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.

p + q = n p + 2q <= n + m

p >= n – m q <= m

There are at most m fractional jobs.

Page 21: Approximation Algorithms:  Job Scheduling

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.

Page 22: Approximation Algorithms:  Job Scheduling

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.

Page 23: Approximation Algorithms:  Job Scheduling

Goal: to design a 2-approximation algorithm for this problem

1) Do preprocessing (parametric pruning) and find a

smallest T* so that LP(T*) is feasible.

2) Find a vertex (basic) solution, say x, to LP(T*).

3) Assign all integral jobs to machines as in x.

4) Match the fractional jobs to the machines so that

each machine is assigned at most one job.

Approximation Algorithm

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.

Page 24: Approximation Algorithms:  Job Scheduling

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.

Page 25: Approximation Algorithms:  Job Scheduling

job

machine

Bipartite Matching

Assume the graph is connected.

There are at most n+m nonzero variables.

n + m vertices,

n + m edges,

at most one cycle.

Page 26: Approximation Algorithms:  Job Scheduling

Bipartite Matching

n + m vertices,

n + m edges,

at most one cycle.

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.

Page 27: Approximation Algorithms:  Job Scheduling

Bipartite Matching

n + m vertices,

n + m edges,

at most one cycle.

Eventually a cycle is left, and we can find a perfect matching.

Match a leaf machine with its adjacent job, then remove these vertices and repeat.

Page 28: Approximation Algorithms:  Job Scheduling

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.

Page 29: Approximation Algorithms:  Job Scheduling

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.

Page 30: Approximation Algorithms:  Job Scheduling

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?

Page 31: Approximation Algorithms:  Job Scheduling

Quick Summary

1. Look at a vertex solution (not many fractional jobs).

2. Schedule all the integral jobs as in the fractional solution.

3. Schedule all the fractional jobs by a matching.

4. Each set can be scheduled in time at most OPT.

5. So we have a 2-approximation algorithm.

Get a feeling on job scheduling problems.

Linear programming is (again) a powerful tool.