Presentation is loading. Please wait.

Presentation is loading. Please wait.

MIT and James Orlin © 2003 1 Networks II Quick Review of Shortest Path Problem The Critical Path Method (CPM) Topological Sort.

Similar presentations


Presentation on theme: "MIT and James Orlin © 2003 1 Networks II Quick Review of Shortest Path Problem The Critical Path Method (CPM) Topological Sort."— Presentation transcript:

1 MIT and James Orlin © 2003 1 Networks II Quick Review of Shortest Path Problem The Critical Path Method (CPM) Topological Sort

2 MIT and James Orlin © 2003 2 Directed and Undirected Networks 2 34 1 a b c d e An Undirected Graph 2 34 1 a b c d e A Directed Graph  The field of Network Optimization concerns optimization problems on networks

3 MIT and James Orlin © 2003 3 The Shortest Path Problem 1 2 3 4 5 6 2 4 2 1 3 4 2 3 2 What is the shortest path from a source node (often denoted as s) to a sink node, (often denoted as t)? What is the shortest path from node 1 to node 6? Assumptions for this lecture: 1. There is a path from the source to all other nodes. 2. All arc lengths are non-negative

4 MIT and James Orlin © 2003 4 Representation as an integer program An integer program is a linear program in which some or all of the variables are required to be integer We will formulate the shortest path problem as an integer program. –Find the shortest path from node 1 to node 6 Decision variables: –x ij = 1 if arc (i,j) is in the path. –x ij = 0 if arc (i,j) is not in the path

5 MIT and James Orlin © 2003 5 Constraints There is one arc out of node 1 There is one arc into node 6 For every other node i, the number of arcs on the path entering node i is the number of arcs leaving node i. Other constraints can be added, but this turns out to be enough.

6 MIT and James Orlin © 2003 6 1 2 3 4 5 6 The constraint matrix is the node arc incidence matrix 1100000001=111000000=1 0 000000=1 0000000=11 000000= 0000000 =x 12 x 13 x 23 x 25 x 24 x 35 x 46 x 54 x 56

7 MIT and James Orlin © 2003 7 On Incidence Matrices If the constraint matrix for a linear program is a node-arc incidence matrix (at most one 1 and at most one –1 per column), then the linear program solves in integer optima. Thus, we can solve the shortest path problem as an LP, and get the optimum path. Shortest Path Pivoting

8 MIT and James Orlin © 2003 8 Arcs and their interpretation Arcs as physical interpretation –paths –flows Arcs as relationship –person i reports to person j –task i must be completed before task j

9 MIT and James Orlin © 2003 9 Project Planning, Scheduling and Control Planning: organized approach to accomplish the goal of minimizing elapsed time of project –defines objectives and tasks; represents tasks interactions on a network; estimates time and resources Scheduling: a time-phased commitment of resources –identifies critical tasks which, if delayed, will delay the project’s completion time. Control: means of monitoring and revising the progress of a project

10 MIT and James Orlin © 2003 10 Development Attributes and Efforts

11 MIT and James Orlin © 2003 11 Network Representation Tasks (or activities) are represented by nodes –Each task has a duration denoted by d j –Node 0 represents the “start” and node n denotes the “finish” of the project Precedence relations are shown by “arcs” –specify what other tasks must be completed before the task in question can begin. –form an acyclic graph (no directed cycles). A path is a sequence of linked tasks going from beginning to end Critical path is the longest path

12 MIT and James Orlin © 2003 12 Precedence Examples ABA C B A C B Activity B begins when activity A ends. Activity C begins when both A and B end. Both activities B and C can begin as soon as A ends.

13 MIT and James Orlin © 2003 13 Project Network Example A,2B,3D,6 C,4 G,4 F,7 E,8 H,5 taskduration Remark: the tasks are labeled alphabetically. If (i,j) is an arc then i < j.

14 MIT and James Orlin © 2003 14 In a CPM Network, there are no directed cycles. Such a graph is called acyclic. Theorem. If a network has no directed cycles, then the nodes can be labeled so that for each arc (i,j), i < j. Such a node labeling is called a topological order. 1 2 5 4 36 78 5 1 3 2 1 1 2 4 7 3 6 With cycle 2-3-4-7-5-2, none of these 5 tasks could be scheduled first.

