Presentation is loading. Please wait.

Presentation is loading. Please wait.

Exploiting Locality: Approximating Sorting Buffers Reuven Bar Yehuda Jonathan Laserson Technion IIT.

Similar presentations


Presentation on theme: "Exploiting Locality: Approximating Sorting Buffers Reuven Bar Yehuda Jonathan Laserson Technion IIT."— Presentation transcript:

1 Exploiting Locality: Approximating Sorting Buffers Reuven Bar Yehuda Jonathan Laserson Technion IIT

2 2 Example Limited Space on truck Packages can get on and off the truck You pay 1$ for every color change in the output $$$ Total Penalty: 3$

3 3 Applications Automobile Industry (e.g. Mercedes: Each car is manufactured for a specific client. The cars come out of an assembly line from the Germen factory assembly line) Communication Networks (uniting multiple requests from the same server in one session will save the overhead time of the handshake-protocol (otherwise needed for each request)). File Servers (the overhead time now is the open/close file operations. Uniting multiple read requests for the same file will save it.) Computer Graphics (computer graphics - rendering polygons - In the rendering process it's highly more efficient if polygons which share similar attributed are processed consecutively)

4 4 The Problem Line of packages from different colors A truck makes one pass along the line Packages can get on and off the truck The truck has limited space Pay 1$ for each color change in the output Goal: Pay minimum amount of $$s

5 5 Same-color adjacent before Same-color adjacent after

6 6 $ Minimization vs. Maximization Minimum Color Changes Maximum Color Savings $ $ $ Before: Pay 4$ $ After: Pay 2$ Save 2$

7 7 New Representation Line of packages from different colors and widths A truck makes one pass along the line Packages can get on and off the truck The truck has limited width (say, 1) Save 1$ from each package after which there is no color change Goal: save maximum amount of $$s

8 8 clearance zone 3 Types of essential Color-Savings Active: Passive: $ $ $ $ $

9 9 3 Types of essential Color-Savings Active: Passive: Active-Passive: clearance zone

10 10 No need to change order of same-color packages ABC AC B Forbidden! $ $ $ $ $ Hence: potential color saving = interval

11 11 Interval $ $3 $1 0$ p(J)=$2 w(J)=0.12 Interval I has: p(I) = the profit of the left package w(I) = the width of the left package Left(I) = the location of the left package Right(I) = the location of the right package p(I)=$1 w(I)=0.06

12 12 No gain from I  Delete I I 0$ I Delete = switch color

13 13 Too fats  No gain  Delete 12$ Super-fat Width > 1 Super-fat Width > 1

14 14 Given a profit vector p. Maximize p·x Subject to:feasibility constraints F(x) x is r-approximation if F(x) and p·x  r · p·x* An algorithm is r-approximation if for any p, F it returns an r-approximation The Local-Ratio Technique: Basic definitions

15 15 x is an r-approximation with respect to p 1 x is an r-approximation with respect to p- p 1  x is an r-approximation with respect to p Proof: (For maximization) p 1 · x  r × p 1 * p 2 · x  r × p 2 *  p · x  r × ( p 1 *+ p 2 *)  r × ( p 1 + p 2 )* The Local-Ratio Theorem:

16 16 Algorithm r-Approx( Set, p ) If Set = Φ then return Φ ; If  p(I)  0 // delete I then return r-Approx(Set-{I},p ); Define “good” p 1 ; REC = r-Approx( S, p- p 1 ) ; If REC is not an r-approximation w.r.t. p 1 then “fix it”; return REC; A Local-Ratio Schema for Maximization problems:

17 17 Case 1: Only fats have money i.e. p(I) > 0  w(I) > 0.5 A 1 is the Last package with money A2A2 1$1$ A0A0 1$1$ 1$1$ 1$1$ If A 1 not gained there must be a package on the truck 1/3 - approximation! 1 ≤ p 1 ·x ≤ 3

18 18 Algorithm MaxFats( S, p ) If S = Φ then return Φ ; If  p(I) =0 then return MaxFats( S - {I}, p); Let Î  S that starts last; ε = minimum p(I) s.t. I in conflict with Î  I  S define: p 1 (I) = CS = MaxFats( S, p- p 1 ) ; If CS is Î-maximal then return IS else return IS  {Î}; //fix it { ε I in conflict with Î 0 else

19 19 3$ 4$ 1$ 3$ 1-1=0$ 3-1=2$3$ 4-1=3$4$ 1$ 3-1=2$ 2-2=0$ 3$ 3-2=1$4$ 1$ 2-2=0$ change

20 20 1-1=0$ 3$ 4-1=3$ 1$ 1-1=0$ 3-1=2$ 0$ Return empty solution Make maximal already maximal change

21 21 3$ 4$ 1$ 3$ 2$3$ 4$ 1$ 2$ 3$ 1$4$ 1$ already maximal Make maximal Profit: 7$

22 22 Fat money $ ThinOdd money $ $ $ ThinEven money $ $ $ $

23 23 Case 2: Only odd thins have money i.e. p(I)>0  w(I)≤ 0.5 and I is odd  No three packages has the same color A2A2 Wg$ Wr$ δ $ δ := 1-Width(A 1 ) δ ≤ p 1 ·x ≤ 2δ+½ 1/3 -approximation! A 1 is the Last package with money

24 24 Algorithm MaxOddThins( S, p ) If S = Φ then return Φ ; If  p(I) =0 then return MaxOddThins( S - {I}, p); Let Î  S that starts last;  I  S define: p 1 (I) = ε × Select the maximum ε s.t.  I :p(I)-p 1 (I) ≥ 0 CS = MaxOddThins( S, p- p 1 ) ; If CS is Î-maximal then return IS else return IS  {Î}; //fix it { 1-w(I) I = Î w(I)I in conflict with Î 0else

25 25 Case 3: Only even thins has money Similar to Case 2 where Only odd thins has money A2A2 Wg$ Wr$ δ $ δ := 1-Width(A 1 ) δ ≤ p · x ≤ 2δ+½ 1/3 -approximation! A 1 is the Last package with money

26 26 $ Fat money $ $ ThinOdd money $ $ $ ThinEven money $ 1/3 Fat* 1/3 ThinOdd* 1/3 ThinEven*

27 27 Full Algorithm 1/9 - approximation! Previous Result: Khort, Pruhs: 1/20-approximation Classify all pairs to fat, thin-even, thin-odd. let x* be an optimal solution. 1/3 of the profit of x* comes from one of the above classes Max{S1, S2, S3} is a 1/9 - approx. □

28 28 Thank You!


Download ppt "Exploiting Locality: Approximating Sorting Buffers Reuven Bar Yehuda Jonathan Laserson Technion IIT."

Similar presentations


Ads by Google