1 / 153

# A Mathematical View of Our World - PowerPoint PPT Presentation

A Mathematical View of Our World. 1 st ed. Parks, Musser, Trimpe, Maurer, and Maurer. Chapter 7. Scheduling. Section 7.1 Basic Concepts of Scheduling. Goals Study project scheduling Study tasks Find finishing times Study weighted digraphs Study maximal paths Find critical times.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about ' A Mathematical View of Our World' - lang

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### A Mathematical View of Our World

1st ed.

Parks, Musser, Trimpe, Maurer, and Maurer

### Chapter 7

Scheduling

Section 7.1Basic Concepts of Scheduling

• Goals

• Study project scheduling

• Find finishing times

• Study weighted digraphs

• Study maximal paths

• Find critical times

• A model railroad club is preparing for an open house.

• Estimate the minimum preparation time required.

• The solution will be given at the end of the section.

• A project consists of 2 or more smaller activities called tasks.

• A task cannot be broken into smaller jobs.

• A task is done by 1 machine or 1 person.

• The amount of time needed to complete a project depends on:

• How many people or machines are available to do the work.

• How the tasks are assigned.

• A group of college students are making lasagna.

• Divide the project into tasks.

• Solution: A possible list of tasks is given.

• The people or machines performing the tasks are called processors.

• The amount of time it takes to perform a task is called its completion time.

• If one task must be completed before another task can be started, we say the tasks have a precedence relation or order requirement between them.

• Tasks that may be done in any order are called independent.

• One way to represent a precedence relation between 2 tasks is to use points to denote the tasks and an arrow to indicate the relationship.

• The tasks of putting on socks and putting on shoes have a preference relation.

• The tasks of putting on a hat and putting on a coat do not have a preference relation. These are independent tasks.

Choose the list of tasks that has no preference relations.

a. bake the pizza, grate some cheese, make pizza sauce

b. fold some clothes, wash some clothes, hang clothes on the line to dry

c. bake the cake, toss the green salad, set the table

d. frost the cake, bake the cake, set the table

• A collection of points (tasks) and straight or curved arrows (precedence relations) connecting them is called a directed graph or digraph.

• A point in a digraph is called a vertex.

• An arrow in a digraph is called an arc.

• Use a digraph to represent the precedence relations for a man dressing to go for a run in the summer.

• The tasks consist of putting on:

• A Shirt

• Shoes

• Shorts

• Socks

• Solution: Determine if there are any order requirements among the tasks.

• Socks must be put on before shoes.

• It is much easier to put on shorts before shoes.

• The shirt can be put on at any point in the process.

• Solution, cont’d: A possible digraph is shown below.

• A digraph that contains at least one precedence relation is called an order-requirement digraph.

• A vertex in a digraph with no arcs attached to it is said to be isolated.

• Example:

• The digraph from the previous example problem is an order-requirement digraph.

• Vertex “put on shirt” is isolated.

• Construct an order-requirement digraph for the tasks of:

• Making blackberry jam

• Making blackberry cobbler

• Picking blackberries

• Solution:

• The berries must be picked first.

• The jam and cobbler can be made in any order.

• Construct an order-requirement digraph for the tasks of:

• Putting on socks

• Putting on a sweatshirt

• Putting on snow pants

• Putting on a hat

• Putting on boots

• Strapping on a snowboard

• Solution:

• The socks probably go on before the pants.

• The pants go on before the boots.

• The boots go on before the snowboard.

• The sweatshirt goes on before the coat.

• The hat can be put on at any point.

• Solution, cont’d: The digraph is shown below.

• Any list of 2 or more vertices connected by arrows such that the list goes in the same direction as the arcs in the corresponding digraph is called a directed path.

• Because we consider only directed paths, we simply call the list a path.

• Identify all possible paths in the order-requirement digraph representing a simple version of the project of replacing old brake shoes.

• Solution: There are 6 possible paths.

• A path that cannot be extended by adding a vertex at either end is called a maximal path.

• In the previous example, the maximal paths were:

• A vertex in a digraph that is at the end of no arc is called a source.

• A vertex in a digraph that is at the start of no arc is called a sink.

• An isolated vertex is both a source and a sink.

