Chapter 3: Planning and Scheduling
September 11, 2013
Last time:
Scheduling tasks Critical-Path Schedules
Review
For a machine-scheduling problem
Tasks are performed by processors
Tasks are arranged in apriority listthat is independent of the
order requirements.
We call a task ready when all its predecessors in the
order-requirement digraph have been completed at that time.
When given a priority list we use the list-processing
algorithmto assign tasks to the processors.
We use the critical-path schedulingalgorithm to obtain a
priority list.
Independent Tasks
Now we deal with a special case, where the digraph has no edges, that is where the tasks are independent.
Example of independent tasks are: Homework assignments Making copies
Motivating Question
Question: What is the best schedule tasks of length 10, 15, 7, 4, 10, 5 on two machines?
Ways to arrive at a solution
Average-case analysis: Is the average of the completion times arrived at by using the list-processing algorithm with all the possible different lists close to the optimal possible completion time?
Worst-case analysis: How far from optimal is a schedule obtained using the list-processing algorithm with one particular priority list?
Decreasing-Time-List Algorithm
Decreasing-Time-List Algorithm
The list-processing algorithm applied to a list of task times arranged in order of non increasing size is called the
decreasing-time-list algorithm.
Motivating Question
Question: A radio station’s policy allows advertising breaks of no longer than 2 minutes, 15 seconds. What is the minimum number of breaks into which the following ads will fit (lengths in seconds): 80, 90, 130, 50, 60, 20, 90, 30, 30, 40?
Bin-Packing
Bin-Packing Problem
Thebin-packing probleminvolves finding the minimum number of bins of weight capacityW into which weights w1,w2,· · ·wn
(each less than or equal toW) can be packed without exceeding
the capacity of the bins.
Heuristic algorithms
next-fit (NF)- If the next weight doesn’t fit start a new bin.
first-fit (FF) - Put the next weight in the first bin that has room, if one doesn’t exist start a new bin.
worst-fit (WF)- Put the next weight in the bin that has the most room, if one doesn’t exist start a new bin.
Question: A radio station’s policy allows advertising breaks of no longer than 2 minutes, 15 seconds. What is the minimum number of breaks into which the following ads will fit (lengths in seconds): 80, 90, 130, 50, 60, 20, 90, 30, 30, 40?
Decreasing-Time Heuristic
next-fit decreasing (NFD) first-fit decreasing(FFD) worst-fit decreasing(WFD)
Question: A radio station’s policy allows advertising breaks of no longer than 2 minutes, 15 seconds. What is the minimum number of breaks into which the following ads will fit (lengths in seconds): 130, 90, 90, 80, 60, 50, 40, 30, 30, 20?
Practice Problems
Question 1: A radio station’s policy allows advertising breaks of no longer than 2 minutes, 15 seconds. What is the minimum number of breaks into which the following ads will fit (lengths in seconds): 60, 50, 40, 40, 60, 90, 90, 50, 20, 30, 30 ,50?
Question 2: It takes 4 seconds to photocopy on page. Manuscripts of 10, 8, 15, 24, 22, 24, 20, 14, 19, 12, 16, 30, 15, and 16 pages are to be photocopied. How many photocopy machines would be required, using the FFD algorithm, to guarantee that all
manuscripts are photocopied in 2 minutes or less? Would the solution differ if WFD were used?
Solution to Question 1
The sum of the lengths of the ad is 610 seconds. 610/135≈4.5,
the solution will have at least 5 breaks.
Using FF algorithm on list: 60, 50, 40, 40, 60, 90, 90, 50, 20, 30, 30 ,50 Bin 1: 60, 50, 20; Bin 2: 40, 40, 50; Bin 3: 60, 30, 30; Bin 4: 90; Bin 5: 90; Bin 6: 50;
Solution to Question 1, cont.
Using FFD algorithm on list: 90, 90, 60, 60, 50, 50, 50, 40, 40, 30, 30, 20 Bin 1: 90, 40; Bin 2: 90, 40; Bin 3: 60, 60; Bin 4: 50, 50, 30; Bin 5: 50, 30, 20; This solution is optimal.
Solution to Question 2
The photocopies times in decreasing order are: 120, 96, 96, 88, 80, 76, 64, 64, 60, 60, 56, 48, 40, 32. The bin size is 120.
Using the FFD algorithm we get: Bin 1: 120; Bin 2: 96; Bin 3: 96; Bin 4: 88, 32; Bin 5: 80, 40; Bin 6: 76; Bin 7: 64, 56; Bin 8: 64, 48; Bin 9: 60, 60;
There are nine printers needed. This solution is optimal since the sum is 980 and 980/120≈8.1
With WFD, the number of bins would not change but the placement of the items in the bin would change.
Next time
Quiz on Friday will be over 2.5 and 3.1-3.5 Friday we will talk about
Resolving Conflict via Coloring