MIT and James Orlin © Networks II Quick Review of Shortest Path Problem The Critical Path Method (CPM) Topological Sort
MIT and James Orlin © Directed and Undirected Networks a b c d e An Undirected Graph a b c d e A Directed Graph The field of Network Optimization concerns optimization problems on networks
MIT and James Orlin © The Shortest Path Problem 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
MIT and James Orlin © 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
MIT and James Orlin © 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.
MIT and James Orlin © The constraint matrix is the node arc incidence matrix = = = = = =x 12 x 13 x 23 x 25 x 24 x 35 x 46 x 54 x 56
MIT and James Orlin © 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
MIT and James Orlin © 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
MIT and James Orlin © 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
MIT and James Orlin © Development Attributes and Efforts
MIT and James Orlin © 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
MIT and James Orlin © 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.
MIT and James Orlin © 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.
MIT and James Orlin © 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 With cycle , none of these 5 tasks could be scheduled first.
MIT and James Orlin © 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
MIT and James Orlin © Finding a Topological Order Next, find a node that has no incoming arcs from unlabeled nodes. 1 2
MIT and James Orlin © Finding a Topological Order Next, find a node that has no incoming arcs from unlabeled nodes
MIT and James Orlin © Finding a Topological Order Next, find a node that has no incoming arcs from unlabeled nodes
MIT and James Orlin © Finding a Topological Order Next, find a node that has no incoming arcs from unlabeled nodes
MIT and James Orlin © 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.
MIT and James Orlin © 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
MIT and James Orlin © 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)
MIT and James Orlin © tAtA tBtB tCtC tDtD tEtE tFtF tGtG tHtH 2 (A, B) 3 (B, C) 3 (B, D) 4 (C, E) 4 (C, F) 6 (D, F) 6 (D, G) 8 (E, H) 4 (G, H) Minimize t H -t A
MIT and James Orlin © tAtA tBtB tCtC tDtD tEtE tFtF tGtG tHtH 2 (A, B) 3 (B, C) 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.
MIT and James Orlin © 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
MIT and James Orlin © 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
MIT and James Orlin © The Gantt Chart AB Lay out the tasks on a time line The width of the task is the amount of time it takes.
MIT and James Orlin © CPM Example A,2B,3D,6 C,4 G,4 F,7 E,8 H,5 Forward Pass ABC D E F G H
MIT and James Orlin © 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
MIT and James Orlin © CPM Example A,2B,3D,6 C,4 G,4 F,7 E,8 H,5 Backward Pass ABC D E F G H
MIT and James Orlin © 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
MIT and James Orlin © 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
MIT and James Orlin © CE Latest and earliest times, and the critical path AB DF G H 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.
MIT and James Orlin © 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
MIT and James Orlin © 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
MIT and James Orlin © 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
MIT and James Orlin © 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
MIT and James Orlin © 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
MIT and James Orlin © 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.
MIT and James Orlin © 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.
MIT and James Orlin © 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: trial/info.htm
MIT and James Orlin © 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
MIT and James Orlin © 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.
MIT and James Orlin © 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.