450 likes | 473 Views
Parallel Machines ( P | pmtn|C max , P | pmtn ; r i |L max , Q | pmtn|C max , Q | pmtn ; r i |L max ). Lesson 7. Short Review.
E N D
Parallel Machines(P|pmtn|Cmax, P|pmtn; ri|Lmax, Q|pmtn|Cmax, Q|pmtn; ri|Lmax) Lesson 7
Short Review • Problem P||ΣCiand more generally, problem R||ΣCi are the only nonpreemptive problems with arbitrary processing times known to be polynomially solvable. Problems P2||Cmaxand P||ΣwiCiare NP-hard. For these reason, we essentially discuss problems in which preemption is possible.
Identical Machines • Givenn jobs Ji (i = 1,...,n) with processing times pi (i = 1,...,n) to be processed on m identical parallel machines M1 ,..., Mm.
P | pmtn | Cmax • A lower bound for this problem is • A schedule meeting this bound can be constructed in linear time: fill the machines successively, scheduling the jobs in any order and splitting jobs into two parts whenever the above time bound is met. Schedule the second part of a preempted job on the next machine at zero time.
Figure 5.1 m = 3 M1 J1 J2 M2 J2 J3 J4 M3 J4 J5 t 0 LB = 7
Figure 5.2 m = 3 M1 J1 J2 M2 J2 J3 J4 M3 J4 J5 t 0 LB = 9
P | pmtn; ri | Lmax • Associated with each job Jithere is a release time ri • and a due date di with ri di. We have to find a • preemptive schedule on m identical machines such • that the maximum lateness is minimized. • We first consider the decision version of this problem: Given some threshold value L does the exist a schedule • such that In addition we want to find such a schedule if it exists.
Time Windows All jobs i must finish before the modified due dates diL and cannot start before the release times ri, i.e. each job Jimust be processed in an interval [ri, diL] associated with Ji. We call these intervals time windows.
Preemptive Schedule with Time Windows • Next we address the general problem of finding a preemptive schedule for jobs Ji on m identical machines such that all jobs are processed within their time windows [ri, di]. This problem may be reduced to a maximum flow problem.
Notation • Let t1 < t2 < ... < tr be the ordered sequence of all different ri-values and di-values. Consider the intervals IK:=[tK, tK+1] of length TK = tK+1 – tK for K = 1,..., r – 1.
Maximum Flow Problem I1 J1 mT1 p1 TK mTK pi t Ji IK s ri tK &tK+1 di pn mTr–1 Ir–1 Jn
Maximum Flow Problem J1 I1 p1 mT1 TK pi mTK IK t s Ji xiK TK pn mTr–1 Jn Ir–1 xiK Ji tK tK+1 TK
Binary search To solve problem P | pmtn; ri | Lmax , we apply binary search on different L-values. We assume di ri + n max pj, which implies – n max pj Lmax n max pj . This yields an algorithm which approximates the value of the solution with absolute error ε in at the most O(n3(log n + log(1/ε) + log (max pj))) steps.
Uniform Machines • Givenn jobs Ji (i = 1,...,n) to be processed on m parallel uniform machines Mj(j = 1,...,m). • The machines have different speeds sj(j = 1,...,m). • Each job Ji has a processing requirement pi. • Execution of job Ji on machine Mj requires pi/sj time units. If we set sj = 1 for all j we have m parallel identical machines. • Further, we suppose that 1= s1 ≥ s2 ≥ ... ≥ smand p1 ≥ p2 ≥ ... ≥ pn.
Q| pmtn|Cmax Let Pi = p1+...+ pi and Sj = s1+...+ sj for i = 1,..., n and j = 1,..., m. Furthermore, we assume that n≥ m. If n< m, we only have to consider n fastest machines. A necessary conditions for processing all jobs in the interval [0, T] is Pn = p1+...+ pns1 T+...+ sm T = Sm T or Pn / Sm T.
Lower Bound • Also we have Pj /Sj T for j = 1,..., m – 1 because Pj / Sj is a lower bound on the length of a schedule for the jobs J1,..., Jj . Thus, is a lower bound for the Cmax-value.
Level • Now we will construct a schedule which achieves this bound. • The corresponding algorithm is called the level algorithm. • Given a partial schedule up to time t, the level pi(t) of job iat time t is the portion of pi not processed before t.
Algorithm level • t := 0; • while there exists jobs with positive level do • begin • Assign(t); (At time t, the algorithm calls a procedureAssign(t) which assign jobs to machines) • t1:= min{s > t| a job completes at time s}; • t2:= min{s > t| there are jobs i, j with pi(t) > pj(t) and pi(s) = pj(s)}; (The machines run with this assignment until some time s > t) • t := min{t1, t2};(A new assignment is done at time s, and the process is repeated) • end • Construct the schedule.
Assign(t) • J := {i | pi (t) > 0};M:= {M1,..., Mm} • Set all jobs in Jand machines in M to be unassigned; • while there are unassigned jobs and machines do • begin • Find the set I Jof jobs with the highest level; • r:= min{|M|, |I|}; • Assign jobs in Ito be processed jointly on the r fastest machines in M; • J :=J \ I; • Eliminate the r fastest machines in Mfrom M • end ↓
Example p1 = 7 p2 = 6 s1 = 1; s2 = 0.5; s3 = 0.25. p3 = 3 p4 = 2 p5 = 1 t M1 J1 J1, J2 J1, J2 J3, J4 J1, J2 J3, J4, J5 M2 J2 M3 J3 J3, J4 t 0
Jointly jobs • To process r jobs jointly on l machines during some period T, we process each job during period of T/r time units on each of the machines. • The case r = 5 and l = 3 M1 M2 M3 t 0 T/5 2T/5 3T/5 4T/5 T
Optimality Theorem 5.7 Algorithm level constructs an optimal schedule for problem Q| pmtn| Cmax .
Proof • Assume that at the beginning of the level algorithm we have p1(0)≥ p2(0)≥ ... ≥ pn(0). This order does not change during the algorithm, i.e we have p1(t)≥ p2(t)≥ ... ≥ pn(t) for all t. • We assume that the algorithm always assigns jobs to machines in this order.
Case 1 No machine is idle before all jobs are finished, say at time T.
Case 2 • Some machines are idle before the last job finishes, then for the finishing times f1,..., fmof machines M1,..., Mmwe have f1 ≥ f2 ≥ ... ≥ fm. • Otherwise, if fi< fi+1 for some 1 i m– 1, the level of the last job processed on Mi at some time fi – ε, where ε > 0 is sufficiently small, has a smaller level of the last job on Mi+1 at the same time. • But the jobs with the highest level assign to the fastest machines (see procedure Assign). • This is contradiction, so f1 ≥ f2 ≥ ... ≥ fm with at least one strict inequality.
Case 2 (cont.) • Assume that T:= f1 = f2 = ... = fj > fj+1 with j < m. • The jobs finishing at time T musthave been started at time 0. • If this is not the case, then we have job i which starts at time t > 0 and finishes at time T. • This implies that at time 0 at least m jobs, say jobs 1,...,m are started and processed together on all machines. We have p1(0)≥ ... ≥ pm(0) ≥ pi(0), which implies p1(T– ε)≥ ... ≥ pm(T– ε) ≥ pi(T– ε) > 0 for all ε with 0 ε T– t. Thus, until time T no machine is idle, which is a contradiction. • So, the jobs finishing at time T have been started at time 0. • It follows that T(s1+...+ sj) = p1+...+ pj and
Running time • The level algorithm call the procedure Assign(t) at the most O(n) times. • The computational effort for assigning jobs to machines after each call is bounded by O(nm). • Thus, we get a total complexity of O(n2m).
Necessary and Sufficient Conditions • We have seen that jobs 1,2,..., n with processing times p1 ≥ p2 ≥ ... ≥ pn can be scheduled on machines M1,..., Mm with speeds s1 ≥ s2 ≥ ... ≥ smwithin an interval of length T if and only if the following inequalities hold:
Q | pmtn; ri | Lmax • We first consider the problem of finding a schedule with the property that each job i is processed in the time window [ri, di] defined by release time ri and a deadline di of job i. • We call such a schedule feasible with respect to the time windows [ri, di]. • In a second step, we apply binary search to solve the general problem.
Old Idea • For identical machines, we solve the feasibility problem by reducing it to a network flow problem. • Let t1 < t2 < ... < tr be the ordered sequence of all different ri-values and di-values and define IK:=[tK–1, tK], TK = tK– tK–1for K = 2,...,r.
Maximum Flow Problem I2 J1 mT1 p1 TK mTK pi t Ji IK s pn mTr–1 Ir Jn Let IK be an arbitrary interval node and denote by Ji1,…,Jis the set of predecessors of node IK.
Expanded Network Ji1 We replace the subnet-work defined by IK, Ji1,…,Jis by the expanded network. ... IK Jis Ji1 (s1–s2)TK K,1 pi1 1(s1–s2)TK (sj–sj+1)TK ... (sm–sm+1)TK SmTK j(sj–sj+1)TK IK K,j ... pis (s1–s2)TK ... (sj–sj+1)TK m(sm–sm+1)TK Jis K,m (sm–sm+1)TK
Flow and Schedule Theorem 5.8 The following properties are equivalent: • There exists a feasible schedule • In the expanded network there exists a flow from s to t with value
Proof: (b) (a) Consider a flow with value in the expanded network. Denote by xiKthe total flow which goes from Jito IK. Then It is sufficient to show that for each subset A {1,..., n}we have This means that the processing requirements x1K,..., xnK can be scheduled in IK for K = 2,...,r.
Proof: (b) (a) Consider in the expanded network the subnetwork induced by A and the corresponding partial flow. The portion of this flow goes through (K, j) is bounded by min{ j(sj– sj+1)TK, |A|(sj– sj+1)TK} = TK(sj– sj+1)min{j, |A|}. Thus, we have
Expanded Network Ji1 We replace the subnet-work defined by IK, Ji1,…,Jis by the expanded network. ... IK Jis Ji1 (s1–s2)TK K,1 pi1 1(s1–s2)TK (sj–sj+1)TK ... (sm–sm+1)TK SmTK j(sj–sj+1)TK IK K,j ... pis (s1–s2)TK ... (sj–sj+1)TK m(sm–sm+1)TK Jis K,m (sm–sm+1)TK
Proof: (b) (a) |A| > m |A| m
Proof: (a) (b) Assume that a feasible schedule exists. For i = 1,..., n and K = 2,..., r let yiKbe the “amount of work” to be performed on job i in the interval IK according to this feasible schedule. Then for all K = 2,..., r and arbitrary set A {1,..., n}, the inequality holds.
Proof: (a) (b) ? Ji (s1–s2)TK K,1 pi yiK 1(s1–s2)TK (sj–sj+1)TK ... (sm–sm+1)TK SmTK j(sj–sj+1)TK IK K,j ... pj (s1–s2)TK ... (sj–sj+1)TK m(sm–sm+1)TK Jj K,m (sm–sm+1)TK
Proof: (a) (b) A sufficient condition for the existence of such a flow is that for arbitrary A {1,..., n} and K = 2,..., r the value is bounded by the value of a minimum cut in the partial network with sources Ji(i A) and sink IK.
Proof: (a) (b) Ji (s1–s2)TK K,1 1(s1–s2)TK (sj–sj+1)TK ... (sm–sm+1)TK |A| j(sj–sj+1)TK IK K,j ... (s1–s2)TK ... (sj–sj+1)TK m(sm–sm+1)TK Jj K,m (sm–sm+1)TK =
Running time • Because a maximal flow in the expanded network can be calculated in O(mn3) steps, a feasibility check can be done with the same complexity. • To solve problem Q|pmtn; ri|Lmax we do binary search. • This yields an ε-approximation algorithm with complexity O(mn3(log n+log(1/ε)+log(max pi)) because Lmax is certainly bounded by n max piif s1=1.
Exercise • Consider Pm|rj, pmtn|Cmax. Formulate the optimal policy and prove its optimality.