• A maximal path starts at a source and ends at a sink.

• In this digraph from the previous example,

• Vertex T1 is a source.

• Vertex T4 is a sink.

Identify all sources and sinks.

a. Sources: put on socks; Sinks: put on hat

b. Sources: put on hat, put on coat, strap on

snowboard; Sinks: put on socks, put on sweatshirt

c. Sources: put on hat; Sinks: put on socks

d. Sources: put on socks, put on sweatshirt;

Sinks: put on hat, put on coat, strap on snowboard

• To find all maximal paths in a digraph:

• Locate all the sinks that are not isolated vertices.

• Locate all the sources that are not isolated vertices.

• For each source, follow the arcs until you reach a sink.

• If there is more than one arc at any vertex along the path formed in Step 3, start again at the same source and choose a different route.

Which path listed below is not a maximal path?

a. put on hat

b. put on pants, put on boots

c. put on sweatshirt, put on coat

d. put on socks, put on pants, put on boots, strap on snowboard

• Identify all maximal paths in the digraph.

• Solution:

• There is only one sink: T6

• There is only one source: T1

• Solution, cont’d:

• A maximal path from T1 to T6 is

• Another maximal path from T1 to T6 is

• Identify all maximal paths in the digraph.

• Solution:

• There is only one sink: T10

• Solution, cont’d:

• There are 4 sources: T1, T4 , T6, and T8.

• Solution, cont’d:

• There are 4 maximal paths:

• The completion time associated with a vertex (task) is the weight of the vertex.

• A digraph with weights at each vertex is called a weighted digraph.

• For example: This weighted digraph shows that it takes 20 seconds to put on sock and 25 seconds to put on shoes.

• Construct a weighted digraph.

• Solution:

• The time from the beginning of a project until the end of the project is called the finishing time for the project.

• The finishing time depends on:

• The number of processors available.

• How the processors are scheduled.

• Whether or not some tasks can be done at the same time.

• If only one processor works on the lasagna project, what is the finishing time?

• Solution: We assume the processor can only perform one task at a time.

• Add up all the task completion times: 10 + 5 + 30 + 10 + 10 + 2 + 6 + 7 + 8 + 30 = 118 minutes.

• It will take one processor almost 2 hours to finish the project.

• The weight of a path in a weighted order-requirement digraph is the sum of the weights at the vertices on the path.

• A critical path in an order-requirement digraph is a path having the largest possible weight.

• The weight of a critical path is called the critical time for the project.

• Any critical path must be a maximal path.

• To find the critical paths:

• Find all the maximal paths.

• Select the maximal path(s) with the largest weight.

• Find a critical path in the lasagna project digraph.

• Solution: Previously we found 4 maximal paths.

Solution, cont’d:

• Solution, cont’d: The largest weight for any maximal path is 83.

• The one critical path is

• The critical time for the project is 83 minutes.

• It will take a minimum of 83 minutes, with enough processors, to make the lasagna.

• This example illustrates the fact that the finishing time of a project is always greater than or equal to its critical time.

• A model railroad club is preparing for an open house.

• What is the minimum completion time?

• The first 6 tasks need to be done first and in order.

• Everything else must be done before task 10.

• A weighted digraph is created.

• Find all maximal paths, along with their weights.

• The critical time of the project is 52 hours.

• The finishing time is greater than or equal to the critical time, so it will take at least 52 hours to prepare for the open house.

Section 7.2List-Scheduling Algorithm

• Goals

• Study project scheduling

• Study priority lists

• Use the list-scheduling algorithm

• Create and read Gantt charts

• Study optimal schedules

• Suppose 2 students will make the lasagna in the project examined in Section 7.1.

• What is a good way for the 2 students to divide the work and how long will it take?

• The solution will be given at the end of the section.

• A priority list is an ordered list of all the tasks in a project.

• When tasks are performed, precedence relations override a priority list.

• A priority list tells you which task to do first among those you can do at a certain point in time.

• A woodworking project consists of 7 tasks.

• The weighted digraph above represents the project, with completion times in minutes.

• Determine the critical time.

• Create a priority list based on completion time, from shortest to longest.

• Solution: The 3 maximal paths, and their weights, are listed.