15 MIT and James Orlin © 2003 15 Finding a Topological Order First, find a node that has no incoming arcs. (If no such node exists, there is a directed cycle.) Label this as node 1. 1

16 MIT and James Orlin © 2003 16 Finding a Topological Order Next, find a node that has no incoming arcs from unlabeled nodes. 1 2

17 MIT and James Orlin © 2003 17 Finding a Topological Order Next, find a node that has no incoming arcs from unlabeled nodes. 1 2 3

18 MIT and James Orlin © 2003 18 Finding a Topological Order Next, find a node that has no incoming arcs from unlabeled nodes. 1 2 3 4 5

19 MIT and James Orlin © 2003 19 Finding a Topological Order Next, find a node that has no incoming arcs from unlabeled nodes. 1 2 3 4 5 6 7 8

20 MIT and James Orlin © 2003 20 Another application of topological sort Consider an Excel spreadsheet We say that cell A precedes cell B if cell B requires the value in cell A as part of its formula This leads to a precedence graph for cells. The precedence graph is acyclic (or else Excel reports an error). Excel topologically sorts the cells, and then computes the values in cells in topological order.

21 MIT and James Orlin © 2003 21 Formulating the CPM Problem Input Data: Precedence relationships and durations Decision Variable: t i : Earliest starting times for each of the tasks Objective: Minimize the elapsed time of the project min t n -t 1 where node n is the last node in the graph

22 MIT and James Orlin © 2003 22 Constraints If t j is the earliest starting time of a task, t i is the earliest starting time of an immediate predecessor and d i is the duration of the immediate predecessor, then we have t j  t i + d i for every arc (i, j)

23 MIT and James Orlin © 2003 23 tAtA tBtB tCtC tDtD tEtE tFtF tGtG tHtH 1000000  2 (A, B) 0100000  3 (B, C) 0010000  3 (B, D) 0001000  4 (C, E) 0000100  4 (C, F) 0000100  6 (D, F) 0000010  6 (D, G) 0000001  8 (E, H) 0000001  4 (G, H) Minimize t H -t A

24 MIT and James Orlin © 2003 24 tAtA tBtB tCtC tDtD tEtE tFtF tGtG tHtH 1000000  2 (A, B) 0100000  3 (B, C) 0010000  3 (B, D) On the constraint matrix The constraint matrix is the transpose of a node- arc incidence matrix. If we solve the linear program, the solution will be integer valued, assuming the data is integer valued.

25 MIT and James Orlin © 2003 25 Critical Path Definitions Earliest Start Time (ES) is the earliest time a task can feasibly start Earliest Finish Time (EF) is the earliest time a task can feasibly end Latest Start Time (LS) is the latest time a task can feasibly start, without delaying the project at all. Latest Finish Time (LF) is the latest time a task can feasibly end, without delaying the project all

26 MIT and James Orlin © 2003 26 Critical Path Method Forward Pass –Go through the jobs in order –Start each job at the earliest time while satisfying the precedence constraints –It finds the earliest start and finish times

27 MIT and James Orlin © 2003 27 The Gantt Chart 02468101214161820222426 AB Lay out the tasks on a time line The width of the task is the amount of time it takes.

28 MIT and James Orlin © 2003 28 CPM Example A,2B,3D,6 C,4 G,4 F,7 E,8 H,5 Forward Pass 02468101214161820222426 ABC D E F G H

29 MIT and James Orlin © 2003 29 CPM: The Backward Pass Fix the finishing time Look at tasks in reverse order Lay out tasks one at a time on the Gantt chart starting at the finish and working backwards to the start Start the task at its latest starting time

30 MIT and James Orlin © 2003 30 CPM Example A,2B,3D,6 C,4 G,4 F,7 E,8 H,5 Backward Pass 02468101214161820222426 ABC D E F G H

31 MIT and James Orlin © 2003 31 CPM and the Critical Path The time to complete the schedule is at least as long as any path. A,2B,3D,6 C,4 G,4 F,7 E,8 H,5 The length of A-B-C-F-H is 21

