500 likes | 680 Views
Networks & Scheduling. Thinking Mathematically by Blitzer Section 15.4 Excursions in Modern Mathematics by Tannenbaum Sections 8.1 – 8.7. The Basic Elements of Scheduling. Excursions in Modern Mathematics , Section 8.1. First, a story.
E N D
Networks & Scheduling Thinking Mathematicallyby Blitzer Section 15.4 Excursions in Modern Mathematics by Tannenbaum Sections 8.1 – 8.7
The Basic Elementsof Scheduling Excursions in Modern Mathematics, Section 8.1
First, a story. . . The National Association of Home Builders estimates that it takes approximately 1100 hours to build an average American house. That means, if one person did every job, it would take 1100 hours. If lots of people are working to build the house, the total of everyone’s hours would be 1100, but the house would be finished much sooner. To get the house built in the fastest time, we must schedule workers so that we can accomplish as much work as possible at the same time. However, we must also take into account that some jobs cannot be started until others are finished. This is scheduling.
Four Parts to Scheduling (Definitions) • Processor – the “worker” who carries out the work • Task – individual unit of work that cannot be broken into smaller units and cannot be shared but must be carried out by only one processor A processor could be a robot, a computer, an ATM, a person, etc. Denoted with capital letter, like X Tasks can be in one of these states: Ineligible – not started since prior task is not completed Ready – prior task has been completed In execution – currently being carried out by a processor Completed – entirely finished
Four Parts to Scheduling (Definitions) • Processor – the “worker” who carries out the work • Task – individual unit of work that cannot be broken into smaller units and cannot be shared but must be carried out by only one processor • Processing time – amount of time required for one processor to execute one task Denoted with number in parenthesis after task letter, like X(5) Assumptions made regarding processing times: VERSATILITY – any processor can execute any task UNIFORMITY – processing time is the same (uniform) for each processor on a given task PERSEVERANCE – once a processor starts, it will complete the task without interruption
Four Parts to Scheduling (Definitions) Facts about precedence relations: Tasks that have no precedence requirement s between them are independent, and can be started at the same time or either one of them first. Precedence relations are transitive. Thus, if X Y and Y Z, then X Z. Precedence relations cannot form a cycle. • Processor – the “worker” who carries out the work • Task – individual unit of work that cannot be broken into smaller units and cannot be shared but must be carried out by only one processor • Processing time – amount of time required for one processor to execute one task • Precedence relations – formal restrictions on the order in which tasks can be executed (like prerequisites) Denoted with arrow, like XY, meaning X must happen before Y
Example A wrecked car needs exterior body work (4 hrs), engine repairs (5 hrs), painting and exterior finish work (7 hrs), and transmission repair (3 hrs). The painting and exterior finish work cannot be started until the exterior body work has been completed. Peter and Paul are mechanics who can work on separate tasks at the same time. Identify and label the processors. Peter P1and Paul P2 Identify and label tasks and times. body work A(4) engine repair B(5) painting C(7) transmission D(3) Identify precedence relations. A C
What if Peter does tasks A and D? Example What is the minimum finishing time to repair the car? Idle A A A A D D D Idle Idle Idle P1 P2 Idle B C C C C C C C B B B B 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 12 hours to repair the car Identify and label the processors. Peter P1and Paul P2 Can we do better? Identify and label tasks and times. body work A(4) engine repair B(5) painting C(7) transmission D(3) Identify precedence relations. A C
What if Peter does tasks A and B? Paul cannot do C until A is finished. Example What is the minimum finishing time to repair the car? Idle A A A A B Idle P1 P2 B B B B C C C C C C C Idle D D D 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 11 hours to repair the car Can we do better? body work A(4) engine repair B(5) painting C(7) transmission D(3) Peter P1and Paul P2 A C
Example What is the minimum finishing time to repair the car? A A A A C C C C C C C P1 P2 B B B B D D Idle Idle Idle B D 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 11 hours to repair the car Since 11 hours is the best time in which to repair the car, it is our criticalor optimaltime (the absolute minimum time based on all problem factors). body work A(4) engine repair B(5) painting C(7) transmission D(3) Peter P1and Paul P2 A C
Directed Graphs(Digraphs) Excursions in Modern Mathematics, Section 8.2
Definitions digraph – a graph in which the edges have a direction associated with them (directed graph) In a digraph with 2 vertices, there are 4 possibilities: X Y X Y X Y X Y
Definitions digraph – a graph in which the edges have a direction associated with them (directed graph) vertex set – list of all vertices in a digraph arc – edges with direction arc set – list of all arcs in a digraph (order matters!) incident – two vertices connected by an arc X is incident to Y Y is incident from X X Y
Definitions digraph – a graph in which the edges have a direction associated with them (directed graph) vertex set – list of all vertices in a digraph arc – edges with direction arc set – list of all arcs in a digraph (order matters!) incident – two vertices connected by an arc adjacent – two arcs connected by a common vertex
More Definitions path – a sequence of vertices and arcs so each is adjacent to the next and none is repeated cycle – a path that starts and ends at the same vertex outdegree – number of arcs that start at a given vertex indegree – number of arcs that end at a given vertex (circuit)
Example Give the vertex set. {A, B, C, D, E} Give the arc set. {AB, AC, BD, CA, CD, CE, EA, ED} Finish the statements: A is incident to ________ . A is incident from ________ . A is not incident to or from ___ . B and C E and C D Finish the statements: A has indegree ___ and has outdegree ___ . D has indegree ___ and has outdegree ___. 2 2 0 3
Example List paths from A to D: A B D A C D A C E D A C A B D Is A E D a path from A to D? No! List any cycles: A C E A A C A Is there a cycle through vertex D? No, because D is a “deadend.”
Example In the year 2050, there are human colonies on Mars where people live in Martian Habitat Units made from prefabricated kits that are built by construction robots. There are 15 separate tasks that must be performed and 17 precedence relations. Robots must be rented to perform the jobs. You must model a digraph from the task and precedence information in the following table in order to minimize the amount of time the robots are used and thus minimize your rental costs.
Example AP(7) IF(5) AF(5)
Example AP(7) IF(5) IW(7) AF(5)
Example AP(7) IF(5) IW(7) AF(5) AW(6)
Example AP(7) IF(5) IW(7) AF(5) AW(6) AD(8) ID(5)
Are the tasks in the chart a precedent for other tasks? Now check IF Check AP, AF, AW, AD
Example PL(4) AP(7) IF(5) IW(7) AF(5) AW(6) AD(8) ID(5)
Move to next “level” and check PL, IW, ID PL is precedent for IC, but so is HU which isn’t on digraph yet…wait
Example PL(4) IP(4) AP(7) IF(5) IW(7) AF(5) AW(6) AD(8) ID(5)
Move to next “level” and check PL, IW, ID
Example PL(4) IP(4) PU(3) AP(7) IF(5) IW(7) AF(5) AW(6) AD(8) ID(5)
Look where IP or PU are precedents…
Example PL(4) HU(4) IP(4) PU(3) AP(7) IF(5) IW(7) AF(5) AW(6) AD(8) ID(5)
Example IC(1) PL(4) HU(4) IP(4) PU(3) AP(7) IF(5) IW(7) AF(5) AW(6) AD(8) ID(5)
Example IC(1) FW(6) PL(4) HU(4) IP(4) PU(3) AP(7) IF(5) IW(7) AF(5) AW(6) AD(8) ID(5)
Example IC(1) FW(6) PL(4) PD(3) HU(4) IP(4) PU(3) AP(7) IF(5) IW(7) AF(5) AW(6) AD(8) ID(5)
Example IC(1) FW(6) PL(4) PD(3) HU(4) IP(4) PU(3) AP(7) IF(5) IW(7) EU(2) AF(5) AW(6) AD(8) ID(5)
Example IC(1) FW(6) PL(4) PD(3) HU(4) IP(4) PU(3) AP(7) END IF(5) IW(7) EU(2) AF(5) START AW(6) Then add “START” and “END” to complete the project digraph. AD(8) ID(5)
Schedulingwith Priority Lists Excursions in Modern Mathematics, Section 8.3
Definition priority list – list of all tasks ranked in the order we prefer to execute them The number of possible priority lists in a project with n tasks is n! (called factorial). Example How many possible priority lists are there for a project that has 5 tasks? 5! = 5 4 3 2 1 = 120 possible priority lists
Example Last-minute system checks must be performed before the launch of a satellite into space. For cost and safety, these must be done as quickly as possible. A project digraph and a priority list are provided. There are two computers. Priority List: A, B, C, D, E A(6) D(2) B(5) START END 17 hours to launch E(5) C(7) P1 P2 A E Idle A A A A A D Idle Idle Idle E E E E D B B B B B C C C C C C C Idle Idle Idle Idle Idle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Example Is this the best we can do…is it the most effective list? Total hours = 6 + 5 + 7 + 2 + 5 = 25, half is 12.5 hours. So 13 hours is probably best we can do! Let’s repeat the example with a new priority list. Priority List: E, D, C, B, A A(6) Next go to C. This is acceptable. Next go to D…but precedence relations do not allow it. Each time complete a task, go to earliest available time. Repeat priority list. Consider P2. Start over with priority list. Still at P2 after B. Start over with priority list. Start with E…but precedence relations do not allow it. D(2) B(5) START END 13 hours to launch E(5) C(7) P1 P2 C C C C C C C E E E E E Idle D D B B B B B A A A A A A 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Example Let’s repeat the example with the same priority list but with three computers instead of two. Priority List: E, D, C, B, A Finally P1 or P3 after time 7. Next spot: P2 after time 5. Now: P2 or P3 after time 6. A(6) Should we use a 3rd computer? D(2) B(5) 12 hours to launch START END Probably not…only saved us 1 unit of time. E(5) C(7) C P1 P2 P3 C C C C C C E E E E E B B B B B Idle D D Idle Idle Idle Idle A A A A A A Idle Idle Idle Idle Idle Idle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17