Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computational Methods for Management and Economics Carla Gomes

Similar presentations


Presentation on theme: "Computational Methods for Management and Economics Carla Gomes"— Presentation transcript:

1 Computational Methods for Management and Economics Carla Gomes
Module 9c Network Models Special cases of the Minimum Cost Flow Problem – shortest path problem (Slides adapted from J.Orlin’s and Hillier’s)

2 Special Cases of the Minimum Cost Flow Model
Transportation and assignment problem (module 8) Shortest path problem

3 Shortest Path Problem

4 The Shortest Path Problem
1 2 3 4 5 6 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

5 Shortest Path Problem Where does it arise in practice?
Common applications shortest paths in a vehicle shortest paths in internet routing Less obvious: close connection to dynamic programming How will we solve the shortest path problem? Dijkstra’s algorithm

6 Shortest Path Problem Find the shortest paths by inspection. 1 2 3 4 5
6 Find the shortest paths by inspection.

7 Shortest Path Problem -1 1 Shortest Path Problem Special case of
1 2 3 4 5 6 Shortest Path Problem Special case of Min. Cost Flow Problem. Why? All arcs have capacity 1

8 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: xij = 1 if arc (i,j) is in the path. xij = 0 if arc (i,j) is not in the path

9 of Shortest Path Problem
Constraint matrix of Shortest Path Problem 1 2 3 4 5 6 x12 x13 x23 x25 x24 x35 x46 x54 x56 1 = 1 -1 = 1 -1 = 1 -1 = 1 -1 = -1 = The constraint matrix is the node arc incidence matrix

10 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.

11 Shortest Path Pivoting
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

12 Littletown Fire Department
Littletown is a small town in a rural area. Its fire department serves a relatively large geographical area that includes many farming communities. Since there are numerous roads throughout the area, many possible routes may be available for traveling to any given farming community. Question: Which route from the fire station to a certain farming community minimizes the total number of miles?

13 The Littletown Road System
Figure The road system between the Littletown Fire Station and a certain farming community, where A, B, … , H are junctions and the number next to each road shows its distance in miles.

14 The Network Representation
Figure The network representation of Figure 7.11 as a shortest path problem.

15 Spreadsheet Model Figure A spreadsheet model for the Littletown Fire Department shortest path problem, including the target cell Total Distance (D29). The values of 1 in the changing cells On Route (D4:D27) reveal the optimal solution obtained by the Solver for the shortest path (19 miles) from the fire station to the farming community. Note: in order to use the LP model we have to consider direct arcs  Replace undirected arcs with two arcs – in particular the cases in which it makes sense to travel in both directions.

16 Assumptions of a Shortest Path Problem
You need to choose a path through the network that starts at a certain node, called the origin, and ends at another certain node, called the destination. The lines connecting certain pairs of nodes commonly are links (which allow travel in either direction), although arcs (which only permit travel in one direction) also are allowed. Associated with each link (or arc) is a nonnegative number called its length. (Be aware that the drawing of each link in the network typically makes no effort to show its true length other than giving the correct number next to the link.) The objective is to find the shortest path (the path with the minimum total length) from the origin to the destination.

17 Applications of Shortest Path Problems
Minimize the total distance traveled. Minimize the total cost of a sequence of activities. Minimize the total time of a sequence of activities.

18 Minimizing Total Cost: Sarah’s Car Fund
Sarah has just graduated from high school. As a graduation present, her parents have given her a car fund of $21,000 to help purchase and maintain a three-year-old used car for college. Since operating and maintenance costs go up rapidly as the car ages, Sarah may trade in her car on another three-year-old car one or more times during the next three summers if it will minimize her total net cost. (At the end of the four years of college, her parents will trade in the current used car on a new car for Sarah.) Question: When should Sarah trade in her car (if at all) during the next three summers?

19 Sarah’s Cost Data Operating and Maintenance Costs for Ownership Year
Trade-in Value at End of Ownership Year Purchase Price 1 2 3 4 $12,000 $2,000 $3,000 $4,500 $6,500 $8,500 Table 7.2 Sarah’s data each time she purchases a three-year-old car

20 Shortest Path Formulation
Buying at moment x x y Trading in at moment Y Figure Formulation of the problem of when Sarah should trade in her car as a shortest path problem. The node labels measure the number of years from now. Each arc represents purchasing a car and then trading it in later. Arc length = purchase price + operating and maintenance cost- trade-in value