• Solution, cont’d: The largest weight of a maximal path in this case is 90 minutes.

• The critical time is 90 minutes.

• Solution, cont’d: The tasks are placed in a priority list according to their completion times.

• The priority list is T1, T5, T2, T3, T6, T7, and T4.

• A priority list in which tasks are arranged from shortest completion time to longest completion time is called an increasing-time priority list.

• A priority list in which tasks are arranged from longest completion time to shortest completion time is called a decreasing-time priority list

Create the decreasing-time priority list for the project whose digraph is shown below.

a.

b.

c.

d.

• How would one processor finish the woodworking project from the previous example using the increasing-time priority list T1, T5, T2, T3, T6, T7, and T4?

• Solution: Use the precedence relations and the priority list to determine the order of the tasks.

• Task T1is a source and is first on the list, so it will be done first.

• Next, either T2or T3could be done. Choose T2because it is first in the list.

• At this point, the tasks that can be done are T3 or T5. According to the priority list, choose T5.

• Solution, cont’d: The order of the rest of the tasks is determined in the same manner.

• The priority list is T1, T5, T2, T3, T6, T7, T4.

• The order in which the tasks will be completed is T1, T2, T5, T3, T6, T4, T7 .

• We can keep track of the order in which tasks are done and how long it takes using a diagram called a Gantt chart.

• Numbers at the bottom of the chart show the elapsed time.

• The boxes represent the tasks.

• A Gantt chart for the woodworking project in the previous example is shown below.

• A task T will be called ready if all tasks required to begin T have been completed.

• A processor that has not yet been assigned a task and is not working on a task will be called idle.

• At the beginning of a project we assume all processors are idle and at least 1 task is ready.

• The lowest-numbered idle processor is assigned to the highest-priority ready task until either all processors are assigned or all ready tasks have been assigned.

• When a processor completes a task, that processor becomes idle. One of 3 cases will occur.

• If there are no ready tasks but not every task has been done, the processor remains idle until more tasks are completed.

• If all tasks have been completed, the project is finished.

• Apply the algorithm to the wood-working project using 2 processors and the increasing-time priority list T1, T5, T2, T3, T6, T7, T4.

• Solution: Step 1:

• P1 is assigned to T1.

• P2 remains idle.

• Solution, cont’d: At 5 minutes, Step 2, Case A.

• Not completed: T2, T3, T4, T5, T6, T7.

• Priority list: T1, T5, T2, T3, T6, T7, T4.

• Solution, cont’d: Step 1:

• P1 and P2 are idle.

• P1 is assigned to T2.

• P2 is assigned to T3.

• Solution, cont’d: At 20 minutes, Step 2, Case A.

• Not completed: T3, T4, T5, T6, T7.

• Priority list: T1, T5, T2, T3, T6, T7, T4.

• Solution, cont’d: Step 1:

• P1 is idle.

• P1 is assigned to T5.

• Solution, cont’d: At 25 minutes, Step 2, Case A.

• Not completed: T4, T5, T6, T7.

• Priority list: T1, T5, T2, T3, T6, T7, T4.

• Solution, cont’d: Step 1:

• P2 is idle.

• P2 is assigned to T6.

• Solution, cont’d: At 30 minutes, Step 2, Case A.

• Not completed: T4, T6, T7.

• Priority list: T1, T5, T2, T3, T6, T7, T4.

• Solution, cont’d: Step 1:

• P1is idle.

• P1 is assigned to T4.

• Solution, cont’d: At 50 minutes, Step 2, Case B.

• Not completed: T4, T7.

• Priority list: T1, T5, T2, T3, T6, T7, T4.

• Solution, cont’d: Step 1:

• P2 remains idle.

• Solution, cont’d: At 65 minutes, Step 2, Case A.

• Not completed: T7.

• Priority list: T1, T5, T2, T3, T6, T7, T4.

• Solution, cont’d: Step 1:

• P1 and P2 are idle.

• P1 is assigned to T7.

• Solution, cont’d: At 95 minutes, Step 2, Case C.

• Not completed: none.

• The finishing time with 2 processors is 95 minutes.

• This is less than 140 minutes for 1 processor, but more than the critical time of 90 minutes.

