computational methods for management and economics carla gomes module 9c network models special...

Post on 23-Dec-2015

213 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Computational Methods forManagement and Economics

Carla Gomes

Module 9cNetwork Models

Special cases of the Minimum Cost Flow Problem –

shortest path problem

(Slides adapted from J.Orlin’s and Hillier’s)

Special Cases of the Minimum Cost Flow Model

• Transportation and assignment problem (module 8)

• Shortest path problem

Shortest Path Problem

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

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

Shortest Path Problem

1

2

3

4

5

6

2

4

2 1

3

4

2

3

2

Find the shortest paths by inspection.

Shortest Path Problem

1

2

3

4

5

6

2

4

2 1

3

4

2

3

2

Shortest Path ProblemSpecial case ofMin. Cost Flow Problem.

Why?

1 -1

0 0

00

All arcs have capacity 1

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

The constraint matrix is the node arc incidence matrix

1 1 0 00 0 0 0 0 1=

1 1 1-1 00000 0=

1-10 -1 00000 0=

1 -1-10 0 000 0 0=

1 1-1-10 00 0 0 0=

-1 -10 0 0 000 0 -1=

x12 x13 x23 x25x24 x35 x46 x54 x56

1

2

3

4

5

6

Constraint matrix of Shortest Path Problem

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.

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

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?

The Littletown Road System

Fire Station

H

G

F

E

D

C

B

A

3

6

4

2

1

7

5

4

6

8

6

4

3

4

6

7

52

3

Farming Community

The Network Representation

T

H

G

F

E

D

B

C

A

O (Destination)(Origin)

3

6

1

2

6

4

3

4

7

8

6

5

42

34

6

75

Spreadsheet Model3456789

1011121314151617181920212223242526272829

B C D E F G H I J KFrom To On Route Distance Nodes Net Flow Supply/Demand

Fire St. A 1 3 Fire St. 1 = 1Fire St. B 0 6 A 0 = 0Fire St. C 0 4 B 0 = 0

A B 1 1 C 0 = 0A D 0 6 D 0 = 0B A 0 1 E 0 = 0B C 0 2 F 0 = 0B D 0 4 G 0 = 0B E 1 5 H 0 = 0C B 0 2 Farm Com. -1 = -1C E 0 7D E 0 3D F 0 8E D 0 3E F 1 6E G 0 5E H 0 4F G 0 3F Farm Com. 1 4G F 0 3G H 0 2G Farm Com. 0 6H G 0 2H Farm Com. 0 7

Total Distance 19

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.

Assumptions of a Shortest Path Problem

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

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

3. 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.)

4. The objective is to find the shortest path (the path with the minimum total length) from the origin to the destination.

Applications of Shortest Path Problems

1.Minimize the total distance traveled.

2.Minimize the total cost of a sequence of activities.

3.Minimize the total time of a sequence of activities.

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?

Sarah’s Cost DataOperating and

Maintenance Costsfor Ownership Year

Trade-in Value at Endof Ownership Year

PurchasePrice 1 2 3 4 1 2 3 4

$12,000 $2,000 $3,000 $4,500 $6,500 $8,500 $6,500 $4,500 $3,000

Shortest Path Formulation

(Origin) (Destination)4321

17,000

10,50010,500

5,500 5,500 5,500 5,500

25,000

17,000

10,500

0

Buyingat moment x

x y

Trading inat moment Y

Arc length = purchase price + operating and maintenance cost- trade-in value

12 + 2 +3 - 6.5

Shortest path

Spreadsheet Model

34567891011121314151617181920212223

B C D E F G H I JOperating & Trade-in Value PurchaseMaint. Cost at End of Year Price

Year 1 $2,000 $8,500 $12,000Year 2 $3,000 $6,500Year 3 $4,500 $4,500Year 4 $6,500 $3,000

From To On Route Cost Nodes Net Flow Supply/DemandYear 0 Year 1 0 $5,500 Year 0 1 = 1Year 0 Year 2 1 $10,500 Year 1 0 = 0Year 0 Year 3 0 $17,000 Year 2 0 = 0Year 0 Year 4 0 $25,000 Year 3 0 = 0Year 1 Year 2 0 $5,500 Year 4 -1 = -1Year 1 Year 3 0 $10,500Year 1 Year 4 0 $17,000Year 2 Year 3 0 $5,500Year 2 Year 4 1 $10,500Year 3 Year 4 0 $5,500

Total Cost $21,000

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

Dijkstra’s Algorithm for the Shortest Path Problem

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.

1

2

3

4

5

6

2

4

2 1

3

4

2

3

2

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.

78

i j

62 101

Path P

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.

72

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;

Dijkstra’s Algorithm

begin

d(s) : = 0 and pred(s) : = 0;

d(j) : = for each j N - {s};

LIST : = {s};

while LIST do

beginlet d(i) : = min {d(j) : j LIST};remove node i from LIST;update(i)if d(j) decreases, place j in LIST

endend

Initialize distances.

LIST = set of temporary nodes

Select the node i on LIST with minimum distance label, and then update(i)

1

2

3

4

5

6

2

4

2 1

3

4

2

32

d(2) = pred(2) =

LIST = {1,

d(1) = 0pred(1) = 0

d(4) = pred(4) =

d(3) = pred(3) =

d(5) = pred(5) =

d(6) = pred(6) =

\ 2, 3,

\ 21

\ 41

\ 62

\ 42

\ 4, 5,\

\ 65

\ 6}\ \

An Example

\ 3\ 2

Initialize the distances and LIST.

Find the node i on LIST with minimum distance.

Scan the arcs out of i, and update d( ), pred( ), and LIST

1

Find the node i on LIST with minimum distance.

2

Scan the arcs out of i, and update d( ), pred( ), and LIST

Find the node i on LIST with minimum distance.

3

Scan the arcs out of i, and update d( ), pred( ), and LIST

Find the node i on LIST with minimum distance.

5

Scan the arcs out of i, and update d( ), pred( ), and LIST

Find the node i on LIST with minimum distance.

4

Scan the arcs out of i, and update d( ), pred( ), and LIST

Find the node i on LIST with minimum distance.

6

The End

The Output from Dijkstra’s Algorithm

1

2

3

4

5

6

2

4

2 1

3

4

2

32

0

2

3

6

4

6

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.

Each node has one incoming arc (except for the source)

To find the shortest path from node j, trace back from the node to the source.

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

top related