16 Oct Create a digraph for the following set of tasks:? Using the priority list T4, T1, T7, T3, T6, T2, T5, schedule the project with two processors.? 5. Using the priority list T4, T3, T9, T10, T
1. Create a digraph for the following set of tasks:
3. Using the priority list T4, T1, T7, T3, T6, T2, T5, schedule the project with two processors.
5. Using the priority list T4, T3, T9, T10, T8, T5, T6, T1, T7, T2 schedule the project with two processors.
7. Using the priority list T4, T3, T9, T10, T8, T5, T6, T1, T7, T2 schedule the project with three processors.
9. Use the decreasing time algorithm to create a priority list for the digraph from #3, and schedule with two processors.
10. Use the decreasing time algorithm to create a priority list for the digraph from #3, and schedule with three processors.
15. With the digraph from #3: a. Apply the backflow algorithm to find the critical time for each task b. Find the critical path for the project and the minimum completion time c. Use the critical path algorithm to create a priority list and schedule on two processors.
Scheduling 155
© David Lippman Creative Commons BY-SA
Scheduling An event planner has to juggle many workers completing different tasks, some of which must
be completed before others can begin. For example, the banquet tables would need to be
arranged in the room before the catering staff could begin setting out silverware. The event
planner has to carefully schedule things so that everything gets done in a reasonable amount
of time.
The problem of scheduling is fairly universal. Contractors need to schedule workers and
subcontractors to build a house as quickly as possible. A magazine needs to schedule
writers, editors, photographers, typesetters, and others so that an issue can be completed on
time.
Getting Started To begin thinking about scheduling, let us consider an auto shop that is converting a car from
gas to electric. A number of steps are involved. A time estimate for each task is given.
Task 1: Remove engine and gas parts (2 days)
Task 2: Steam clean the inside of the car (0.5 day)
Task 3: Buy an electric motor and speed controller (2 days for travel)
Task 4: Construct the part that connects the motor to the car’s transmission (1 day)
Task 5: Construct battery racks (2 days)
Task 6: Install the motor (0.5 day)
Task 7: Install the speed controller (0.5 day)
Task 8: Install the battery racks (0.5 day)
Task 9: Wire the electricity (1 day)
Some tasks have to be completed before others – we certainly can’t install the new motor
before removing the old engine! There are some tasks, however, that can be worked on
simultaneously by two different people, like constructing the battery racks and installing the
motor.
To help us visualize the ordering of tasks, we will create a digraph.
Digraph
A diagraph is a graphical representation of a set of tasks in which tasks are represented
with dots, called vertices, and arrows between vertices are used to show ordering.
For example, this digraph shows that Task 1, notated T1 for compactness, needs to be
completed before Task 2. The number in parentheses after the task name is the time required
for the task.
T1 (2) T2 (0.5)
156
Example 1
A complete digraph for our car conversion would look like this:
The time it takes to complete this job will partially depend upon how many people are
working on the project.
Processors
In scheduling jargon, the workers completing the tasks are called processors. While in
this example the processors are humans, in some situations the processors are
computers, robots, or other machines.
For simplicity, we are going to make the very big assumptions that every processor can do
every task, that they all would take the same time to complete it, and that only one processor
can work on a task at a time.
Finishing Time
The finishing time is how long it will take to complete all the tasks. The finishing time
will depend upon the number of processors and the specific schedule.
If we had only one processor working on this task, it is easy to determine the finishing time;
just add up the individual times. We assume one person can’t work on two tasks at the same
time, ignore things like drying times during which someone could work on another task.
Scheduling with one processor, a possible schedule would look like this, with a finishing
time of 10 days.
Time: 0 1 2 3 4 5 6 7 8 9 10
P1 T1 T3 T4 T5 T2 T6 T7 T8 T9
In this schedule, all the ordering requirements are met. This is certainly not the only possible
schedule for one processor, but no other schedule could complete the job in less time.
Because of this, this is an optimal schedule with optimal finishing time – there is nothing
better.
T1 (2) T2 (0.5)
T3 (2)
T4 (1)
T5 (2)
T6 (0.5)
T7 (0.5)
T8 (0.5)
T9 (1)
Scheduling 157
Optimal Schedule
An optimal schedule is the schedule with the shortest possible finishing time.
For two processors, things become more interesting. For small digraphs like this, we
probably could fiddle around and guess-and-check a pretty good schedule. Here would be a
possibility:
Time: 0 1 2 3 4 5 6 7 8 9 10
P1 T1 T3 T6 T9
P2 T5 T4 T2 T8 T7
With two processors, the finishing time was reduced to 5.5 days. What was processor 2
doing during the last day? Nothing, because there were no tasks for the processor to do.
This is called idle time.
Idle Time
Idle time is time in the schedule when there are no tasks available for the processor to
work on, so they sit idle.
Is this schedule optimal? Could it have been completed in 5 days? Because every other task
had to be completed before task 9 could start, there would be no way that both processors
could be busy during task 9, so it is not possible to create a shorter schedule.
So how long will it take if we use three processors? About 10/3 = 3.33 days? Again we will
guess-and-check a schedule:
Time: 0 1 2 3 4 5 6 7 8 9 10
P1 T1 T2 T6 T8 T9
P2 T3 T7
P3 T4 T5
With three processors, the job still took 4.5 days. It is a little harder to tell whether this
schedule is optimal. However, it might be helpful to notice that since Task 1, 2, 6, and 9
have to be completed sequentially, there is no way that this job could be completed in less
than 2+0.5+0.5+1 = 4 days, regardless of the number of processors. Four days is, for this
digraph, the absolute minimum time to complete the job, called the critical time.
Critical Time
The critical time is the absolute minimum time to complete the job, regardless of the
number of processors working on the tasks.
Critical time can be determined by looking at the longest sequence of tasks in the
digraph, called the critical path
158
Adding an algorithm Up until now, we have been creating schedules by guess-and-check, which works well
enough for small schedules, but would not work well with dozens or hundreds of tasks. To
create a more procedural approach, we might begin by somehow creating a priority list.
Once we have a priority list, we can begin scheduling using that list and the list processing
algorithm.
Priority List
A priority list is a list of tasks given in the order in which we desire them to be
completed.
The List Processing Algorithm turns a priority list into a schedule
List Processing Algorithm
1. On the digraph or priority list, circle all tasks that are ready, meaning that all pre-
requisite tasks have been completed.
2. Assign to each available processor, in order, the first ready task. Mark the task as
in progress, perhaps by putting a single line through the task.
3. Move forward in time until a task is completed. Mark the task as completed,
perhaps by crossing out the task. If any new tasks become ready, mark them as
such.
4. Repeat until all tasks have been scheduled.
Example 2
Using our digraph from above, schedule it using the priority list below:
T1, T3, T4, T5, T6, T7, T8, T2, T9
Time 0: Mark ready tasks
Priority list: T1, T3, T4, T5, T6, T7, T8, T2, T9
We assign the first task, T1 to the first processor, P1, and the second ready task, T3, to the
second processor. Making those assignments, we mark those tasks as in progress:
Priority list: T1, T3, T4, T5, T6, T7, T8, T2, T9
Schedule up to here:
We jump to the time when the next task completes, which is at time 2.
Time: 0 1 2 3 4 5 6 7 8 9 10
P1 T1
P2 T3
Scheduling 159
Time 2: Both processors complete their tasks. We mark those tasks as complete. With Task
1 complete, Task 2 becomes ready:
Priority list: T1, T3, T4, T5, T6, T7, T8, T2, T9
We assign the next ready task on the list, T4 to P1, and T5 to P2.
Priority list: T1, T3, T4, T5, T6, T7, T8, T2, T9
Time 3: Processor 1 has completed T4. Completing T4 does not make any other tasks ready
(note that all the rest require that T2 be completed first).
Priority list: T1, T3, T4, T5, T6, T7, T8, T2, T9
Since the next three tasks are not yet ready, we assign the next ready task, T2 to P1
Priority list: T1, T3, T4, T5, T6, T7, T8, T2, T9
Time 3.5: Processor 1 has completed T2. Completing T2 causes T6 and T7 to become ready.
We assign T6 to P1
Priority list: T1, T3, T4, T5, T6, T7, T8, T2, T9
Time 4: Both processors complete their tasks. The completion of T5 allows T8 to become
ready. We assign T7 to P1and T8 to P2.
Priority list: T1, T3, T4, T5, T6, T7, T8, T2, T9
Time: 0 1 2 3 4 5 6 7 8 9 10
P1 T1 T4
P2 T3 T5
Time: 0 1 2 3 4 5 6 7 8 9 10
P1 T1 T4 T2
P2 T3 T5
Time: 0 1 2 3 4 5 6 7 8 9 10
P1 T1 T4 T2 T6
P2 T3 T5
Time: 0 1 2 3 4 5 6 7 8 9 10
P1 T1 T4 T2 T6 T7
P2 T3 T5 T8
160
Time 4.5: Both processors complete their tasks. T9 becomes ready, and is assigned to P1.
There is no ready task for P2 to work on, so P2 idles.
Priority list: T1, T3, T4, T5, T6, T7, T8, T2, T9
With the last task completed, we have a completed schedule, with finishing time 5.5 days.
Try it Now 1
Using the digraph below, create a schedule using the priority list:
T1, T2, T3, T4, T5, T6, T7, T8, T9
It is important to note that the list processing algorithm itself does not influence the resulting
schedule – the schedule is completely determined by the priority list followed. The list
processing, while do-able by hand, could just as easily be executed by a computer. The
interesting part of scheduling, then, is how to choose a priority list that will create the best
possible schedule.
Choosing a priority list We will explore two algorithms for selecting a priority list.
Decreasing time algorithm
The decreasing time algorithm takes the approach of trying to get the very long tasks out of
the way as soon as possible by putting them first on the priority list.
Decreasing Time Algorithm
Create the priority list by listing the tasks in order from longest completion time to
shortest completion time.
Time: 0 1 2 3 4 5 6 7 8 9 10
P1 T1 T4 T2 T6 T7 T9
P2 T3 T5 T8
T1 (10) T2 (7)
T4 (9)
T7 (13)
T5 (5)
T8 (4)
T6 (4)
T9 (6)
T3 (4)
Scheduling 161
Example 3
Consider the scheduling problem represented by the digraph below. Create a priority list
using the decreasing time list algorithm, then use it to schedule for two processors using the
list processing algorithm.
To use the decreasing time list algorithm,
we create our priority list by listing the
tasks in order from longest task time to
shortest task time. If there is a tie, we will
list the task with smaller task number first
(not for any good reason, but just for
consistency).
For this digraph, the decreasing time
algorithm would create a priority list of:
T6 (10), T3 (7), T10 (7), T1 (6), T5 (5), T4 (4), T7 (4), T2 (3), T8 (3), T9 (2)
Once we have the priority list, we can create the schedule using the list processing algorithm.
With two processors, we’d get:
Time 0: We identify ready tasks, and assign T3 to P1 and T1 to P2
Priority list: T6, T3, T10, T1, T5, T4, T7, T2, T8, T9
Time 6: P2 completes T1. No new tasks become ready, so T4 is assigned to P2.
Priority list: T6, T3, T10, T1, T5, T4, T7, T2, T8, T9
Time 7: P1 completes T3. No new tasks become ready, so T2 is assigned to P1.
Priority list: T6, T3, T10, T1, T5, T4, T7, T2, T8, T9
T1 (6) T5 (5)
T2 (3)
T3 (7)
T4 (4)
T6 (10)
T7 (4)
T10 (7) T8 (3)
T9 (2)
T3 P1
P2 T1
7
6
T3 P1
P2 T1
7
6
T4
10
T3 P1
P2 T1
7
6
T4
10
T2
162
Time 10: Both processors complete their tasks. T6 becomes ready, and is assigned to P1.
No other tasks are ready, so P2 idles.
Priority list: T6, T3, T10, T1, T5, T4, T7, T2, T8, T9
Time 20: With T6 complete, T5 and T7 become ready, and are assigned to P1 and P2
respectively.
Priority list: T6, T3, T10, T1, T5, T4, T7, T2, T8, T9
Time 24: P2 completes T7. No new items become ready, so P2 idles.
Time 25: P1 completes T5. T8 and T9 become ready, and are assigned.
Priority list: T6, T3, T10, T1, T5, T4, T7, T2, T8, T9
Time 27: T9 is completed. No items ready, so P2 idles.
Time 28: T8 is completed. T10 becomes ready, and is assigned to P1.
Priority list: T6, T3, T10, T1, T5, T4, T7, T2, T8, T9
This is our completed schedule, with a finishing time of 35.
T3 P1
P2 T1
7
6
T4
10
T2 T6
20
T3 P1
P2 T1
7
6
T4
10
T2 T6
20
T5
T7
25
24
T3 P1
P2 T1
7
6
T4
10
T2 T6
20
T5
T7
25
24
T8
T9
28
27
T3 P1
P2 T1
7
6
T4
10
T2 T6
20
T5
T7
25
24
T8
T9
28
27
T10
35
Scheduling 163
Using the decreasing time algorithm, the priority list led to a schedule with a finishing time
of 35. Is this good? It certainly looks like there was a lot of idle time in this schedule. To
get some idea how good or bad this schedule is, we could compute the critical time, the
minimum time to complete the job. To find this, we look for the sequence of tasks with the
highest total completion time. For this digraph that sequence would appear to be: T2, T6, T5,
T8, T10, with total sequence time of 28. From this we can conclude that our schedule isn’t
horrible, but there is a possibility that a better schedule exists.
Try it Now 2
Determine the priority list for the digraph from Try it Now 1 using the decreasing time
algorithm.
Critical path algorithm
A sequence of tasks in the digraph is called a path. In the previous example, we saw that the
critical path dictates the minimum completion time for a schedule. Perhaps, then, it would
make sense to consider the critical path when creating our schedule. For example, in the last
schedule, the processors began working on tasks 1 and 3 because they were longer tasks, but
starting on task 2 earlier would have allowed work to begin on the long task 6 earlier.
The critical path algorithm allows you to create a priority list based on idea of critical paths.
Critical Path Algorithm (version 1)
1. Find the critical path.
2. The first task in the critical path gets added to the priority list.
3. Remove that task from the digraph
4. Repeat, finding the new critical path with the revised digraph.
Example 4
The original digraph from Example 3 has critical path T2, T6, T5, T8, T10, so T2 gets added
first to the priority list. Removing T2 from the digraph, it now looks like:
The critical path (longest path) in the remaining digraph is now T6, T5, T8, T10, so T6 is added
to the priority list and removed.
T1 (6) T5 (5)
T3 (7)
T4 (4)
T6 (10)
T7 (4)
T10 (7) T8 (3)
T9 (2)
164
Now there are two paths with the same longest length: T1, T5, T8, T10 and T3, T7, T8, T10. We
can add T1 to the priority list (or T3 – we usually add the one with smaller item number) and
remove it, and continue the process.
I’m sure you can imagine that searching for the critical path every time you remove a task
from the digraph would get really tiring, especially for a large digraph. In practice, the
critical path algorithm is implementing by first working from the end backwards. This is
called the backflow algorithm.
Backflow Algorithm
1. Introduce an “end” vertex, and assign it a time of 0, shown in [brackets]
2. Move backwards to every vertex that has an arrow to the end and assign it a critical
time
3. From each of those vertices, move backwards and assign those vertices critical
times. Notice that the critical time for the earlier vertex will be that task’s time plus
the critical time for the later vertex.
Example: Consider this segment of digraph.
In this case, if T2 has already been determined to have a critical time of 10, then T1
will have a critical time of 5+10 = 15
If you have already assigned a critical time to a vertex, replace it only if the new
time is larger.
Example: In the digraph below, T1 should be labeled with a critical time of 16,
since it is the longer of 5+10 and 5+11.
4. Repeat until all vertices are labeled with their critical times
T1 (6) T5 (5)
T3 (7)
T4 (4) T7 (4)
T10 (7) T8 (3)
T9 (2)
T1 (5) T2 (4) [10]
T1 (5) [15] T2 (4) [10]
T1 (5) T2 (4) [10]
T3 (5) [11]
Scheduling 165
One you have completed the backflow algorithm, you can easily create the critical path
priority list by using the critical times you just found.
Critical Path Algorithm (version 2)
1. Apply the backflow algorithm to the digraph
2. Create the priority list by listing the tasks in order from longest critical time to
shortest critical time
This version of the Critical Path Algorithm will usually be the easier to implement.
Example 5
Applying this to our digraph from the earlier example, we start applying the backflow
algorithm.
We add an end vertex and give it a critical time of 0.
We then move back to T4, T9, and T10, labeling them with their critical times
From each vertex marked with a critical time, we go back. T7, for example, will get labeled
with a critical time 11 – the task time of 4 plus the critical time of 7 for T10. For T5, there are
two paths to the end. We use the longer, labeling T5 with critical time 5+7 = 12.
T1 (6) T5 (5)
T2 (3)
T3 (7)
T4 (4)
T6 (10)
T7 (4)
T10 (7) T8 (3)
T9 (2)
End [0]
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Wridemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.