• Apply the algorithm to the wood-working project using 3 processors and the increasing-time priority list T1, T5, T2, T3, T6, T7, T4.

• Solution: Step 1:

• P1 is assigned to T1.

• P2 and P3 remain idle.

• Solution, cont’d: At 5 minutes: Step 2 and Step 1

• P1, P2 and P3are idle.

• P1 is assigned to T2.

• P2 is assigned to T3.

• P3remains idle.

• Solution, cont’d: At 20 minutes: Step 2 and Step 1

• P1 and P3are idle.

• P1 is assigned to T5.

• P3remains idle.

• Solution, cont’d: At 25 minutes: Step 2 and Step 1

• P2 and P3are idle.

• P2is assigned to T6.

• P3is assigned to T4.

• Solution, cont’d: At 30 minutes: Step 2 and Step 1

• P1is idle.

• P1 remains idle.

• Solution, cont’d: At 50 minutes: Step 2 and Step 1

• P1 and P2are idle.

• P1and P2remain idle.

• Solution, cont’d: At 60 minutes: Step 2 and Step 1

• P1, P2 and P3 are idle.

• P1 is assigned to T7.

• Solution, cont’d: At 90 minutes: Step 2 and Step 1

• P1, P2 and P3are idle.

• All tasks have been completed.

• The completion time with 3 processors is 90 minutes, the critical time.

• The project completion is summarized in the Gantt chart.

• Apply the algorithm to the wood-working project using 2 processors and the decreasing-time priority list T4, T7, T6, T3, T2, T5, T1.

• Solution: Step 1:

• P1 is assigned to T1.

• P2remains idle.

• Solution, cont’d: At 5 minutes: Step 2 and Step 1

• P1and P2 are idle.

• P1 is assigned to T3.

• P2 is assigned to T2.

• Solution, cont’d: At 20 minutes: Step 2 and Step 1

• P2 is idle.

• P2 is assigned to T5.

• Solution, cont’d: At 25 minutes: Step 2 and Step 1

• P1 is idle.

• P1 is assigned to T4.

• Solution, cont’d: At 30 minutes: Step 2 and Step 1

• P2is idle.

• P2 is assigned to T6.

• Solution, cont’d: At 55 minutes: Step 2 and Step 1

• P2is idle.

• P2remains idle.

• Solution, cont’d: At 60 minutes: Step 2 and Step 1

• P1 and P2 are idle.

• P1 is assigned to T7.

• P2remains idle.

• Solution, cont’d: At 90 minutes: Step 2 and Step 1

• P1 and P2are idle.

• The finishing time with the decreasing-time priority list and 2 processors is 90 minutes.

• Solution, cont’d:

Given the priority list

and the digraph for the project, which tasks will be assigned first if there are 3 processors?

• An optimal schedule is a schedule assigning processors to tasks in such a way that it results in the shortest possible finishing time for that project with that number of processors.

• If the finishing time is equal to the critical time, we know the schedule is optimal.

• If the finishing time is more than the critical time, the schedule may or may not be optimal.

• Typically, the decreasing-time priority list gives a better finishing time than does the increasing-time priority list.

• Form a decreasing-time priority list.

• Apply the list-processing algorithm.

• If 2 or more tasks have the same completion time, they may be chosen in any order.

• Determine a schedule and the finishing time for the lasagna project with 2 processors.

• Use a decreasing-time priority list: T3, T10, T1, T4, T5, T9, T8, T7, T2, T6.

• The Gantt chart that results from applying the algorithm is shown next.

• The finishing time for this project with 2 processors and a decreasing-time priority list is 90 minutes.

• The critical time was 83 minutes.

• This may or may not be an optimal schedule.

Section 7.3The Critical-Path Algorithm

• Goals

• Study the critical-path priority list algorithm

• Create the critical-path priority list

• Schedule tasks according to the critical-path priority list

• Find an optimal schedule for the lasagna project using 2 processors.

• The solution will be given at the end of the section.

• A digraph for the project of making sandwiches is shown below.

• Two processors will be assigned.

• Apply the decreasing-time algorithm to create a schedule and find the finishing time.

• Find the critical path and the critical time.