21 Spreadsheet Model Figure A spreadsheet model that formulates Sarah’s problem as a shortest path problem where the objective is to minimize the total cost instead of the total distance. After applying the Solver, the values of 1 in the changing cells On Route (D12:D21) identify the shortest (least expensive) path for scheduling trade-ins.

22 Planning Vehicle Replacement at Phillips Petroleum
Phillips Petroleum had a fleet of 1,500 cars and 3,800 trucks. Modeled replacement strategy as shortest path model (20-year time horizon)—solved model once for each class of vehicle. Could keep, purchase (replace), or lease, at 3-month intervals. Costs considered included: Maintenance and operating costs (fuel, oil, repair), Leasing cost for leased vehicles, Purchasing cost for purchased vehicles, State license fees and road taxes, Tax effects (investment tax credits, depreciation) First used to make lease-or-buy decision, then vehicle-replacement strategy, and more recently for other equipment (non-vehicle). For more details, see Waddell (1983) Jul-Aug Interfaces article, “A Model for Equipment Replacement Decisions and Policies”.

23 Dijkstra’s Algorithm for the Shortest Path Problem
1 2 3 4 5 6 Exercise: find the shortest path from node 1 to all other nodes. Keep track of distances using labels, d(i) and each node’s immediate predecessor, pred(i). d(1)= 0, pred(1)=0; d(2) = 2, pred(2)=1 Find the other distances, in order of increasing distance from node 1.

24 A Key Step in Shortest Path Algorithms
Let d( ) denote a vector of temporary distance labels. d(j) is the length of some path from the origin node 1 to node j. Procedure Update(i) for each (i,j) Î A(i) do if d(j) > d(i) + cij then d(j) : = d(i) + cij and pred(j) : = i; i j 62 10 1 Path P 78 72 Up to this point, the best path from 1 to j has length 78 But P, (i,j) is a path from 1 to j of length 72.

25 Dijkstra’s Algorithm Initialize distances.
LIST = set of temporary nodes begin d(s) : = 0 and pred(s) : = 0; d(j) : =  for each j  N - {s}; LIST : = {s}; while LIST  f do let d(i) : = min {d(j) : j  LIST}; remove node i from LIST; update(i) if d(j) decreases, place j in LIST end Select the node i on LIST with minimum distance label, and then update(i)

26 An Example \ 2, 3, \ 4, 5, \ \ \ 6} \ The End \ 2 \ 6 \ 6 \ 4 \ 3 \ 2
Scan the arcs out of i, and update d( ), pred( ), and LIST Scan the arcs out of i, and update d( ), pred( ), and LIST Scan the arcs out of i, and update d( ), pred( ), and LIST Scan the arcs out of i, and update d( ), pred( ), and LIST Scan the arcs out of i, and update d( ), pred( ), and LIST d(4) =  pred(4) = d(2) =  pred(2) = \ 2 1 \ 6 2 1 2 3 4 5 6 2 4 d(6) =  pred(6) = \ 6 5 d(1) = 0 1 6 pred(1) = 0 3 5 d(3) =  pred(3) = \ 4 1 \ 3 \ 2 d(5) =  pred(5) = \ 4 2 The End Find the node i on LIST with minimum distance. Find the node i on LIST with minimum distance. Find the node i on LIST with minimum distance. Find the node i on LIST with minimum distance. Find the node i on LIST with minimum distance. Find the node i on LIST with minimum distance. Initialize the distances and LIST. \ 2, 3, \ , 5, LIST = {1, \ \ \ 6} \

27 The Output from Dijkstra’s Algorithm
To find the shortest path from node j, trace back from the node to the source. Each node has one incoming arc (except for the source) 2 6 4 2 4 2 2 1 2 3 6 1 6 2 4 3 3 5 4 3 Dijkstra provides a shortest path from node 1 to all other nodes. It provides a shortest path tree. Note that this tree is an out-tree.

28 Comments on Dijkstra’s Algorithm
Dijkstra’s algorithm makes nodes permanent in increasing order of distance from the origin node. Dijkstra’s algorithm is efficient in its current form. The running time grows as n2, where n is the number of nodes It can be made much more efficient In practice it runs in time linear in the number of arcs (or almost so).


Download ppt "Computational Methods for Management and Economics Carla Gomes"

Similar presentations


Ads by Google