32 MIT and James Orlin © 2003 32 CPM and the Critical Path A-B-D-F-H is the longest path. Its length is 23 A,2B,3D,6 C,4 G,4 F,7 E,8 H,5 Theorem: The minimum length of the schedule is the length of the longest path. The longest path is called the critical path

33 MIT and James Orlin © 2003 33 02468101214161820222426 CE Latest and earliest times, and the critical path AB DF G H 02468101214161820222426 AB C D E F G H Look for tasks whose earliest start time and latest start time are the same. These tasks are critical, and are on a critical path.

34 MIT and James Orlin © 2003 34 CPM Example Critical path are found by identifying those tasks where ES=LS (equivalently, EF=LF) No flexibility in scheduling tasks on the critical path A-B-D-F-H is is the critical path The makespan of the critical path equals the LF of the final task (23 in example) Slack is the difference between LS and ES

35 MIT and James Orlin © 2003 35 CPM Spreadsheet The LP will not automatically put all times at the earliest possible. It will set the completion time to be as early as possible. You can “fool” the LP into giving the EST by minimizing the sum of completion times. Consider the possibility of reducing the final completion time by reducing the time of tasks. Suppose that reducing task j by x j units costs c j x j. Suppose the budget for reducing tasks is B. spreadsheet

36 MIT and James Orlin © 2003 36 More on Project Management CPM –Advantage of ease of use –Lays out the Gantt chart (nicely visual) –Identifies the critical path –Used in practice on large projects e.g., used for the big dig Other issues –Tasks take resources, which are limited –Task times are really random variables –Unpredictable things happen

37 MIT and James Orlin © 2003 37 On variability of tasks Consider 10 independent tasks –each takes 1 unit of time on average –the time it takes is uniformly distributed between 0 and 2. CPM (uses expected value) Modeling Randomness The random schedule takes longer

38 MIT and James Orlin © 2003 38 On Incorporating Variability Program Evaluation and Review Technique (PERT) –Attempts to incorporate variability in the durations –Assume mean, , and variance,  2, of the durations can be estimated Simulation –Model variability using any distribution –simulate to see how long a schedule will take

39 MIT and James Orlin © 2003 39 Incorporating Resource Constraints Each task can have resources that it needs –3 construction workers –1 crane –etc In scheduling, do not use more resources than are available at any time –Makes the problem much more difficult to solve exactly. Heuristics are used.

40 MIT and James Orlin © 2003 40 Dealing with the unknown VERY hard to model How does one model totally unforeseen events? –In the Big Dig, there is a leak in digging a tunnel despite assurances it would not happen –In the Hubble telescope, a firm assures that the mirrors are ground properly. By the time the mistake is discovered, the telescope is in outer space.

41 MIT and James Orlin © 2003 41 Project Management Software Explosive growth in software packages using these techniques Cost and capabilities vary greatly Yearly survey in PM Network Microsoft Project is most commonly used package today –Free 60 day trial versions: http://www.microsoft.com/office/98/project/ trial/info.htm

42 MIT and James Orlin © 2003 42 Summary Project management Simple model: we use estimates of the time for each task, and we use the precedence constraints The precedence graph is acyclic and can be topologically ordered CPM will lay out the Gantt chart and find the critical path Other extensions are possible

43 MIT and James Orlin © 2003 43 PERT Technique Using the estimated mean durations, apply the CPM calculation To obtain an estimate of the variance of the resulting makespan, add up the variances of the tasks on the critical path. Since the distribution is assumed normal, we can determine the probability that the makespan of our project will not exceed an upper bound.

44 MIT and James Orlin © 2003 44 PERT Drawbacks The critical path (I.e. the longest path) might have very low variance, whereas another path might have high variance What if there is more than one critical path? This assumes that the makespan is normally distributed, but if the number of tasks on a path is small (less than 5) then this may not hold.


Download ppt "MIT and James Orlin © 2003 1 Networks II Quick Review of Shortest Path Problem The Critical Path Method (CPM) Topological Sort."

Similar presentations


Ads by Google