• Find the finishing time when one processor is assigned to the tasks in the critical path and one to the other tasks.

• Solution: The decreasing-time priority list is T1, T2, T3, T4, T5, T6, T7.

• The Gantt chart shows a finishing time of 39 minutes.

• Solution: The maximal paths and their weights are shown below.

• The critical time is 30 minutes.

• Solution: Instead of using a priority list, all tasks in the critical path are assigned to one processor.

• The Gantt chart shows a finishing time of 30 minutes.

• List all the maximal paths and isolated vertices.

• Find the greatest of all the weights of the maximal paths and isolated vertices.

• If the weight belongs to a maximal path, the task at the head of the path goes next in the priority list.

• If the weight belongs to an isolated vertex, that task goes next in the priority list.

• Remove the task selected in Step 2 and all attached edges from the digraph.

• Using the new digraph, repeat Step 1 and Step 2.

• Find the critical-path priority list.

• Solution: The maximal paths are listed. There are no isolated vertices.

• The greatest weight is 42, so the first task in the list is T2.

• Solution, cont’d: The task and all attached edges are removed from the digraph.

• Solution, cont’d: The maximal paths are listed. There are no isolated vertices.

• The greatest weight is 38, so the next task in the list is T1.

• Solution, cont’d: Remove T1 and create a new digraph and table.

• The greatest weight is 30, so the next task in the list is T5.

• Solution, cont’d: Remove T5 and create a new digraph and table.

• The greatest weight is 22, so the next task in the list is T6.

• Solution, cont’d: Remove T6 and create a new digraph and table.

• The greatest weight is 20, so the next task in the list is T3.

• Solution, cont’d: Remove T3 and create a new digraph and table.

• The greatest weight is 15, so the next task in the list is T7.

• Solution, cont’d: Remove T7and create a new digraph and table.

• The greatest weight is 11, so the next task in the list is T4.

• Solution, cont’d: Remove T4and create a new digraph and table.

• The next task in the list is T8, followed by T9.

• The priority list is T2, T1, T5, T6, T3, T7, T4, T8, T9.

Find the critical-path priority list for the project.

a.

b.

c.

d.

• Determine the critical-path priority list.

• Apply the list-processing algorithm.

Suppose the critical-path algorithm is being used to schedule a project using 3 processors. The priority list is . At 2 minutes, the status is that Processors 1 and 2 are both working on task, while Processor 3 is idle. What should happen at this point?

a. Processor 3 is assigned

b. Processor 3 is assigned

c. Processor 3 is assigned

d. Processor 3 remains idle.

• Apply the critical-path scheduling algorithm using 2 processors.

• Solution: The critical-path priority list was found in the last example: T2, T1, T5, T6, T3, T7, T4, T8, T9.

• The Gantt chart is shown below.

• Solution, cont’d: The finishing time with 2 processors using the critical-path priority list is 42 minutes.

• There were 2 periods of time during which Processor 2 had to remain idle.

• Two processors will complete the lasagna project.

• We will use the critical-path priority list.

• The maximal paths are listed, with their weights.

• The greatest weight is 83, so the first task in the list is T1.

• Remove T1.

• The maximal paths are listed, with their weights.

• The greatest weight is 73, so the next task in the list is T2.

• Remove T2.

• The maximal paths are listed, with their weights.

• The greatest weight is 68, so the next task in the list is T3.

• Remove T3.

• The maximal paths are listed, with their weights.

• The greatest weight is 58, so the next task in the list is T4.

• Remove T4.

• The maximal paths are listed, with their weights.

• The greatest weight is 48, so the next task in the list is T5.

• Remove T5.

• The maximal paths are listed, with their weights.

• The greatest weight is 46, so the next task in the list is T6.

• Remove T6.

• The maximal paths are listed, with their weights.

• The greatest weight is 45, so the next task in the list is T8.

• Remove T8.

• The maximal paths are listed, with their weights.

• The task are assigned in the order T7, T9, T10.

• The critical-path priority list is T1, T2, T3, T4, T5, T6, T8, T7, T9 , T10 .

• The Gantt chart is shown above.

• The finishing time is equal to the critical time of 83 minutes, so we know the schedule is optimal.