Download presentation
Presentation is loading. Please wait.
Published byBartholomew Mason Modified over 8 years ago
1
Unit 3 Scheduling and Planning
2
Literacy Practice Please read PG 67-68. Stop at ASSUMPTIONS AND GOALS on page 68.
3
Vocabulary 1.Job: 2.Tasks: 3.Processors:
4
Assumptions 1.If a processor starts work on a task, it will not stop until the task is completed. 2.No processor will stay voluntarily idle. If a processor is free to do a task, and a task is available to be worked on, the processor will immediately start work on the task. 3.The requirements for ordering the tasks are given by an order- requirement digraph. 4.The tasks are arranged in a priority list (most important to least important) that is independent of the order requirements.
5
Goals 1.Minimize the completion time of the job (optimal time) 2.Minimize the total time that the processors are idle 3.Find the minimum number or processors necessary to finish the job by a specified time.
6
List-Processing Algorithm At a given time, assign to the lowest-numbered free processor the first task on the priority list that is ready at that time and that hasn’t already been assigned to a processor.
7
Example 2 Schedule the following order-requirement digraph given the following priority list with 2 processors.
9
For Example 2, what is the shortest possible completion time for the job? How did you know?
10
Estimated Minimum Completion Time To estimate the minimum completion time of a Order-Requirement Digraph (ORD), add up all the times of the tasks and divide by the number of processors. That number will be the minimum estimation. Example: If we sum the tasks from Example 2, we get 47. Divide this by 2 processors, and we get 23.5. So we know that the job could never be completed in less that 23.5 minutes regardless of the critical path.
11
Strange Happenings The LPA involves four factors that affect the final schedule: 1.The times to carry out the tasks. 2.Number of processors. 3.Order-requirement digraph. 4.Ordering of the tasks in the priority list.
12
Strange Happenings continued In order to shorten the completion time of a job that has been scheduled, we can do any of three things to the job. 1.Reduce the task times. 1.If every task takes less time, the job should be able to be done quicker. 2.Use more processors. 1.If more people are working on the job, it should go quicker. 3.“Loosen” constraints by having fewer edges in the ORD. 1.If we have more independent tasks, they can be done at any time and we should be able to finish the job quicker.
18
Critical-Path Scheduling Algorithm The critical-path scheduling algorithm applies to the LPA using the priority list obtained as follows: 1.Find the task that heads the critical path in the ORD. If there is a tie, choose the one with the lower task number. 2.Place the task found in step one next on the list. 3.Remove the task and its connected edges from the ORD. 4.Continue steps 1-3 until there are no vertices left.
19
Priority List
21
Not a game. We’re talkin’ ‘bout practice, man. 1. Individually, create an Order-Requirement Digraph. 2. Get with a partner and trade your digraphs. 3. Using the critical-path scheduling algorithm and the list processing algorithm, determine the priority list and schedule the digraph using 2 processors.
22
Literacy Practice Please read page 78 starting at section 3.3. Stop reading at page 79 before Decreasing-Time Lists
23
Decreasing-Time Lists The LPA applied to a list of task times arranged in order of nonincreasing size. Ex: 10, 4, 5, 9, 7, 7 are the times of independent tasks. Using the DTL, the tasks would be arranged 10, 9, 7, 7, 5, 4
24
Example Schedule a job that has all independent tasks of times 3,4,2,8,5,9,7 with two processors using Decreasing-Time Lists. Then try it with three processors. 1.What is the idle time of each processor? 2.What is the total idle time? 3.Are either of these schedules optimal?
25
Schedule the following graphs on 2, then three processors using the critical path scheduling algorithm.
26
Schedule the following graphs using the Decreasing Time Lists Algorithm on 2 then 3 processors.
27
Bin Packing The bin-packing problem involves finding the minimum number of bins of a specific weight capacity into which items of smaller weights can be packed without exceeding the capacity of the bins. ***This is directly related to the scheduling we have been doing so far this unit, but instead of having a fixed number of processors and looking for a minimum completion time, we have a fixed completion time and need to find the minimum number of processors.
28
Example 1: Bookshelves You would like to build a set of shelves along your living room wall. To match the design you’ve drawn, you need shelves of the following lengths: 6, 6, 5, 5, 5, 4, 4, 2, 2, 2, 3, 7, 8, 8 If the lumber yard only sells wood in 9ft boards, how many board do you need to buy? (assume no wood is ever ruined, wasted, or miscut, i.e. a 9ft board could be cut into a 7ft and a 2ft section)
29
Next-Fit Algorithm (NF) Starting at the beginning of the list, place the weights into the currently open bin. If it does not fit, open a new bin and place the weight in there. Pro: Do not need to know all weights in advance Con: Not always optimal ***Think conveyor belt moving the bins past you, once you move onto the next bin, you cannot go back to a previous one whether or not it has space available.
30
Shelves: NF Each “bin” below is 9ft long. Let’s use the NF algorithm to figure out how many we need. 6, 6, 5, 5, 5, 4, 4, 2, 2, 2, 3, 7, 8, 8
31
First-Fit Algorithm (FF) Just like NF algorithm, but remove the conveyor belt idea. All of the bins are in front of you and you place the weight into the FIRST bin that it FITS into. After a weight is placed in a bin, grab the next weight, and start with bin #1 to see where it will fit.
32
Shelves: FF Each “bin” below is 9ft long. Let’s use the FF algorithm to figure out how many we need. 6, 6, 5, 5, 5, 4, 4, 2, 2, 2, 3, 7, 8, 8
33
Worst-Fit Algorithm (WF) Similar to the FF algorithm, WF requires that the next weight goes into the open bin that has the MOST available space left.
34
Shelves: WF Each “bin” below is 9ft long. Let’s use the WF algorithm to figure out how many we need. 6, 6, 5, 5, 5, 4, 4, 2, 2, 2, 3, 7, 8, 8
35
Why we use each algorithm Next-Fit: Can be used when “bins” are being taken away as they are being packed. Imagine someone coming up and grabbing the bins that you are no longer using, so you are stuck with the one you’re on or a new bin. First-Fit: Packing storage containers full of items that are not breakable, therefore they can be packed tightly without fear of breaking anything inside the bin. Worst-Fit: Packing expensive breakables. WF allows for more space to be left over in each bin since it is more unlikely to completely fill each bin. Since there is extra space, items won’t be pressing against each other.
36
Decreasing-Time Heuristics As we have noticed, large weights toward the end of the list cannot be packed efficiently with smaller weights that occurred early. Therefore, if we organize the list before packing the weights from GREATEST to LEAST, we create three new algorithms that are more likely to be optimal. The three new algorithms are called Next-Fit Decreasing (NFD), First- Fit Decreasing (FFD), and Worst-Fit Decreasing (WFD).
37
Next-Fit Decreasing (NFD) Apply the NFD algorithm to the following list and pack them in the 9ft bins below. 6, 6, 5, 5, 5, 4, 4, 2, 2, 2, 3, 7, 8, 8
38
First-Fit Decreasing (FFD) Apply the FFD algorithm to the following list and pack them in the 9ft bins below. 6, 6, 5, 5, 5, 4, 4, 2, 2, 2, 3, 7, 8, 8
39
Worst-Fit Decreasing (WFD) Apply the WFD algorithm to the following list and pack them in the 9ft bins below. 6, 6, 5, 5, 5, 4, 4, 2, 2, 2, 3, 7, 8, 8
40
Conflict Resolution Read page 84. Stop at Example 5.
41
Example 5 (Page 85) FMHPEISC French (F) X XXX X Math (M)X XX History (H) XXX Philosophy (P)X X English (E)XX X Italian (I)XXX X X Spanish (S) X X Chemistry (C)X XX
43
Definitions Vertex Coloring: Assigning each vertex of a graph a color (label) such that two vertices joined by an edge are assigned different colors. Chromatic Number: The minimum number of colors needed to label the vertices of a graph so that no two vertices of the graph joined by an edge get the same color.
44
Four Color Theorem Alfred Kempe tried to prove Four Color Theorem in 1879, but in 1890 Percy John Heawood found an error. Heawood went on from Kempe’s work to instead prove Five Color Theorem. In 1976, Kenneth Appel and Wolfgang Haken proved four color theorem, however many modern mathematicians do not take the proof as fact because they required thousands of maps and a supercomputer to prove their theorem. No pencil and paper proof exists to this day.
47
Four Color Theorem No matter how complicated the map, only four colors are needed to color it such that no two adjacent sections are the same color. Try to draw a complicated map on a piece of paper. Then trade with a partner and see if they can color it using only four colors.
49
The table below represents species of plants that have competing light or water requirements. Draw a graph that represents the conflicts and find the minimum number of habitats that would be needed to display all these plants in a garden. ABCDE A X XX BX X C X X DX X X EX X
50
The following chart represents species of fish. There is an X between two species if they cannot survive in the same aquarium due to hostility, food needs, or other issues. Find out the minimum number of aquariums we need to house all of the different types of fish. Also, try your best to even out the number of fish in each aquarium. ABCDE A X XX BX XX C X DXX X EX X
51
John, Hannah, Autriana, Derek, and Karla are going on a field trip to the Math Factory with their awesome teacher, Mr. D. The only problem is some of the students HATE each other and cannot be in the car on the way to the Math Factory. How many cars will be needed, and who will be in each car, if the follow table represents students who do not like each other? JHADK John XXX Hannah X X AutrianaXX DerekX X KarlaXX X
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.