1 / 32

Weighted Interval Scheduling: Divide and Conquer Algorithm

This lecture discusses the problem of weighted interval scheduling and presents a divide and conquer algorithm to solve it. It explores different greedy algorithms and their limitations, and proposes a recursive approach for finding the optimal schedule. The lecture also covers the concept of patching up solutions to sub-problems.

farteaga
Télécharger la présentation

Weighted Interval Scheduling: Divide and Conquer Algorithm

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 33 CSE 331 Nov 19, 2018

  2. Thanksgiving break

  3. Sample Final exam

  4. Final exam: Dec 10

  5. Graded HW 7 Should be done by tonight

  6. High level view of CSE 331 Problem Statement Problem Definition Three general techniques Algorithm “Implementation” Data Structures Analysis Correctness+Runtime Analysis

  7. Greedy Algorithms Natural algorithms Reduced exponential running time to polynomial

  8. Divide and Conquer Recursive algorithmic paradigm Reduced large polynomial time to smaller polynomial time

  9. A new algorithmic technique Dynamic Programming

  10. Dynamic programming vs. Divide & Conquer

  11. Same same because Both design recursive algorithms

  12. Different because Dynamic programming is smarter about solving recursive sub-problems

  13. End of Semester blues Can only do one thing at any day: what is the optimal schedule to obtain maximum value? Write up a term paper (10) Party! (2) Exam study (5) 331 HW (3) Project (30) Monday Tuesday Wednesday Thursday Friday

  14. Previous Greedy algorithm Order by end time and pick jobs greedily Greedy value = 5+2+3= 10 Write up a term paper (10) OPT = 30 Party! (2) Exam study (5) 331 HW (3) Project (30) Monday Tuesday Wednesday Thursday Friday

  15. Today’s agenda Formal definition of the problem Start designing a recursive algorithm for the problem

  16. Weighted Interval Scheduling Input: n jobs/intervals. Interval i is triple (si, fi, vi) start time value finish time v3 = 2 v4 = 3 v2 = 4 v1 = 30 2 3 1 0

  17. Previous Greedy Algorithm R = original set of jobs While R is not empty     Choose i in R where fi is the smallest     Add i to S     Remove all requests that conflict with i from R Return S* = S v3 = 2 v4 = 3 v2 = 4 v1 = 30 2 3 1 0

  18. Perhaps be greedy differently? R = original set of jobs While R is not empty     Choose i in R where vi/(fi – si) is the largest     Add i to S     Remove all requests that conflict with i from R Return S* = S v3 = 2 v4 = 3 v2 = 4 v1 = 30 2 3 1 0

  19. Can this work? R = original set of jobs While R is not empty     Choose i in R where vi/(fi – si) is the largest     Add i to S     Remove all requests that conflict with i from R Return S* = S v3 = 2 v4 = 3 v2 = 6 v1 = 12 2 3 1 0

  20. Avoiding the greedy rabbit hole Provably IMPOSSIBLE for a large class of greedy algos https://www.writerightwords.com/down-the-rabbit-hole/ There are no known greedy algorithm to solve this problem

  21. Perhaps a divide & conquer algo? Divide the problem in 2 or more many EQUAL SIZED INDEPENDENT problems Recursively solve the sub-problems Patchup the SOLUTIONS to the sub-problems

  22. Perhaps a divide & conquer algo? RecurWeightedInt([n]) if n = 1 return the only interval Would this general scheme work? L = first n/2 intervals R = last n/2 intervals SL = RecurWeightedInt(L) SR = RecurWeightedInt(R) PatchUp(SL, SR) Divide the problem in 2 or more many EQUAL SIZED INDEPENDENT problems

  23. Sub-problems NOT independent! v6 = 20 v3 = 10 v2 = 2 v4 = 4 v1 = 1 v5 = 5 2 3 0 1

  24. Perhaps patchup can help? Patchup the SOLUTIONS to the sub-problems v6 = 20 v3 = 10 v2 = 2 v1 = 1 2 3 0 1

  25. Sometimes patchup NOT needed! v6 = 0 v3 = 10 v2 = 2 v4 = 4 v1 = 1 v5 = 5 2 3 0 1

  26. Check for two cases? 6 is in the optimal solution v6 = 20 v6 = 0 v3 = 10 v3 = 10 6 is NOT in the optimal solution v2 = 2 v2 = 2 v4 = 4 v4 = 4 v1 = 1 v1 = 1 v5 = 5 v5 = 5 2 2 3 3 1 1 0 0

  27. Check if v6 is the largest value? 6 is in the optimal solution Cannot decide this greedily. Need to have a global view! v6 = 20 v6 = 20 v6 = 0 v3 = 10 v3 = 10 6 is NOT in the optimal solution v2 = 2 v2 = 2 v4= 14 v4 = 4 v1 = 1 v1 = 1 v5 = 5 2 3 1 0 v5 =15 2 3 1 0

  28. Check out both options! v5 = 5 v6 = 20 2 3 1 0 v3 = 10 v2 = 2 v4 = 4 v1 = 1 Case 1: 6 is in the optimal solution

  29. 6 is not in optimal solution v6 = 20 v3 = 10 v2 = 2 v4= 14 v1 = 1 v5 =15 2 3 1 0

  30. So what sub-problems? Divide the problem in 2 or more many EQUAL SIZED INDEPENDENT problems Sub-problem 5 Original problem Sub-problem 2 Sub problem 3 Sub problem 4 Sub problem 1

More Related